2020-05-24 23:13:21 +05:30
|
|
|
import { propertyOf } from 'lodash';
|
2021-01-29 00:20:46 +05:30
|
|
|
import getDesignListQuery from 'shared_queries/design_management/get_design_list.query.graphql';
|
|
|
|
import createFlash, { FLASH_TYPES } from '~/flash';
|
2020-05-24 23:13:21 +05:30
|
|
|
import { s__ } from '~/locale';
|
|
|
|
import { DESIGNS_ROUTE_NAME } from '../router/constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import allVersionsMixin from './all_versions';
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
export default {
|
|
|
|
mixins: [allVersionsMixin],
|
|
|
|
apollo: {
|
2021-01-03 14:25:43 +05:30
|
|
|
designCollection: {
|
2020-05-24 23:13:21 +05:30
|
|
|
query: getDesignListQuery,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
fullPath: this.projectPath,
|
|
|
|
iid: this.issueIid,
|
|
|
|
atVersion: this.designsVersion,
|
|
|
|
};
|
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
update: (data) => {
|
2020-10-24 23:57:45 +05:30
|
|
|
const designNodes = propertyOf(data)([
|
|
|
|
'project',
|
|
|
|
'issue',
|
|
|
|
'designCollection',
|
|
|
|
'designs',
|
|
|
|
'nodes',
|
|
|
|
]);
|
2021-01-03 14:25:43 +05:30
|
|
|
const copyState = propertyOf(data)(['project', 'issue', 'designCollection', 'copyState']);
|
|
|
|
return {
|
|
|
|
designs: designNodes,
|
|
|
|
copyState,
|
|
|
|
};
|
2020-05-24 23:13:21 +05:30
|
|
|
},
|
|
|
|
error() {
|
|
|
|
this.error = true;
|
|
|
|
},
|
|
|
|
result() {
|
|
|
|
if (this.$route.query.version && !this.hasValidVersion) {
|
2021-01-29 00:20:46 +05:30
|
|
|
createFlash({
|
|
|
|
message: s__(
|
2020-05-24 23:13:21 +05:30
|
|
|
'DesignManagement|Requested design version does not exist. Showing latest version instead',
|
|
|
|
),
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
this.$router.replace({ name: DESIGNS_ROUTE_NAME, query: { version: undefined } });
|
|
|
|
}
|
2021-01-03 14:25:43 +05:30
|
|
|
if (this.designCollection.copyState === 'ERROR') {
|
2021-01-29 00:20:46 +05:30
|
|
|
createFlash({
|
|
|
|
message: s__(
|
2021-01-03 14:25:43 +05:30
|
|
|
'DesignManagement|There was an error moving your designs. Please upload your designs below.',
|
|
|
|
),
|
2021-01-29 00:20:46 +05:30
|
|
|
type: FLASH_TYPES.WARNING,
|
|
|
|
});
|
2021-01-03 14:25:43 +05:30
|
|
|
}
|
2020-05-24 23:13:21 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2021-01-03 14:25:43 +05:30
|
|
|
designCollection: null,
|
2020-05-24 23:13:21 +05:30
|
|
|
error: false,
|
|
|
|
};
|
|
|
|
},
|
2021-01-03 14:25:43 +05:30
|
|
|
computed: {
|
|
|
|
designs() {
|
|
|
|
return this.designCollection?.designs || [];
|
|
|
|
},
|
|
|
|
},
|
2020-05-24 23:13:21 +05:30
|
|
|
};
|