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>2021-04-13 15:11:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-13 15:11:32 +0300
commit7ad147d6b88837b12b02d1b1711061dcdcd6c0e3 (patch)
tree75fccfb5f4f66d2a20d53be6e9c2e60964fad04e /app/assets/javascripts
parent37974ac0b196b06ffcc6cbea44385eaac1cc57bd (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/content_editor/extensions/code_block_highlight.js38
-rw-r--r--app/assets/javascripts/content_editor/services/create_editor.js30
-rw-r--r--app/assets/javascripts/content_editor/services/markdown_serializer.js5
-rw-r--r--app/assets/javascripts/diffs/components/app.vue14
-rw-r--r--app/assets/javascripts/diffs/components/diff_file.vue11
-rw-r--r--app/assets/javascripts/diffs/store/actions.js47
-rw-r--r--app/assets/javascripts/diffs/store/getters.js10
-rw-r--r--app/assets/javascripts/diffs/store/modules/diff_state.js1
-rw-r--r--app/assets/javascripts/diffs/store/modules/index.js6
-rw-r--r--app/assets/javascripts/diffs/store/mutation_types.js1
-rw-r--r--app/assets/javascripts/diffs/store/mutations.js6
-rw-r--r--app/assets/javascripts/pipelines/components/pipelines_list/pipelines_ci_templates.vue12
12 files changed, 95 insertions, 86 deletions
diff --git a/app/assets/javascripts/content_editor/extensions/code_block_highlight.js b/app/assets/javascripts/content_editor/extensions/code_block_highlight.js
new file mode 100644
index 00000000000..1d050ed208b
--- /dev/null
+++ b/app/assets/javascripts/content_editor/extensions/code_block_highlight.js
@@ -0,0 +1,38 @@
+import { CodeBlockHighlight as BaseCodeBlockHighlight } from 'tiptap-extensions';
+
+export default class GlCodeBlockHighlight extends BaseCodeBlockHighlight {
+ get schema() {
+ const baseSchema = super.schema;
+
+ return {
+ ...baseSchema,
+ attrs: {
+ params: {
+ default: null,
+ },
+ },
+ parseDOM: [
+ {
+ tag: 'pre',
+ preserveWhitespace: 'full',
+ getAttrs: (node) => {
+ const code = node.querySelector('code');
+
+ if (!code) {
+ return null;
+ }
+
+ return {
+ /* `params` is the name of the attribute that
+ prosemirror-markdown uses to extract the language
+ of a codeblock.
+ https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.js#L62
+ */
+ params: code.getAttribute('lang'),
+ };
+ },
+ },
+ ],
+ };
+ }
+}
diff --git a/app/assets/javascripts/content_editor/services/create_editor.js b/app/assets/javascripts/content_editor/services/create_editor.js
index 5ff80350f5d..128d332b0a2 100644
--- a/app/assets/javascripts/content_editor/services/create_editor.js
+++ b/app/assets/javascripts/content_editor/services/create_editor.js
@@ -1,7 +1,20 @@
import { isFunction, isString } from 'lodash';
import { Editor } from 'tiptap';
-import { Bold, Code } from 'tiptap-extensions';
+import {
+ Bold,
+ Italic,
+ Code,
+ Link,
+ Image,
+ Heading,
+ Blockquote,
+ HorizontalRule,
+ BulletList,
+ OrderedList,
+ ListItem,
+} from 'tiptap-extensions';
import { PROVIDE_SERIALIZER_OR_RENDERER_ERROR } from '../constants';
+import CodeBlockHighlight from '../extensions/code_block_highlight';
import createMarkdownSerializer from './markdown_serializer';
const createEditor = async ({ content, renderMarkdown, serializer: customSerializer } = {}) => {
@@ -10,7 +23,20 @@ const createEditor = async ({ content, renderMarkdown, serializer: customSeriali
}
const editor = new Editor({
- extensions: [new Bold(), new Code()],
+ extensions: [
+ new Bold(),
+ new Italic(),
+ new Code(),
+ new Link(),
+ new Image(),
+ new Heading({ levels: [1, 2, 3, 4, 5, 6] }),
+ new Blockquote(),
+ new HorizontalRule(),
+ new BulletList(),
+ new ListItem(),
+ new OrderedList(),
+ new CodeBlockHighlight(),
+ ],
});
const serializer = customSerializer || createMarkdownSerializer({ render: renderMarkdown });
diff --git a/app/assets/javascripts/content_editor/services/markdown_serializer.js b/app/assets/javascripts/content_editor/services/markdown_serializer.js
index 632d4f92218..e3b5775e320 100644
--- a/app/assets/javascripts/content_editor/services/markdown_serializer.js
+++ b/app/assets/javascripts/content_editor/services/markdown_serializer.js
@@ -60,9 +60,12 @@ const create = ({ render = () => null }) => {
// creates a bold alias for the strong mark converter
...defaultMarkdownSerializer.marks.strong,
},
+ italic: { open: '_', close: '_', mixable: true, expelEnclosingWhitespace: true },
});
- return serializer.serialize(document);
+ return serializer.serialize(document, {
+ tightLists: true,
+ });
},
};
};
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue
index 02fb5df07e8..8f41b848b0b 100644
--- a/app/assets/javascripts/diffs/components/app.vue
+++ b/app/assets/javascripts/diffs/components/app.vue
@@ -184,12 +184,7 @@ export default {
'viewDiffsFileByFile',
'mrReviews',
]),
- ...mapGetters('diffs', [
- 'whichCollapsedTypes',
- 'isParallelView',
- 'currentDiffIndex',
- 'fileCodequalityDiff',
- ]),
+ ...mapGetters('diffs', ['whichCollapsedTypes', 'isParallelView', 'currentDiffIndex']),
...mapGetters(['isNotesFetched', 'getNoteableData']),
diffs() {
if (!this.viewDiffsFileByFile) {
@@ -287,7 +282,6 @@ export default {
endpointMetadata: this.endpointMetadata,
endpointBatch: this.endpointBatch,
endpointCoverage: this.endpointCoverage,
- endpointCodequality: this.endpointCodequality,
endpointUpdateUser: this.endpointUpdateUser,
projectPath: this.projectPath,
dismissEndpoint: this.dismissEndpoint,
@@ -297,6 +291,10 @@ export default {
mrReviews: this.rehydratedMrReviews,
});
+ if (this.endpointCodequality) {
+ this.setCodequalityEndpoint(this.endpointCodequality);
+ }
+
if (this.shouldShow) {
this.fetchData();
}
@@ -341,6 +339,7 @@ export default {
...mapActions('diffs', [
'moveToNeighboringCommit',
'setBaseConfig',
+ 'setCodequalityEndpoint',
'fetchDiffFilesMeta',
'fetchDiffFilesBatch',
'fetchCoverageFiles',
@@ -532,7 +531,6 @@ export default {
:help-page-path="helpPagePath"
:can-current-user-fork="canCurrentUserFork"
:view-diffs-file-by-file="viewDiffsFileByFile"
- :codequality-diff="fileCodequalityDiff(file.file_path)"
/>
<div
v-if="showFileByFileNavigation"
diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue
index 93855db52b6..bdbc13a38c4 100644
--- a/app/assets/javascripts/diffs/components/diff_file.vue
+++ b/app/assets/javascripts/diffs/components/diff_file.vue
@@ -67,11 +67,6 @@ export default {
type: Boolean,
required: true,
},
- codequalityDiff: {
- type: Array,
- required: false,
- default: () => [],
- },
},
data() {
return {
@@ -85,7 +80,7 @@ export default {
genericError: GENERIC_ERROR,
},
computed: {
- ...mapState('diffs', ['currentDiffFileId']),
+ ...mapState('diffs', ['currentDiffFileId', 'codequalityDiff']),
...mapGetters(['isNotesFetched']),
...mapGetters('diffs', ['getDiffFileDiscussions']),
viewBlobHref() {
@@ -154,7 +149,9 @@ export default {
return loggedIn && featureOn;
},
hasCodequalityChanges() {
- return this.codequalityDiff.length > 0;
+ return (
+ this.codequalityDiff?.files && this.codequalityDiff?.files[this.file.file_path]?.length > 0
+ );
},
},
watch: {
diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js
index 81416984dbf..1c66ad1a18c 100644
--- a/app/assets/javascripts/diffs/store/actions.js
+++ b/app/assets/javascripts/diffs/store/actions.js
@@ -1,5 +1,4 @@
import Cookies from 'js-cookie';
-import Visibility from 'visibilityjs';
import Vue from 'vue';
import { deprecatedCreateFlash as createFlash } from '~/flash';
import { diffViewerModes } from '~/ide/constants';
@@ -53,15 +52,12 @@ import {
prepareLineForRenamedFile,
} from './utils';
-let eTagPoll;
-
export const setBaseConfig = ({ commit }, options) => {
const {
endpoint,
endpointMetadata,
endpointBatch,
endpointCoverage,
- endpointCodequality,
endpointUpdateUser,
projectPath,
dismissEndpoint,
@@ -75,7 +71,6 @@ export const setBaseConfig = ({ commit }, options) => {
endpointMetadata,
endpointBatch,
endpointCoverage,
- endpointCodequality,
endpointUpdateUser,
projectPath,
dismissEndpoint,
@@ -238,48 +233,6 @@ export const fetchCoverageFiles = ({ commit, state }) => {
coveragePoll.makeRequest();
};
-export const clearEtagPoll = () => {
- eTagPoll = null;
-};
-
-export const stopCodequalityPolling = () => {
- if (eTagPoll) eTagPoll.stop();
-};
-
-export const restartCodequalityPolling = () => {
- if (eTagPoll) eTagPoll.restart();
-};
-
-export const fetchCodequality = ({ commit, state, dispatch }) => {
- eTagPoll = new Poll({
- resource: {
- getCodequalityDiffReports: (endpoint) => axios.get(endpoint),
- },
- data: state.endpointCodequality,
- method: 'getCodequalityDiffReports',
- successCallback: ({ status, data }) => {
- if (status === httpStatusCodes.OK) {
- commit(types.SET_CODEQUALITY_DATA, data);
-
- eTagPoll.stop();
- }
- },
- errorCallback: () => createFlash(__('Something went wrong on our end. Please try again!')),
- });
-
- if (!Visibility.hidden()) {
- eTagPoll.makeRequest();
- }
-
- Visibility.change(() => {
- if (!Visibility.hidden()) {
- dispatch('restartCodequalityPolling');
- } else {
- dispatch('stopCodequalityPolling');
- }
- });
-};
-
export const setHighlightedRow = ({ commit }, lineCode) => {
const fileHash = lineCode.split('_')[0];
commit(types.SET_HIGHLIGHTED_ROW, lineCode);
diff --git a/app/assets/javascripts/diffs/store/getters.js b/app/assets/javascripts/diffs/store/getters.js
index b06faa2284b..dec3f87b03e 100644
--- a/app/assets/javascripts/diffs/store/getters.js
+++ b/app/assets/javascripts/diffs/store/getters.js
@@ -136,16 +136,6 @@ export const fileLineCoverage = (state) => (file, line) => {
};
/**
- * Returns the codequality diff data for a given file
- * @param {string} filePath
- * @returns {Array}
- */
-export const fileCodequalityDiff = (state) => (filePath) => {
- if (!state.codequalityDiff.files || !state.codequalityDiff.files[filePath]) return [];
- return state.codequalityDiff.files[filePath];
-};
-
-/**
* Returns index of a currently selected diff in diffFiles
* @returns {number}
*/
diff --git a/app/assets/javascripts/diffs/store/modules/diff_state.js b/app/assets/javascripts/diffs/store/modules/diff_state.js
index e5bbc9ed8f8..38366663cfd 100644
--- a/app/assets/javascripts/diffs/store/modules/diff_state.js
+++ b/app/assets/javascripts/diffs/store/modules/diff_state.js
@@ -29,7 +29,6 @@ export default () => ({
startVersion: null, // Null unless a target diff is selected for comparison that is not the "base" diff
diffFiles: [],
coverageFiles: {},
- codequalityDiff: {},
mergeRequestDiffs: [],
mergeRequestDiff: null,
diffViewType: viewTypeFromQueryString || viewTypeFromCookie || defaultViewType,
diff --git a/app/assets/javascripts/diffs/store/modules/index.js b/app/assets/javascripts/diffs/store/modules/index.js
index 6860e24db6b..03d11e60745 100644
--- a/app/assets/javascripts/diffs/store/modules/index.js
+++ b/app/assets/javascripts/diffs/store/modules/index.js
@@ -1,7 +1,7 @@
-import * as actions from '../actions';
+import * as actions from 'ee_else_ce/diffs/store/actions';
+import createState from 'ee_else_ce/diffs/store/modules/diff_state';
+import mutations from 'ee_else_ce/diffs/store/mutations';
import * as getters from '../getters';
-import mutations from '../mutations';
-import createState from './diff_state';
export default () => ({
namespaced: true,
diff --git a/app/assets/javascripts/diffs/store/mutation_types.js b/app/assets/javascripts/diffs/store/mutation_types.js
index b0f396f905a..4641731c4b6 100644
--- a/app/assets/javascripts/diffs/store/mutation_types.js
+++ b/app/assets/javascripts/diffs/store/mutation_types.js
@@ -11,7 +11,6 @@ export const SET_MR_FILE_REVIEWS = 'SET_MR_FILE_REVIEWS';
export const SET_DIFF_VIEW_TYPE = 'SET_DIFF_VIEW_TYPE';
export const SET_COVERAGE_DATA = 'SET_COVERAGE_DATA';
-export const SET_CODEQUALITY_DATA = 'SET_CODEQUALITY_DATA';
export const SET_MERGE_REQUEST_DIFFS = 'SET_MERGE_REQUEST_DIFFS';
export const TOGGLE_LINE_HAS_FORM = 'TOGGLE_LINE_HAS_FORM';
export const ADD_CONTEXT_LINES = 'ADD_CONTEXT_LINES';
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js
index eacf76234fc..9ff9a02d444 100644
--- a/app/assets/javascripts/diffs/store/mutations.js
+++ b/app/assets/javascripts/diffs/store/mutations.js
@@ -33,7 +33,6 @@ export default {
endpointMetadata,
endpointBatch,
endpointCoverage,
- endpointCodequality,
endpointUpdateUser,
projectPath,
dismissEndpoint,
@@ -47,7 +46,6 @@ export default {
endpointMetadata,
endpointBatch,
endpointCoverage,
- endpointCodequality,
endpointUpdateUser,
projectPath,
dismissEndpoint,
@@ -91,10 +89,6 @@ export default {
Object.assign(state, { coverageFiles });
},
- [types.SET_CODEQUALITY_DATA](state, codequalityDiffData) {
- Object.assign(state, { codequalityDiff: codequalityDiffData });
- },
-
[types.RENDER_FILE](state, file) {
renderFile(file);
},
diff --git a/app/assets/javascripts/pipelines/components/pipelines_list/pipelines_ci_templates.vue b/app/assets/javascripts/pipelines/components/pipelines_list/pipelines_ci_templates.vue
index 4d4420436a5..c2ec8c57fd7 100644
--- a/app/assets/javascripts/pipelines/components/pipelines_list/pipelines_ci_templates.vue
+++ b/app/assets/javascripts/pipelines/components/pipelines_list/pipelines_ci_templates.vue
@@ -1,5 +1,6 @@
<script>
import { GlButton, GlCard, GlSprintf } from '@gitlab/ui';
+import ExperimentTracking from '~/experimentation/experiment_tracking';
import { mergeUrlParams } from '~/lib/utils/url_utility';
import { s__, sprintf } from '~/locale';
import { HELLO_WORLD_TEMPLATE_KEY } from '../../constants';
@@ -10,6 +11,7 @@ export default {
GlCard,
GlSprintf,
},
+ HELLO_WORLD_TEMPLATE_KEY,
i18n: {
cta: s__('Pipelines|Use template'),
testTemplates: {
@@ -51,6 +53,14 @@ export default {
),
};
},
+ methods: {
+ trackEvent(template) {
+ const tracking = new ExperimentTracking('pipeline_empty_state_templates', {
+ label: template,
+ });
+ tracking.event('template_clicked');
+ },
+ },
};
</script>
<template>
@@ -82,6 +92,7 @@ export default {
variant="confirm"
:href="helloWorldTemplateUrl"
data-testid="test-template-link"
+ @click="trackEvent($options.HELLO_WORLD_TEMPLATE_KEY)"
>
{{ $options.i18n.cta }}
</gl-button>
@@ -121,6 +132,7 @@ export default {
variant="confirm"
:href="template.link"
data-testid="template-link"
+ @click="trackEvent(template.name)"
>
{{ $options.i18n.cta }}
</gl-button>