Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-15 18:08:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-15 18:08:45 +0300
commitd9e71b0d412fb9d2d7fc8b00dddac21617eaaf19 (patch)
tree704cd8a52cf1e068bcd2e82cc1a0112e9674ef5d /app/assets/javascripts/static_site_editor
parent6ae38bb3b5dc719fb6a046dcbcce4671176395a2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/static_site_editor')
-rw-r--r--app/assets/javascripts/static_site_editor/components/edit_meta_controls.vue39
-rw-r--r--app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue18
2 files changed, 55 insertions, 2 deletions
diff --git a/app/assets/javascripts/static_site_editor/components/edit_meta_controls.vue b/app/assets/javascripts/static_site_editor/components/edit_meta_controls.vue
index 927b52dc72a..9f75c65a316 100644
--- a/app/assets/javascripts/static_site_editor/components/edit_meta_controls.vue
+++ b/app/assets/javascripts/static_site_editor/components/edit_meta_controls.vue
@@ -1,5 +1,6 @@
<script>
import { GlForm, GlFormGroup, GlFormInput, GlFormTextarea } from '@gitlab/ui';
+import AccessorUtilities from '~/lib/utils/accessor';
export default {
components: {
@@ -26,12 +27,47 @@ export default {
},
};
},
+ computed: {
+ editableStorageKey() {
+ return this.getId('local-storage', 'editable');
+ },
+ hasLocalStorage() {
+ return AccessorUtilities.isLocalStorageAccessSafe();
+ },
+ },
+ mounted() {
+ this.initCachedEditable();
+ this.preSelect();
+ },
methods: {
getId(type, key) {
return `sse-merge-request-meta-${type}-${key}`;
},
+ initCachedEditable() {
+ if (this.hasLocalStorage) {
+ const cachedEditable = JSON.parse(localStorage.getItem(this.editableStorageKey));
+ if (cachedEditable) {
+ this.editable = cachedEditable;
+ }
+ }
+ },
+ preSelect() {
+ this.$nextTick(() => {
+ this.$refs.title.$el.select();
+ });
+ },
+ resetCachedEditable() {
+ if (this.hasLocalStorage) {
+ window.localStorage.removeItem(this.editableStorageKey);
+ }
+ },
onUpdate() {
- this.$emit('updateSettings', { ...this.editable });
+ const payload = { ...this.editable };
+ this.$emit('updateSettings', payload);
+
+ if (this.hasLocalStorage) {
+ window.localStorage.setItem(this.editableStorageKey, JSON.stringify(payload));
+ }
},
},
};
@@ -46,6 +82,7 @@ export default {
>
<gl-form-input
:id="getId('control', 'title')"
+ ref="title"
v-model.lazy="editable.title"
type="text"
@input="onUpdate"
diff --git a/app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue b/app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue
index aa4c0eb7f1c..4e5245bd892 100644
--- a/app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue
+++ b/app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue
@@ -35,6 +35,12 @@ export default {
attributes: [{ variant: 'success' }, { disabled: this.disabled }],
};
},
+ secondaryProps() {
+ return {
+ text: __('Keep editing'),
+ attributes: [{ variant: 'default' }],
+ };
+ },
},
methods: {
hide() {
@@ -43,6 +49,13 @@ export default {
show() {
this.$refs.modal.show();
},
+ onPrimary() {
+ this.$emit('primary', this.mergeRequestMeta);
+ this.$refs.editMetaControls.resetCachedEditable();
+ },
+ onSecondary() {
+ this.hide();
+ },
onUpdateSettings(mergeRequestMeta) {
this.mergeRequestMeta = { ...mergeRequestMeta };
},
@@ -56,11 +69,14 @@ export default {
modal-id="edit-meta-modal"
:title="__('Submit your changes')"
:action-primary="primaryProps"
+ :action-secondary="secondaryProps"
size="sm"
- @primary="() => $emit('primary', mergeRequestMeta)"
+ @primary="onPrimary"
+ @secondary="onSecondary"
@hide="() => $emit('hide')"
>
<edit-meta-controls
+ ref="editMetaControls"
:title="mergeRequestMeta.title"
:description="mergeRequestMeta.description"
@updateSettings="onUpdateSettings"