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

60 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-01-29 00:20:46 +05:30
import getDesignListQuery from 'shared_queries/design_management/get_design_list.query.graphql';
2020-05-24 23:13:21 +05:30
import { findVersionId } from '../utils/design_management_utils';
export default {
apollo: {
allVersions: {
query: getDesignListQuery,
variables() {
return {
fullPath: this.projectPath,
iid: this.issueIid,
atVersion: null,
};
},
2021-03-08 18:12:59 +05:30
update: (data) => data.project.issue.designCollection.versions.nodes,
2020-10-24 23:57:45 +05:30
},
},
inject: {
projectPath: {
default: '',
},
issueIid: {
default: '',
2020-05-24 23:13:21 +05:30
},
},
computed: {
hasValidVersion() {
return (
this.$route.query.version &&
this.allVersions &&
2021-03-08 18:12:59 +05:30
this.allVersions.some((version) => version.id.endsWith(this.$route.query.version))
2020-05-24 23:13:21 +05:30
);
},
designsVersion() {
return this.hasValidVersion
? `gid://gitlab/DesignManagement::Version/${this.$route.query.version}`
: null;
},
latestVersionId() {
const latestVersion = this.allVersions[0];
2020-10-24 23:57:45 +05:30
return latestVersion && findVersionId(latestVersion.id);
2020-05-24 23:13:21 +05:30
},
isLatestVersion() {
if (this.allVersions.length > 0) {
return (
!this.$route.query.version ||
!this.latestVersionId ||
this.$route.query.version === this.latestVersionId
);
}
return true;
},
},
data() {
return {
allVersions: [],
};
},
};