summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/snippets/components/edit.vue
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/snippets/components/edit.vue')
-rw-r--r--app/assets/javascripts/snippets/components/edit.vue51
1 files changed, 10 insertions, 41 deletions
diff --git a/app/assets/javascripts/snippets/components/edit.vue b/app/assets/javascripts/snippets/components/edit.vue
index dd77d49803f..08683f25651 100644
--- a/app/assets/javascripts/snippets/components/edit.vue
+++ b/app/assets/javascripts/snippets/components/edit.vue
@@ -9,19 +9,14 @@ import FormFooterActions from '~/vue_shared/components/form/form_footer_actions.
import {
SNIPPET_MARK_EDIT_APP_START,
SNIPPET_MEASURE_BLOBS_CONTENT,
-} from '~/performance_constants';
+} from '~/performance/constants';
import eventHub from '~/blob/components/eventhub';
-import { performanceMarkAndMeasure } from '~/performance_utils';
+import { performanceMarkAndMeasure } from '~/performance/utils';
import UpdateSnippetMutation from '../mutations/updateSnippet.mutation.graphql';
import CreateSnippetMutation from '../mutations/createSnippet.mutation.graphql';
import { getSnippetMixin } from '../mixins/snippets';
-import {
- SNIPPET_CREATE_MUTATION_ERROR,
- SNIPPET_UPDATE_MUTATION_ERROR,
- SNIPPET_VISIBILITY_PRIVATE,
-} from '../constants';
-import defaultVisibilityQuery from '../queries/snippet_visibility.query.graphql';
+import { SNIPPET_CREATE_MUTATION_ERROR, SNIPPET_UPDATE_MUTATION_ERROR } from '../constants';
import { markBlobPerformance } from '../utils/blob';
import SnippetBlobActionsEdit from './snippet_blob_actions_edit.vue';
@@ -41,15 +36,7 @@ export default {
GlLoadingIcon,
},
mixins: [getSnippetMixin],
- apollo: {
- defaultVisibility: {
- query: defaultVisibilityQuery,
- manual: true,
- result({ data: { selectedLevel } }) {
- this.selectedLevelDefault = selectedLevel;
- },
- },
- },
+ inject: ['selectedLevel'],
props: {
markdownPreviewPath: {
type: String,
@@ -73,9 +60,12 @@ export default {
data() {
return {
isUpdating: false,
- newSnippet: false,
actions: [],
- selectedLevelDefault: SNIPPET_VISIBILITY_PRIVATE,
+ snippet: {
+ title: '',
+ description: '',
+ visibilityLevel: this.selectedLevel,
+ },
};
},
computed: {
@@ -112,13 +102,6 @@ export default {
}
return this.snippet.webUrl;
},
- newSnippetSchema() {
- return {
- title: '',
- description: '',
- visibilityLevel: this.selectedLevelDefault,
- };
- },
},
beforeCreate() {
performanceMarkAndMeasure({ mark: SNIPPET_MARK_EDIT_APP_START });
@@ -145,20 +128,6 @@ export default {
Flash(sprintf(defaultErrorMsg, { err }));
this.isUpdating = false;
},
- onNewSnippetFetched() {
- this.newSnippet = true;
- this.snippet = this.newSnippetSchema;
- },
- onExistingSnippetFetched() {
- this.newSnippet = false;
- },
- onSnippetFetch(snippetRes) {
- if (snippetRes.data.snippets.nodes.length === 0) {
- this.onNewSnippetFetched();
- } else {
- this.onExistingSnippetFetched();
- }
- },
getAttachedFiles() {
const fileInputs = Array.from(this.$el.querySelectorAll('[name="files[]"]'));
return fileInputs.map(node => node.value);
@@ -209,7 +178,7 @@ export default {
</script>
<template>
<form
- class="snippet-form js-requires-input js-quick-submit common-note-form"
+ class="snippet-form js-quick-submit common-note-form"
:data-snippet-type="isProjectSnippet ? 'project' : 'personal'"
data-testid="snippet-edit-form"
@submit.prevent="handleFormSubmit"