diff --git a/apps/st2-actions/actions-details.component.js b/apps/st2-actions/actions-details.component.js index c6316391a..84a3df31f 100644 --- a/apps/st2-actions/actions-details.component.js +++ b/apps/st2-actions/actions-details.component.js @@ -26,6 +26,9 @@ import { Link } from '@stackstorm/module-router'; import ActionReporter from '@stackstorm/module-action-reporter'; import AutoForm from '@stackstorm/module-auto-form'; import StringField from '@stackstorm/module-auto-form/fields/string'; +import EnumField from '@stackstorm/module-auto-form/fields/enum'; +import get from 'lodash/fp/get'; + import { FlexTable, FlexTableRow, @@ -48,7 +51,6 @@ import { } from '@stackstorm/module-panel'; import Time from '@stackstorm/module-time'; - @connect((state) => { const { action, executions, entrypoint } = state; return { action, executions, entrypoint }; @@ -64,6 +66,14 @@ export default class ActionsDetails extends React.Component { action: PropTypes.object, executions: PropTypes.array, entrypoint: PropTypes.string, + groups: PropTypes.array, + filter: PropTypes.string, + match: PropTypes.shape({ + params: PropTypes.shape({ + ref: PropTypes.string, + section: PropTypes.string, + }), + }), } state = { @@ -71,7 +81,13 @@ export default class ActionsDetails extends React.Component { runValue: null, runTrace: null, executionsVisible: {}, - isChecked:false, + openModel: false, + isChecked: false, + destinationPack:'', + destinationAction:'', + packs:[], + isRemoveFiles : false, + } componentDidMount() { @@ -129,11 +145,29 @@ export default class ActionsDetails extends React.Component { } } - componentDidUpdate(prevProps) { - const { id } = this.props; + UNSAFE_componentWillReceiveProps(nextProps) { + const {groups, filter} = nextProps; + const packs = []; + if(!filter) { + groups && groups.map(data => { + packs.push(data.pack); + }); + + this.setState({packs : packs}); + } + } + + componentDidUpdate(prevProps, prevState) { + const { id , filter} = this.props; + + if (id && id !== prevProps.id) { this.fetchAction(id); } + + if(filter && filter !== prevProps.filter) { + this.setState({packs: prevState.packs}); + } } componentWillUnmount() { @@ -254,6 +288,101 @@ export default class ActionsDetails extends React.Component { return this.props.handleRun(...args); } + handleClone(e, srcPack,srcAction, destAction,destPack, overwrite) { + e.preventDefault(); + return store.dispatch({ + type: 'CLONE_ACTION', + promise: api.request({ + method: 'post', + path: `/actions/${srcPack}.${srcAction}/clone`, + },{ + 'dest_pack': destPack, + 'dest_action': destAction, + 'overwrite': overwrite, + + }) + .then((execution) => { + document.getElementById('overlay').style.display = 'none'; + notification.success(`Action "${srcAction}" has been cloned successfully.`); + this.getActions(); + return execution; + }) + .catch((err) => { + if (err.response) { + const error = document.getElementById('error'); + error.textContent = err.response.data.faultstring; + error.style.color = 'red'; + } + }), + }); + } + + getActions() { + return store.dispatch({ + type: 'FETCH_GROUPS', + promise: api.request({ + path: '/actions', + query: { + include_attributes: [ + 'ref', + 'pack', + 'name', + 'description', + 'runner_type', + ], + }, + }) + .catch((err) => { + notification.error('Unable to retrieve actions.', { err }); + throw err; + }), + }) + .then(() => { + const { id } = this.urlParams; + const { groups } = this.props; + + if (id && groups && !groups.some(({ actions }) => actions.some(({ ref }) => ref === id))) { + this.navigate({ id: false }); + } + }) + ; + } + + get urlParams() { + const { + ref = get('groups[0].actions[0].ref', this.props), + section = 'general', + } = this.props.match.params; + + return { + id: ref, + section, + }; + } + + openModel (e) { + const {action} = this.props; + const el = document.getElementById('overlay'); + el.style.display = 'block'; + this.setState({ destinationPack:action.pack, destinationAction:'', isChecked: false}); + } + + closeModel() { + document.getElementById('overlay').style.display = 'none'; + } + + handleDropdown(e) { + const error = document.getElementById('error'); + error.textContent = ''; + this.setState({destinationPack:e}); + } + + handleInput(e) { + const error = document.getElementById('error'); + error.textContent = ''; + this.setState({destinationAction:e}); + } + handleChange(e) { const isChecked = document.getElementById('checkbox').checked; if(isChecked) { @@ -264,28 +393,37 @@ export default class ActionsDetails extends React.Component { } } - openModel (e) { - this.setState({isChecked: false}); - const el = document.getElementById('overlay'); + handleDeleteChange(e) { + const isChecked = document.getElementById('deletecheckbox').checked; + if(isChecked) { + this.setState({isRemoveFiles:true}); + } + else { + this.setState({isRemoveFiles:false}); + } + } + + openDeleteModel (e) { + this.setState({isRemoveFiles: false}); + const el = document.getElementById('delete'); el.style.display = 'block'; } handleDelete (e) { e.preventDefault(); const { id } = this.props; - const {isChecked} = this.state; - document.getElementById('overlay').style.display = 'none'; - return this.props.handleDelete(id, isChecked); + const {isRemoveFiles} = this.state; + document.getElementById('delete').style.display = 'none'; + return this.props.handleDelete(id, isRemoveFiles); } - closeModel() { - - document.getElementById('overlay').style.display = 'none'; + closeDeleteModel() { + document.getElementById('delete').style.display = 'none'; } - render() { - const { section, action, executions, entrypoint } = this.props; + const { section, action, executions, entrypoint} = this.props; + if (!action) { return null; } @@ -325,7 +463,8 @@ export default class ActionsDetails extends React.Component { /> + + + + -
+

You are about to delete the action. Are you sure?

- this.handleChange(e)} /> Remove Files (This operation is irreversible.)


+ this.handleDeleteChange(e)} /> Remove Files (This operation is irreversible.)


- +
diff --git a/apps/st2-actions/actions-panel.component.js b/apps/st2-actions/actions-panel.component.js index 557006517..7f8e41c17 100644 --- a/apps/st2-actions/actions-panel.component.js +++ b/apps/st2-actions/actions-panel.component.js @@ -222,7 +222,6 @@ export default class ActionsPanel extends React.Component { .then((res) => { notification.success(`Action "${ref}" has been deleted successfully.`); this.navigate({ id: null }); - store.dispatch(flexActions.toggleAll()); this.fetchGroups(); return res; }) @@ -311,6 +310,8 @@ export default class ActionsPanel extends React.Component { id={id} section={section} + groups={groups} + filter={filter} /> ); diff --git a/apps/st2-workflows/package.json b/apps/st2-workflows/package.json index 43ce4bb8f..d013248a9 100644 --- a/apps/st2-workflows/package.json +++ b/apps/st2-workflows/package.json @@ -71,7 +71,7 @@ "react-redux": "^6.0.1", "react-router-dom": "^5.0.0", "redux": "^4.0.1", - "urijs": "^1.19.4 " + "urijs": "^1.19.7" }, "devDependencies": { "@babel/core": "7.4.3", diff --git a/modules/st2-login/login.component.js b/modules/st2-login/login.component.js index 9c049c783..e8a1471e4 100644 --- a/modules/st2-login/login.component.js +++ b/modules/st2-login/login.component.js @@ -164,7 +164,7 @@ export default class Login extends React.Component { } docsLink = 'https://docs.stackstorm.com/' - supportLink = 'https://forum.stackstorm.com/' + supportLink = 'https://github.com/StackStorm/st2/discussions' connect(e) { e.preventDefault(); diff --git a/modules/st2-menu/menu.component.js b/modules/st2-menu/menu.component.js index 89ce718ae..6c7882b84 100644 --- a/modules/st2-menu/menu.component.js +++ b/modules/st2-menu/menu.component.js @@ -75,7 +75,7 @@ export default class Menu extends React.Component { } docsLink = 'https://docs.stackstorm.com/' - supportLink = 'https://forum.stackstorm.com/' + supportLink = 'https://github.com/StackStorm/st2/discussions' idleLogout() { let t; diff --git a/package.json b/package.json index edd9d33cf..1db431036 100644 --- a/package.json +++ b/package.json @@ -80,14 +80,15 @@ "moment": "2.24.0", "node": "^14.16.1", "node-uuid": "^1.4.4", - "open": "^6.0.0", - "qs": "^6.0.4", + "open": "^8.4.0", + "qs": "^6.10.2", "react": "16.8.6", "react-dom": "16.8.6", "react-redux": "7.0.2", "redux": "^4.0.1", "set-value": "^4.1.0", - "urijs": "^1.19.4", + "tar": "^6.1.11", + "urijs": "^1.19.7", "websocket-extensions": "^0.1.4" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 196c2bd85..84e9f89b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3102,6 +3102,11 @@ chownr@^1.1.1, chownr@^1.1.2: resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== +chownr@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece" + integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== + ci-info@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" @@ -5293,6 +5298,13 @@ fs-minipass@^1.2.5: dependencies: minipass "^2.6.0" +fs-minipass@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" + integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== + dependencies: + minipass "^3.0.0" + fs-mkdirp-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz#0b7815fc3201c6a69e14db98ce098c16935259eb" @@ -6832,11 +6844,6 @@ is-windows@^1.0.0, is-windows@^1.0.1, is-windows@^1.0.2: resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== -is-wsl@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" - integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0= - is-wsl@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" @@ -8043,6 +8050,13 @@ minipass@^2.3.5, minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: safe-buffer "^5.1.2" yallist "^3.0.0" +minipass@^3.0.0: + version "3.1.6" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.6.tgz#3b8150aa688a711a1521af5e8779c1d3bb4f45ee" + integrity sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ== + dependencies: + yallist "^4.0.0" + minizlib@^1.2.1: version "1.3.3" resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" @@ -8050,6 +8064,14 @@ minizlib@^1.2.1: dependencies: minipass "^2.9.0" +minizlib@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931" + integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== + dependencies: + minipass "^3.0.0" + yallist "^4.0.0" + mississippi@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022" @@ -8086,7 +8108,7 @@ mkdirp-promise@^5.0.1: dependencies: mkdirp "*" -mkdirp@*: +mkdirp@*, mkdirp@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== @@ -8778,12 +8800,14 @@ open@^0.0.5: resolved "https://registry.yarnpkg.com/open/-/open-0.0.5.tgz#42c3e18ec95466b6bf0dc42f3a2945c3f0cad8fc" integrity sha1-QsPhjslUZra/DcQvOilFw/DK2Pw= -open@^6.0.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/open/-/open-6.4.0.tgz#5c13e96d0dc894686164f18965ecfe889ecfc8a9" - integrity sha512-IFenVPgF70fSm1keSd2iDBIDIBZkroLeuffXq+wKTzTJlBpesFWojV9lb8mzOfaAzM1sr7HQHuO0vtV0zYekGg== +open@^8.4.0: + version "8.4.0" + resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8" + integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q== dependencies: - is-wsl "^1.1.0" + define-lazy-prop "^2.0.0" + is-docker "^2.1.1" + is-wsl "^2.2.0" optionator@^0.8.1, optionator@^0.8.2, optionator@^0.8.3: version "0.8.3" @@ -9874,7 +9898,14 @@ qs@6.5.2, qs@~6.5.2: resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== -qs@^6.0.4, qs@^6.9.4: +qs@^6.10.2: + version "6.10.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.2.tgz#c1431bea37fc5b24c5bdbafa20f16bdf2a4b9ffe" + integrity sha512-mSIdjzqznWgfd4pMii7sHtaYF8rx8861hBO80SraY5GT0XQibWZWJSid0avzHGkDIZLImux2S5mXO0Hfct2QCw== + dependencies: + side-channel "^1.0.4" + +qs@^6.9.4: version "6.10.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.1.tgz#4931482fa8d647a5aab799c5271d2133b981fb6a" integrity sha512-M528Hph6wsSVOBiYUnGf+K/7w0hNshs/duGsNXPUCLH5XAqjEtiPGwNONLV0tBH8NoGb0mvD5JubnUTrujKDTg== @@ -11609,6 +11640,18 @@ tar@^4.4.10, tar@^4.4.12, tar@^4.4.8: safe-buffer "^5.1.2" yallist "^3.0.3" +tar@^6.1.11: + version "6.1.11" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" + integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== + dependencies: + chownr "^2.0.0" + fs-minipass "^2.0.0" + minipass "^3.0.0" + minizlib "^2.1.1" + mkdirp "^1.0.3" + yallist "^4.0.0" + temp-dir@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/temp-dir/-/temp-dir-1.0.0.tgz#0a7c0ea26d3a39afa7e0ebea9c1fc0bc4daa011d" @@ -12137,10 +12180,10 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -urijs@^1.19.4, "urijs@^1.19.4 ": - version "1.19.6" - resolved "https://registry.yarnpkg.com/urijs/-/urijs-1.19.6.tgz#51f8cb17ca16faefb20b9a31ac60f84aa2b7c870" - integrity sha512-eSXsXZ2jLvGWeLYlQA3Gh36BcjF+0amo92+wHPyN1mdR8Nxf75fuEuYTd9c0a+m/vhCjRK0ESlE9YNLW+E1VEw== +urijs@^1.19.7: + version "1.19.7" + resolved "https://registry.yarnpkg.com/urijs/-/urijs-1.19.7.tgz#4f594e59113928fea63c00ce688fb395b1168ab9" + integrity sha512-Id+IKjdU0Hx+7Zx717jwLPsPeUqz7rAtuVBRLLs+qn+J2nf9NGITWVCxcijgYxBqe83C7sqsQPs6H1pyz3x9gA== urix@^0.1.0: version "0.1.0"