debian-mirror-gitlab/app/assets/javascripts/design_management/mixins/all_designs.js

69 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-05-24 23:13:21 +05:30
import { propertyOf } from 'lodash';
2020-10-24 23:57:45 +05:30
import { deprecatedCreateFlash as createFlash } from '~/flash';
2020-05-24 23:13:21 +05:30
import { s__ } from '~/locale';
import getDesignListQuery from '../graphql/queries/get_design_list.query.graphql';
import allVersionsMixin from './all_versions';
import { DESIGNS_ROUTE_NAME } from '../router/constants';
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,
};
},
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) {
createFlash(
s__(
'DesignManagement|Requested design version does not exist. Showing latest version instead',
),
);
this.$router.replace({ name: DESIGNS_ROUTE_NAME, query: { version: undefined } });
}
2021-01-03 14:25:43 +05:30
if (this.designCollection.copyState === 'ERROR') {
createFlash(
s__(
'DesignManagement|There was an error moving your designs. Please upload your designs below.',
),
'warning',
);
}
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
};