diff --git a/.rubocop_todo/capybara/visibility_matcher.yml b/.rubocop_todo/rspec/capybara/visibility_matcher.yml similarity index 100% rename from .rubocop_todo/capybara/visibility_matcher.yml rename to .rubocop_todo/rspec/capybara/visibility_matcher.yml diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index beb66fcc2b4..699e4a0c856 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -e4d8f69ffa2efd3f2cb0adff5fa66f367f66f6fb +c13d9d902ef8175a0b1165ef0bc8643fb37b7897 diff --git a/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue b/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue index 9acc1cb62a1..bd3929c5f59 100644 --- a/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue +++ b/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue @@ -8,21 +8,18 @@ import { GlFormGroup, GlFormInput, GlFormSelect, - GlSegmentedControl, } from '@gitlab/ui'; -import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue'; -import axios from '~/lib/utils/axios_utils'; import csrf from '~/lib/utils/csrf'; import { setUrlFragment } from '~/lib/utils/url_utility'; import { s__, sprintf } from '~/locale'; import Tracking from '~/tracking'; -import MarkdownField from '~/vue_shared/components/markdown/field.vue'; +import MarkdownEditor from '~/vue_shared/components/markdown/markdown_editor.vue'; import { - CONTENT_EDITOR_LOADED_ACTION, SAVED_USING_CONTENT_EDITOR_ACTION, WIKI_CONTENT_EDITOR_TRACKING_LABEL, WIKI_FORMAT_LABEL, WIKI_FORMAT_UPDATED_ACTION, + CONTENT_EDITOR_LOADED_ACTION, } from '../constants'; const trackingMixin = Tracking.mixin({ @@ -74,10 +71,6 @@ export default { }, cancel: s__('WikiPage|Cancel'), }, - switchEditingControlOptions: [ - { text: s__('Wiki Page|Source'), value: 'source' }, - { text: s__('Wiki Page|Rich text'), value: 'richText' }, - ], components: { GlIcon, GlForm, @@ -87,13 +80,7 @@ export default { GlSprintf, GlLink, GlButton, - GlSegmentedControl, - MarkdownField, - LocalStorageSync, - ContentEditor: () => - import( - /* webpackChunkName: 'content_editor' */ '~/content_editor/components/content_editor.vue' - ), + MarkdownEditor, }, mixins: [trackingMixin], inject: ['formatOptions', 'pageInfo'], @@ -106,7 +93,7 @@ export default { commitMessage: '', isDirty: false, contentEditorEmpty: false, - switchEditingControlDisabled: false, + isContentEditorActive: false, }; }, computed: { @@ -162,12 +149,6 @@ export default { disableSubmitButton() { return this.noContent || !this.title; }, - isContentEditorActive() { - return this.isMarkdownFormat && this.useContentEditor; - }, - useContentEditor() { - return this.editingMode === 'richText'; - }, }, mounted() { this.updateCommitMessage(); @@ -178,23 +159,10 @@ export default { window.removeEventListener('beforeunload', this.onPageUnload); }, methods: { - renderMarkdown(content) { - return axios - .post(this.pageInfo.markdownPreviewPath, { text: content }) - .then(({ data }) => data.body); - }, - - setEditingMode(editingMode) { - this.editingMode = editingMode; - }, - async handleFormSubmit(e) { e.preventDefault(); - if (this.useContentEditor) { - this.trackFormSubmit(); - } - + this.trackFormSubmit(); this.trackWikiFormat(); // Wait until form field values are refreshed @@ -205,16 +173,6 @@ export default { this.isDirty = false; }, - handleContentChange() { - this.isDirty = true; - }, - - handleContentEditorChange({ empty, markdown, changed }) { - this.contentEditorEmpty = empty; - this.isDirty = changed; - this.content = markdown; - }, - onPageUnload(event) { if (!this.isDirty) return undefined; @@ -235,8 +193,13 @@ export default { this.commitMessage = newCommitMessage; }, - trackContentEditorLoaded() { - this.track(CONTENT_EDITOR_LOADED_ACTION); + notifyContentEditorActive() { + this.isContentEditorActive = true; + this.trackContentEditorLoaded(); + }, + + notifyContentEditorInactive() { + this.isContentEditorActive = false; }, trackFormSubmit() { @@ -256,12 +219,12 @@ export default { }); }, - enableSwitchEditingControl() { - this.switchEditingControlDisabled = false; + trackContentEditorLoaded() { + this.track(CONTENT_EDITOR_LOADED_ACTION); }, - disableSwitchEditingControl() { - this.switchEditingControlDisabled = true; + checkDirty(markdown) { + this.isDirty = this.pageInfo.content !== markdown; }, }, }; @@ -329,74 +292,22 @@ export default {
-
- -
- - - - -
- - -
- -
-
- + :autofocus="pageInfo.persisted" + :form-field-placeholder="$options.i18n.content.placeholder" + :form-field-aria-label="$options.i18n.content.label" + form-field-id="wiki_content" + form-field-name="wiki[content]" + @contentEditor="notifyContentEditorActive" + @markdownField="notifyContentEditorInactive" + @input="checkDirty" + />