2020-05-07 08:09:46 -04:00
|
|
|
import { propertyOf } from 'lodash';
|
2020-11-03 10:09:05 -05:00
|
|
|
import getDesignListQuery from 'shared_queries/design_management/get_design_list.query.graphql';
|
2022-10-05 08:09:04 -04:00
|
|
|
import { createAlert, VARIANT_WARNING } from '~/flash';
|
2020-05-07 08:09:46 -04:00
|
|
|
import { s__ } from '~/locale';
|
|
|
|
import { DESIGNS_ROUTE_NAME } from '../router/constants';
|
2021-02-01 10:08:56 -05:00
|
|
|
import allVersionsMixin from './all_versions';
|
2020-05-07 08:09:46 -04:00
|
|
|
|
|
|
|
export default {
|
|
|
|
mixins: [allVersionsMixin],
|
|
|
|
apollo: {
|
2020-09-22 11:09:37 -04:00
|
|
|
designCollection: {
|
2020-05-07 08:09:46 -04:00
|
|
|
query: getDesignListQuery,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
fullPath: this.projectPath,
|
|
|
|
iid: this.issueIid,
|
|
|
|
atVersion: this.designsVersion,
|
|
|
|
};
|
|
|
|
},
|
2020-12-23 16:10:24 -05:00
|
|
|
update: (data) => {
|
2020-07-30 08:09:33 -04:00
|
|
|
const designNodes = propertyOf(data)([
|
|
|
|
'project',
|
|
|
|
'issue',
|
|
|
|
'designCollection',
|
|
|
|
'designs',
|
|
|
|
'nodes',
|
|
|
|
]);
|
2020-09-22 11:09:37 -04:00
|
|
|
const copyState = propertyOf(data)(['project', 'issue', 'designCollection', 'copyState']);
|
|
|
|
return {
|
|
|
|
designs: designNodes,
|
|
|
|
copyState,
|
|
|
|
};
|
2020-05-07 08:09:46 -04:00
|
|
|
},
|
|
|
|
error() {
|
|
|
|
this.error = true;
|
|
|
|
},
|
|
|
|
result() {
|
|
|
|
if (this.$route.query.version && !this.hasValidVersion) {
|
2022-10-05 08:09:04 -04:00
|
|
|
createAlert({
|
2020-10-28 14:08:52 -04:00
|
|
|
message: s__(
|
2020-05-07 08:09:46 -04:00
|
|
|
'DesignManagement|Requested design version does not exist. Showing latest version instead',
|
|
|
|
),
|
2020-10-28 14:08:52 -04:00
|
|
|
});
|
2020-05-07 08:09:46 -04:00
|
|
|
this.$router.replace({ name: DESIGNS_ROUTE_NAME, query: { version: undefined } });
|
|
|
|
}
|
2020-09-22 11:09:37 -04:00
|
|
|
if (this.designCollection.copyState === 'ERROR') {
|
2022-10-05 08:09:04 -04:00
|
|
|
createAlert({
|
2020-10-28 14:08:52 -04:00
|
|
|
message: s__(
|
2020-09-22 11:09:37 -04:00
|
|
|
'DesignManagement|There was an error moving your designs. Please upload your designs below.',
|
|
|
|
),
|
2022-10-05 08:09:04 -04:00
|
|
|
variant: VARIANT_WARNING,
|
2020-10-28 14:08:52 -04:00
|
|
|
});
|
2020-09-22 11:09:37 -04:00
|
|
|
}
|
2020-05-07 08:09:46 -04:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-09-22 11:09:37 -04:00
|
|
|
designCollection: null,
|
2020-05-07 08:09:46 -04:00
|
|
|
error: false,
|
|
|
|
};
|
|
|
|
},
|
2020-09-22 11:09:37 -04:00
|
|
|
computed: {
|
|
|
|
designs() {
|
|
|
|
return this.designCollection?.designs || [];
|
|
|
|
},
|
|
|
|
},
|
2020-05-07 08:09:46 -04:00
|
|
|
};
|