Commit e7983d85 authored by Tom Quirk's avatar Tom Quirk

Compute isSaving property from filesToBeSaved

Renames savingDesignFiles->filesToBeSaved, and computes
isSaving this array (if there's anything in array, isSaving=true)
parent c5007456
...@@ -46,8 +46,7 @@ export default { ...@@ -46,8 +46,7 @@ export default {
permissions: { permissions: {
createDesign: false, createDesign: false,
}, },
isSaving: false, filesToBeSaved: [],
savingDesignFiles: [],
selectedDesigns: [], selectedDesigns: [],
}; };
}, },
...@@ -55,6 +54,9 @@ export default { ...@@ -55,6 +54,9 @@ export default {
isLoading() { isLoading() {
return this.$apollo.queries.designs.loading || this.$apollo.queries.permissions.loading; return this.$apollo.queries.designs.loading || this.$apollo.queries.permissions.loading;
}, },
isSaving() {
return this.filesToBeSaved.length > 0;
},
canCreateDesign() { canCreateDesign() {
return this.permissions.createDesign; return this.permissions.createDesign;
}, },
...@@ -101,8 +103,8 @@ export default { ...@@ -101,8 +103,8 @@ export default {
return null; return null;
} }
const filesArray = Array.from(files); this.filesToBeSaved = Array.from(files);
const optimisticResponse = filesArray.map(file => ({ const optimisticResponse = this.filesToBeSaved.map(file => ({
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26 // False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings // eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
__typename: 'Design', __typename: 'Design',
...@@ -135,9 +137,6 @@ export default { ...@@ -135,9 +137,6 @@ export default {
}, },
})); }));
this.isSaving = true;
this.savingDesignFiles = filesArray;
return this.$apollo return this.$apollo
.mutate({ .mutate({
mutation: uploadDesignMutation, mutation: uploadDesignMutation,
...@@ -170,7 +169,7 @@ export default { ...@@ -170,7 +169,7 @@ export default {
throw e; throw e;
}) })
.finally(() => { .finally(() => {
this.isSaving = false; this.filesToBeSaved = [];
}); });
}, },
changeSelectedDesigns(filename) { changeSelectedDesigns(filename) {
...@@ -194,7 +193,7 @@ export default { ...@@ -194,7 +193,7 @@ export default {
return ( return (
this.isLatestVersion && this.isLatestVersion &&
this.canCreateDesign && this.canCreateDesign &&
!this.savingDesignFiles.some(file => file.name === filename) !this.filesToBeSaved.some(file => file.name === filename)
); );
}, },
onDesignDelete() { onDesignDelete() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment