diff options
Diffstat (limited to 'app/assets/javascripts/blob')
16 files changed, 158 insertions, 70 deletions
diff --git a/app/assets/javascripts/blob/balsamiq_viewer.js b/app/assets/javascripts/blob/balsamiq_viewer.js index 2e537d8c000..fc86f630c4e 100644 --- a/app/assets/javascripts/blob/balsamiq_viewer.js +++ b/app/assets/javascripts/blob/balsamiq_viewer.js @@ -1,4 +1,4 @@ -import Flash from '../flash'; +import { deprecatedCreateFlash as Flash } from '../flash'; import BalsamiqViewer from './balsamiq/balsamiq_viewer'; import { __ } from '~/locale'; diff --git a/app/assets/javascripts/blob/components/blob_content_error.vue b/app/assets/javascripts/blob/components/blob_content_error.vue index 44dc4a6c727..7344b9cdff5 100644 --- a/app/assets/javascripts/blob/components/blob_content_error.vue +++ b/app/assets/javascripts/blob/components/blob_content_error.vue @@ -1,6 +1,6 @@ <script> -import { __ } from '~/locale'; import { GlSprintf, GlLink } from '@gitlab/ui'; +import { __ } from '~/locale'; import { BLOB_RENDER_ERRORS } from './constants'; export default { diff --git a/app/assets/javascripts/blob/components/blob_edit_content.vue b/app/assets/javascripts/blob/components/blob_edit_content.vue index 056b4ea4aa8..26ba7b98a39 100644 --- a/app/assets/javascripts/blob/components/blob_edit_content.vue +++ b/app/assets/javascripts/blob/components/blob_edit_content.vue @@ -1,6 +1,12 @@ <script> -import { initEditorLite } from '~/blob/utils'; import { debounce } from 'lodash'; +import { initEditorLite } from '~/blob/utils'; +import { + SNIPPET_MARK_BLOBS_CONTENT, + SNIPPET_MARK_EDIT_APP_START, + SNIPPET_MEASURE_BLOBS_CONTENT, + SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP, +} from '~/performance_constants'; export default { props: { @@ -14,6 +20,13 @@ export default { required: false, default: '', }, + // This is used to help uniquely create a monaco model + // even if two blob's share a file path. + fileGlobalId: { + type: String, + required: false, + default: '', + }, }, data() { return { @@ -30,17 +43,33 @@ export default { el: this.$refs.editor, blobPath: this.fileName, blobContent: this.value, + blobGlobalId: this.fileGlobalId, + }); + + this.editor.onChangeContent(debounce(this.onFileChange.bind(this), 250)); + + window.requestAnimationFrame(() => { + if (!performance.getEntriesByName(SNIPPET_MARK_BLOBS_CONTENT).length) { + performance.mark(SNIPPET_MARK_BLOBS_CONTENT); + performance.measure(SNIPPET_MEASURE_BLOBS_CONTENT); + performance.measure(SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP, SNIPPET_MARK_EDIT_APP_START); + } }); }, + beforeDestroy() { + this.editor.dispose(); + }, methods: { - triggerFileChange: debounce(function debouncedFileChange() { + onFileChange() { this.$emit('input', this.editor.getValue()); - }, 250), + }, }, }; </script> <template> <div class="file-content code"> - <pre id="editor" ref="editor" data-editor-loading @keyup="triggerFileChange">{{ value }}</pre> + <div id="editor" ref="editor" data-editor-loading> + <pre class="editor-loading-content">{{ value }}</pre> + </div> </div> </template> diff --git a/app/assets/javascripts/blob/components/blob_edit_header.vue b/app/assets/javascripts/blob/components/blob_edit_header.vue index e1e1d76f721..2cbbbddceeb 100644 --- a/app/assets/javascripts/blob/components/blob_edit_header.vue +++ b/app/assets/javascripts/blob/components/blob_edit_header.vue @@ -1,9 +1,10 @@ <script> -import { GlFormInput } from '@gitlab/ui'; +import { GlFormInput, GlButton } from '@gitlab/ui'; export default { components: { GlFormInput, + GlButton, }, inheritAttrs: false, props: { @@ -11,6 +12,16 @@ export default { type: String, required: true, }, + canDelete: { + type: Boolean, + required: false, + default: true, + }, + showDelete: { + type: Boolean, + required: false, + default: false, + }, }, data() { return { @@ -21,17 +32,27 @@ export default { </script> <template> <div class="js-file-title file-title-flex-parent"> - <gl-form-input - id="snippet_file_name" - v-model="name" - :placeholder=" - s__('Snippets|Give your file a name to add code highlighting, e.g. example.rb for Ruby') - " - name="snippet_file_name" - class="form-control js-snippet-file-name" - type="text" - v-bind="$attrs" - @change="$emit('input', name)" - /> + <div class="gl-display-flex gl-align-items-center gl-w-full"> + <gl-form-input + v-model="name" + :placeholder=" + s__('Snippets|Give your file a name to add code highlighting, e.g. example.rb for Ruby') + " + name="snippet_file_name" + class="form-control js-snippet-file-name" + type="text" + v-bind="$attrs" + @change="$emit('input', name)" + /> + <gl-button + v-if="showDelete" + class="gl-ml-4" + variant="danger" + category="secondary" + :disabled="!canDelete" + @click="$emit('delete')" + >{{ s__('Snippets|Delete file') }}</gl-button + > + </div> </div> </template> diff --git a/app/assets/javascripts/blob/components/blob_header.vue b/app/assets/javascripts/blob/components/blob_header.vue index 76c5779f3ae..fd40c51fec1 100644 --- a/app/assets/javascripts/blob/components/blob_header.vue +++ b/app/assets/javascripts/blob/components/blob_header.vue @@ -71,7 +71,7 @@ export default { </template> </blob-filepath> - <div class="file-actions d-none d-sm-flex"> + <div class="gl-display-none gl-display-sm-flex"> <viewer-switcher v-if="showViewerSwitcher" v-model="viewer" /> <slot name="actions"></slot> diff --git a/app/assets/javascripts/blob/components/blob_header_default_actions.vue b/app/assets/javascripts/blob/components/blob_header_default_actions.vue index 62fef108b47..daade611651 100644 --- a/app/assets/javascripts/blob/components/blob_header_default_actions.vue +++ b/app/assets/javascripts/blob/components/blob_header_default_actions.vue @@ -1,5 +1,5 @@ <script> -import { GlDeprecatedButton, GlButtonGroup, GlIcon, GlTooltipDirective } from '@gitlab/ui'; +import { GlButton, GlButtonGroup, GlTooltipDirective } from '@gitlab/ui'; import { BTN_COPY_CONTENTS_TITLE, BTN_DOWNLOAD_TITLE, @@ -10,9 +10,8 @@ import { export default { components: { - GlIcon, GlButtonGroup, - GlDeprecatedButton, + GlButton, }, directives: { GlTooltip: GlTooltipDirective, @@ -48,7 +47,7 @@ export default { </script> <template> <gl-button-group> - <gl-deprecated-button + <gl-button v-if="!hasRenderError" v-gl-tooltip.hover :aria-label="$options.BTN_COPY_CONTENTS_TITLE" @@ -56,26 +55,29 @@ export default { :disabled="copyDisabled" data-clipboard-target="#blob-code-content" data-testid="copyContentsButton" - > - <gl-icon name="copy-to-clipboard" :size="14" /> - </gl-deprecated-button> - <gl-deprecated-button + icon="copy-to-clipboard" + category="primary" + variant="default" + /> + <gl-button v-gl-tooltip.hover :aria-label="$options.BTN_RAW_TITLE" :title="$options.BTN_RAW_TITLE" :href="rawPath" target="_blank" - > - <gl-icon name="doc-code" :size="14" /> - </gl-deprecated-button> - <gl-deprecated-button + icon="doc-code" + category="primary" + variant="default" + /> + <gl-button v-gl-tooltip.hover :aria-label="$options.BTN_DOWNLOAD_TITLE" :title="$options.BTN_DOWNLOAD_TITLE" :href="downloadUrl" target="_blank" - > - <gl-icon name="download" :size="14" /> - </gl-deprecated-button> + icon="download" + category="primary" + variant="default" + /> </gl-button-group> </template> diff --git a/app/assets/javascripts/blob/components/blob_header_viewer_switcher.vue b/app/assets/javascripts/blob/components/blob_header_viewer_switcher.vue index 5b15fe2d7cc..902dd0b8eec 100644 --- a/app/assets/javascripts/blob/components/blob_header_viewer_switcher.vue +++ b/app/assets/javascripts/blob/components/blob_header_viewer_switcher.vue @@ -1,5 +1,5 @@ <script> -import { GlButton, GlButtonGroup, GlIcon, GlTooltipDirective } from '@gitlab/ui'; +import { GlButton, GlButtonGroup, GlTooltipDirective } from '@gitlab/ui'; import { RICH_BLOB_VIEWER, RICH_BLOB_VIEWER_TITLE, @@ -9,7 +9,6 @@ import { export default { components: { - GlIcon, GlButtonGroup, GlButton, }, @@ -52,19 +51,21 @@ export default { :title="$options.SIMPLE_BLOB_VIEWER_TITLE" :selected="isSimpleViewer" :class="{ active: isSimpleViewer }" + icon="code" + category="primary" + variant="default" @click="switchToViewer($options.SIMPLE_BLOB_VIEWER)" - > - <gl-icon name="code" :size="14" /> - </gl-button> + /> <gl-button v-gl-tooltip.hover :aria-label="$options.RICH_BLOB_VIEWER_TITLE" :title="$options.RICH_BLOB_VIEWER_TITLE" :selected="isRichViewer" :class="{ active: isRichViewer }" + icon="document" + category="primary" + variant="default" @click="switchToViewer($options.RICH_BLOB_VIEWER)" - > - <gl-icon name="document" :size="14" /> - </gl-button> + /> </gl-button-group> </template> diff --git a/app/assets/javascripts/blob/file_template_mediator.js b/app/assets/javascripts/blob/file_template_mediator.js index d2c0ef330e4..4409d7a33cc 100644 --- a/app/assets/javascripts/blob/file_template_mediator.js +++ b/app/assets/javascripts/blob/file_template_mediator.js @@ -1,12 +1,13 @@ import $ from 'jquery'; import Api from '~/api'; -import Flash from '../flash'; +import { deprecatedCreateFlash as Flash } from '../flash'; import FileTemplateTypeSelector from './template_selectors/type_selector'; import BlobCiYamlSelector from './template_selectors/ci_yaml_selector'; import DockerfileSelector from './template_selectors/dockerfile_selector'; import GitignoreSelector from './template_selectors/gitignore_selector'; import LicenseSelector from './template_selectors/license_selector'; +import MetricsDashboardSelector from './template_selectors/metrics_dashboard_selector'; import toast from '~/vue_shared/plugins/global_toast'; import { __ } from '~/locale'; import initPopover from '~/blob/suggest_gitlab_ci_yml'; @@ -30,6 +31,7 @@ export default class FileTemplateMediator { this.templateSelectors = [ GitignoreSelector, BlobCiYamlSelector, + MetricsDashboardSelector, DockerfileSelector, LicenseSelector, ].map(TemplateSelectorClass => new TemplateSelectorClass({ mediator: this })); diff --git a/app/assets/javascripts/blob/notebook/notebook_viewer.vue b/app/assets/javascripts/blob/notebook/notebook_viewer.vue index b1713989997..ea33d621d47 100644 --- a/app/assets/javascripts/blob/notebook/notebook_viewer.vue +++ b/app/assets/javascripts/blob/notebook/notebook_viewer.vue @@ -1,7 +1,7 @@ <script> +import { GlLoadingIcon } from '@gitlab/ui'; import axios from '~/lib/utils/axios_utils'; import notebookLab from '~/notebook/index.vue'; -import { GlLoadingIcon } from '@gitlab/ui'; export default { components: { diff --git a/app/assets/javascripts/blob/openapi/index.js b/app/assets/javascripts/blob/openapi/index.js index a6f28de799f..12cc2be8246 100644 --- a/app/assets/javascripts/blob/openapi/index.js +++ b/app/assets/javascripts/blob/openapi/index.js @@ -1,5 +1,5 @@ import { SwaggerUIBundle } from 'swagger-ui-dist'; -import flash from '~/flash'; +import { deprecatedCreateFlash as flash } from '~/flash'; import { __ } from '~/locale'; export default () => { diff --git a/app/assets/javascripts/blob/pdf/pdf_viewer.vue b/app/assets/javascripts/blob/pdf/pdf_viewer.vue index 64fc832ee54..96d6f500960 100644 --- a/app/assets/javascripts/blob/pdf/pdf_viewer.vue +++ b/app/assets/javascripts/blob/pdf/pdf_viewer.vue @@ -1,6 +1,6 @@ <script> -import PdfLab from '../../pdf/index.vue'; import { GlLoadingIcon } from '@gitlab/ui'; +import PdfLab from '../../pdf/index.vue'; export default { components: { diff --git a/app/assets/javascripts/blob/pipeline_tour_success_modal.vue b/app/assets/javascripts/blob/pipeline_tour_success_modal.vue index 3ccd84037a7..90eafb75758 100644 --- a/app/assets/javascripts/blob/pipeline_tour_success_modal.vue +++ b/app/assets/javascripts/blob/pipeline_tour_success_modal.vue @@ -1,7 +1,7 @@ <script> import { GlModal, GlSprintf, GlLink } from '@gitlab/ui'; -import { sprintf, s__, __ } from '~/locale'; import Cookies from 'js-cookie'; +import { sprintf, s__, __ } from '~/locale'; import { glEmojiTag } from '~/emoji'; import Tracking from '~/tracking'; @@ -11,8 +11,12 @@ export default { beginnerLink: 'https://about.gitlab.com/blog/2018/01/22/a-beginners-guide-to-continuous-integration/', exampleLink: 'https://docs.gitlab.com/ee/ci/examples/', + codeQualityLink: 'https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html', bodyMessage: s__( - 'MR widget|The pipeline will now run automatically every time you commit code. Pipelines are useful for deploying static web pages, detecting vulnerabilities in dependencies, static or dynamic application security testing (SAST and DAST), and so much more!', + `MR widget|The pipeline will test your code on every commit. A %{codeQualityLinkStart}code quality report%{codeQualityLinkEnd} will appear in your merge requests to warn you about potential code degradations.`, + ), + helpMessage: s__( + `MR widget|Take a look at our %{beginnerLinkStart}Beginner's Guide to Continuous Integration%{beginnerLinkEnd} and our %{exampleLinkStart}examples of GitLab CI/CD%{exampleLinkEnd} to learn more.`, ), modalTitle: sprintf( __("That's it, well done!%{celebrate}"), @@ -75,15 +79,15 @@ export default { modal-id="success-pipeline-modal-id-not-used" > <p> - {{ $options.bodyMessage }} + <gl-sprintf :message="$options.bodyMessage"> + <template #codeQualityLink="{content}"> + <gl-link :href="$options.codeQualityLink" target="_blank" class="font-size-inherit">{{ + content + }}</gl-link> + </template> + </gl-sprintf> </p> - <gl-sprintf - :message=" - s__(`MR widget|Take a look at our %{beginnerLinkStart}Beginner's Guide to Continuous Integration%{beginnerLinkEnd} - and our %{exampleLinkStart}examples of GitLab CI/CD%{exampleLinkEnd} - to see all the cool stuff you can do with it.`) - " - > + <gl-sprintf :message="$options.helpMessage"> <template #beginnerLink="{content}"> <gl-link :href="$options.beginnerLink" target="_blank"> {{ content }} @@ -105,7 +109,7 @@ export default { :data-track-event="$options.trackEvent" :data-track-label="trackLabel" > - {{ __('Go to Pipelines') }} + {{ __('See your pipeline in action') }} </a> </template> </gl-modal> diff --git a/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue b/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue index 932b6e8a0f7..aff6a56cb0b 100644 --- a/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue +++ b/app/assets/javascripts/blob/suggest_gitlab_ci_yml/components/popover.vue @@ -1,5 +1,5 @@ <script> -import { GlPopover, GlSprintf, GlDeprecatedButton, GlIcon } from '@gitlab/ui'; +import { GlPopover, GlSprintf, GlButton } from '@gitlab/ui'; import { parseBoolean, scrollToElement, setCookie, getCookie } from '~/lib/utils/common_utils'; import { s__ } from '~/locale'; import Tracking from '~/tracking'; @@ -29,8 +29,7 @@ export default { components: { GlPopover, GlSprintf, - GlIcon, - GlDeprecatedButton, + GlButton, }, mixins: [trackingMixin], props: { @@ -112,18 +111,17 @@ export default { <template #title> <span v-html="suggestTitle"></span> <span class="ml-auto"> - <gl-deprecated-button + <gl-button :aria-label="__('Close')" class="btn-blank" name="dismiss" + icon="close" :data-track-property="humanAccess" :data-track-value="$options.dismissTrackValue" :data-track-event="$options.clickTrackValue" :data-track-label="trackLabel" @click="onDismiss" - > - <gl-icon name="close" aria-hidden="true" /> - </gl-deprecated-button> + /> </span> </template> diff --git a/app/assets/javascripts/blob/template_selectors/metrics_dashboard_selector.js b/app/assets/javascripts/blob/template_selectors/metrics_dashboard_selector.js new file mode 100644 index 00000000000..b4accaadfa3 --- /dev/null +++ b/app/assets/javascripts/blob/template_selectors/metrics_dashboard_selector.js @@ -0,0 +1,28 @@ +import FileTemplateSelector from '../file_template_selector'; + +export default class MetricsDashboardSelector extends FileTemplateSelector { + constructor({ mediator }) { + super(mediator); + this.config = { + key: 'metrics-dashboard-yaml', + name: '.metrics-dashboard.yml', + pattern: /(.metrics-dashboard.yml)/, + type: 'metrics_dashboard_ymls', + dropdown: '.js-metrics-dashboard-selector', + wrapper: '.js-metrics-dashboard-selector-wrap', + }; + } + + initDropdown() { + this.$dropdown.glDropdown({ + data: this.$dropdown.data('data'), + filterable: true, + selectable: true, + search: { + fields: ['name'], + }, + clicked: options => this.reportSelectionName(options), + text: item => item.name, + }); + } +} diff --git a/app/assets/javascripts/blob/utils.js b/app/assets/javascripts/blob/utils.js index 840a3dbe450..a0211c8bb8e 100644 --- a/app/assets/javascripts/blob/utils.js +++ b/app/assets/javascripts/blob/utils.js @@ -1,14 +1,17 @@ import Editor from '~/editor/editor_lite'; -export function initEditorLite({ el, blobPath, blobContent }) { +export function initEditorLite({ el, ...args }) { if (!el) { throw new Error(`"el" parameter is required to initialize Editor`); } - const editor = new Editor(); + const editor = new Editor({ + scrollbar: { + alwaysConsumeMouseWheel: false, + }, + }); editor.createInstance({ el, - blobPath, - blobContent, + ...args, }); return editor; diff --git a/app/assets/javascripts/blob/viewer/index.js b/app/assets/javascripts/blob/viewer/index.js index b18faea628a..05ee8e49eb1 100644 --- a/app/assets/javascripts/blob/viewer/index.js +++ b/app/assets/javascripts/blob/viewer/index.js @@ -1,6 +1,6 @@ import $ from 'jquery'; import '~/behaviors/markdown/render_gfm'; -import Flash from '../../flash'; +import { deprecatedCreateFlash as Flash } from '../../flash'; import { handleLocationHash } from '../../lib/utils/common_utils'; import axios from '../../lib/utils/axios_utils'; import eventHub from '../../notes/event_hub'; |