diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /app/assets/javascripts/vue_shared/components/markdown | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'app/assets/javascripts/vue_shared/components/markdown')
6 files changed, 52 insertions, 8 deletions
diff --git a/app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue b/app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue index 709d3592828..926034efd10 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue @@ -1,9 +1,9 @@ <script> -import { GlDropdown, GlDropdownForm, GlFormTextarea, GlButton } from '@gitlab/ui'; +import { GlDropdown, GlDropdownForm, GlFormTextarea, GlButton, GlAlert } from '@gitlab/ui'; import { __, n__ } from '~/locale'; export default { - components: { GlDropdown, GlDropdownForm, GlFormTextarea, GlButton }, + components: { GlDropdown, GlDropdownForm, GlFormTextarea, GlButton, GlAlert }, props: { disabled: { type: Boolean, @@ -19,6 +19,11 @@ export default { required: false, default: 0, }, + errorMessage: { + type: String, + required: false, + default: null, + }, }, data() { return { @@ -55,6 +60,9 @@ export default { > <gl-dropdown-form class="gl-px-4! gl-m-0!"> <label for="commit-message">{{ __('Commit message') }}</label> + <gl-alert v-if="errorMessage" variant="danger" :dismissible="false" class="gl-mb-4"> + {{ errorMessage }} + </gl-alert> <gl-form-textarea id="commit-message" ref="commitMessage" diff --git a/app/assets/javascripts/vue_shared/components/markdown/field.vue b/app/assets/javascripts/vue_shared/components/markdown/field.vue index e1020ce656b..722df3cc58b 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/field.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/field.vue @@ -1,5 +1,5 @@ <script> -import { GlIcon } from '@gitlab/ui'; +import { GlIcon, GlSafeHtmlDirective } from '@gitlab/ui'; import $ from 'jquery'; import '~/behaviors/markdown/render_gfm'; import { debounce, unescape } from 'lodash'; @@ -24,6 +24,9 @@ export default { GlIcon, Suggestions, }, + directives: { + SafeHtml: GlSafeHtmlDirective, + }, mixins: [glFeatureFlagsMixin()], props: { /** @@ -308,6 +311,9 @@ export default { ); }, }, + safeHtmlConfig: { + ADD_TAGS: ['gl-emoji'], + }, }; </script> @@ -369,18 +375,19 @@ export default { <div v-show="previewMarkdown" ref="markdown-preview" + v-safe-html:[$options.safeHtmlConfig]="markdownPreview" class="js-vue-md-preview md md-preview-holder" - v-html="markdownPreview /* eslint-disable-line vue/no-v-html */" ></div> </template> <div v-if="referencedCommands && previewMarkdown && !markdownPreviewLoading" + v-safe-html:[$options.safeHtmlConfig]="referencedCommands" class="referenced-commands" - v-html="referencedCommands /* eslint-disable-line vue/no-v-html */" + data-testid="referenced-commands" ></div> <div v-if="shouldShowReferencedUsers" class="referenced-users"> <gl-icon name="warning-solid" /> - <span v-html="addMultipleToDiscussionWarning /* eslint-disable-line vue/no-v-html */"></span> + <span v-safe-html:[$options.safeHtmlConfig]="addMultipleToDiscussionWarning"></span> </div> </div> </template> diff --git a/app/assets/javascripts/vue_shared/components/markdown/header.vue b/app/assets/javascripts/vue_shared/components/markdown/header.vue index 13189670e17..d0bd5046bf0 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/header.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/header.vue @@ -10,7 +10,7 @@ import { } from '~/behaviors/shortcuts/keybindings'; import { getSelectedFragment } from '~/lib/utils/common_utils'; import { s__, __ } from '~/locale'; -import { CopyAsGFM } from '../../../behaviors/markdown/copy_as_gfm'; +import { CopyAsGFM } from '~/behaviors/markdown/copy_as_gfm'; import ToolbarButton from './toolbar_button.vue'; export default { @@ -187,7 +187,7 @@ export default { <template #tabs-end> <div data-testid="md-header-toolbar" - :class="{ 'gl-display-none': previewMarkdown }" + :class="{ 'gl-display-none!': previewMarkdown }" class="md-header-toolbar gl-ml-auto gl-pb-3 gl-justify-content-center" > <toolbar-button diff --git a/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff.vue b/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff.vue index 7d8d8c0b90e..4d10c3f0a51 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff.vue @@ -36,6 +36,11 @@ export default { required: false, default: 0, }, + failedToLoadMetadata: { + type: Boolean, + required: false, + default: false, + }, }, computed: { batchSuggestionsCount() { @@ -80,6 +85,7 @@ export default { :help-page-path="helpPagePath" :default-commit-message="defaultCommitMessage" :inapplicable-reason="suggestion.inapplicable_reason" + :failed-to-load-metadata="failedToLoadMetadata" @apply="applySuggestion" @applyBatch="applySuggestionBatch" @addToBatch="addSuggestionToBatch" diff --git a/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue b/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue index 648e9c9462f..8a1b8363f19 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue @@ -4,6 +4,10 @@ import { isLoggedIn } from '~/lib/utils/common_utils'; import { __ } from '~/locale'; import ApplySuggestion from './apply_suggestion.vue'; +const APPLY_SUGGESTION_ERROR_MESSAGE = __( + 'Unable to fully load the default commit message. You can still apply this suggestion and the commit message will be correct.', +); + export default { components: { GlBadge, GlIcon, GlButton, GlLoadingIcon, ApplySuggestion }, directives: { 'gl-tooltip': GlTooltipDirective }, @@ -52,6 +56,11 @@ export default { required: false, default: 0, }, + failedToLoadMetadata: { + type: Boolean, + required: false, + default: false, + }, }, data() { return { @@ -94,6 +103,9 @@ export default { return true; }, + applySuggestionErrorMessage() { + return this.failedToLoadMetadata ? APPLY_SUGGESTION_ERROR_MESSAGE : null; + }, }, methods: { apply(message) { @@ -171,6 +183,7 @@ export default { :disabled="isDisableButton" :default-commit-message="defaultCommitMessage" :batch-suggestions-count="batchSuggestionsCount" + :error-message="applySuggestionErrorMessage" class="gl-ml-3" @apply="apply" /> diff --git a/app/assets/javascripts/vue_shared/components/markdown/suggestions.vue b/app/assets/javascripts/vue_shared/components/markdown/suggestions.vue index 2f6776f835e..de3eda6b04f 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/suggestions.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/suggestions.vue @@ -47,6 +47,11 @@ export default { required: false, default: 0, }, + failedToLoadMetadata: { + type: Boolean, + required: false, + default: false, + }, }, data() { return { @@ -60,6 +65,9 @@ export default { noteHtml() { this.reset(); }, + failedToLoadMetadata() { + this.reset(); + }, }, mounted() { this.renderSuggestions(); @@ -105,6 +113,7 @@ export default { helpPagePath, defaultCommitMessage, suggestionsCount, + failedToLoadMetadata, } = this; const suggestion = suggestions && suggestions[suggestionIndex] ? suggestions[suggestionIndex] : {}; @@ -117,6 +126,7 @@ export default { helpPagePath, defaultCommitMessage, suggestionsCount, + failedToLoadMetadata, }, }); |