Merge pull request #3459 from mantis-toboggan-md/bugfix-namespace-move

fix namespace move-project action
This commit is contained in:
Nancy 2021-07-14 07:00:59 -07:00 committed by GitHub
commit 4986c4f122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<script> <script>
import { mapState } from 'vuex'; import { mapState, mapGetters } from 'vuex';
import Card from '@/components/Card'; import Card from '@/components/Card';
import AsyncButton from '@/components/AsyncButton'; import AsyncButton from '@/components/AsyncButton';
import LabeledSelect from '@/components/form/LabeledSelect'; import LabeledSelect from '@/components/form/LabeledSelect';
@ -11,28 +11,39 @@ export default {
components: { components: {
AsyncButton, Card, LabeledSelect, Loading AsyncButton, Card, LabeledSelect, Loading
}, },
async fetch() { async fetch() {
this.projects = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.PROJECT }); this.projects = await this.$store.dispatch('management/findAll', { type: MANAGEMENT.PROJECT });
}, },
data() { data() {
return { return {
modalName: 'move-modal', projects: [], targetProject: null modalName: 'move-modal', projects: [], targetProject: null
}; };
}, },
computed: { computed: {
...mapState('action-menu', ['showPromptMove', 'toMove']), ...mapState('action-menu', ['showPromptMove', 'toMove']),
...mapGetters(['currentCluster']),
excludedProjects() { excludedProjects() {
return this.toMove.map(namespace => namespace.project.shortId); return this.toMove.filter(namespace => !!namespace.project).map(namespace => namespace.project.shortId);
}, },
projectOptions() { projectOptions() {
return this.projects return this.projects.reduce((inCluster, project) => {
.map(p => ({ if (!this.excludedProjects.includes(project.shortId) && project.spec?.clusterName === this.currentCluster.id) {
value: p.shortId, inCluster.push({
label: p.nameDisplay value: project.shortId,
})) label: project.nameDisplay
.filter(pair => !this.excludedProjects.includes(pair.value) ); });
}
return inCluster;
}, []);
} }
}, },
watch: { watch: {
showPromptMove(show) { showPromptMove(show) {
if (show) { if (show) {
@ -42,6 +53,7 @@ export default {
} }
} }
}, },
methods: { methods: {
close() { close() {
this.$store.commit('action-menu/togglePromptMove'); this.$store.commit('action-menu/togglePromptMove');
@ -62,6 +74,7 @@ export default {
this.$emit('moving'); this.$emit('moving');
await Promise.all(promises); await Promise.all(promises);
finish(true); finish(true);
this.targetProject = null;
this.close(); this.close();
} catch (ex) { } catch (ex) {
finish(false); finish(false);