summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/commons/polyfills.js22
-rw-r--r--app/assets/javascripts/gfm_auto_complete.js57
-rw-r--r--app/assets/javascripts/ide/stores/modules/commit/actions.js4
-rw-r--r--app/assets/javascripts/monitoring/components/charts/time_series.vue2
-rw-r--r--app/assets/javascripts/test_utils/index.js2
5 files changed, 59 insertions, 28 deletions
diff --git a/app/assets/javascripts/commons/polyfills.js b/app/assets/javascripts/commons/polyfills.js
index dd300b8a307..dec3c637c22 100644
--- a/app/assets/javascripts/commons/polyfills.js
+++ b/app/assets/javascripts/commons/polyfills.js
@@ -1,24 +1,4 @@
-// ECMAScript polyfills
-import 'core-js/es/array/fill';
-import 'core-js/es/array/find';
-import 'core-js/es/array/find-index';
-import 'core-js/es/array/from';
-import 'core-js/es/array/includes';
-import 'core-js/es/number/is-integer';
-import 'core-js/es/object/assign';
-import 'core-js/es/object/values';
-import 'core-js/es/object/entries';
-import 'core-js/es/promise';
-import 'core-js/es/promise/finally';
-import 'core-js/es/string/code-point-at';
-import 'core-js/es/string/from-code-point';
-import 'core-js/es/string/includes';
-import 'core-js/es/string/starts-with';
-import 'core-js/es/string/ends-with';
-import 'core-js/es/symbol';
-import 'core-js/es/map';
-import 'core-js/es/weak-map';
-import 'core-js/modules/web.url';
+import 'core-js/stable';
// Browser polyfills
import 'formdata-polyfill';
diff --git a/app/assets/javascripts/gfm_auto_complete.js b/app/assets/javascripts/gfm_auto_complete.js
index de69daf5c22..c762e298eb8 100644
--- a/app/assets/javascripts/gfm_auto_complete.js
+++ b/app/assets/javascripts/gfm_auto_complete.js
@@ -1,6 +1,7 @@
import $ from 'jquery';
import 'at.js';
import _ from 'underscore';
+import SidebarMediator from '~/sidebar/sidebar_mediator';
import glRegexp from './lib/utils/regexp';
import AjaxCache from './lib/utils/ajax_cache';
import { spriteIcon } from './lib/utils/common_utils';
@@ -53,8 +54,8 @@ export const defaultAutocompleteConfig = {
};
class GfmAutoComplete {
- constructor(dataSources) {
- this.dataSources = dataSources || {};
+ constructor(dataSources = {}) {
+ this.dataSources = dataSources;
this.cachedData = {};
this.isLoadingData = {};
}
@@ -199,6 +200,16 @@ class GfmAutoComplete {
}
setupMembers($input) {
+ const fetchData = this.fetchData.bind(this);
+ const MEMBER_COMMAND = {
+ ASSIGN: '/assign',
+ UNASSIGN: '/unassign',
+ REASSIGN: '/reassign',
+ CC: '/cc',
+ };
+ let assignees = [];
+ let command = '';
+
// Team Members
$input.atwho({
at: '@',
@@ -225,6 +236,48 @@ class GfmAutoComplete {
callbacks: {
...this.getDefaultCallbacks(),
beforeSave: membersBeforeSave,
+ matcher(flag, subtext) {
+ const subtextNodes = subtext
+ .split(/\n+/g)
+ .pop()
+ .split(GfmAutoComplete.regexSubtext);
+
+ // Check if @ is followed by '/assign', '/reassign', '/unassign' or '/cc' commands.
+ command = subtextNodes.find(node => {
+ if (Object.values(MEMBER_COMMAND).includes(node)) {
+ return node;
+ }
+ return null;
+ });
+
+ // Cache assignees list for easier filtering later
+ assignees = SidebarMediator.singleton?.store?.assignees?.map(
+ assignee => `${assignee.username} ${assignee.name}`,
+ );
+
+ const match = GfmAutoComplete.defaultMatcher(flag, subtext, this.app.controllers);
+ return match && match.length ? match[1] : null;
+ },
+ filter(query, data, searchKey) {
+ if (GfmAutoComplete.isLoading(data)) {
+ fetchData(this.$inputor, this.at);
+ return data;
+ }
+
+ if (data === GfmAutoComplete.defaultLoadingData) {
+ return $.fn.atwho.default.callbacks.filter(query, data, searchKey);
+ }
+
+ if (command === MEMBER_COMMAND.ASSIGN) {
+ // Only include members which are not assigned to Issuable currently
+ return data.filter(member => !assignees.includes(member.search));
+ } else if (command === MEMBER_COMMAND.UNASSIGN) {
+ // Only include members which are assigned to Issuable currently
+ return data.filter(member => assignees.includes(member.search));
+ }
+
+ return data;
+ },
},
});
}
diff --git a/app/assets/javascripts/ide/stores/modules/commit/actions.js b/app/assets/javascripts/ide/stores/modules/commit/actions.js
index 73c1bc8b582..0740e0523a9 100644
--- a/app/assets/javascripts/ide/stores/modules/commit/actions.js
+++ b/app/assets/javascripts/ide/stores/modules/commit/actions.js
@@ -44,7 +44,7 @@ export const setLastCommitMessage = ({ commit, rootGetters }, data) => {
const commitMsg = sprintf(
__('Your changes have been committed. Commit %{commitId} %{commitStats}'),
{
- commitId: `<a href="${currentProject.web_url}/commit/${data.short_id}" class="commit-sha">${data.short_id}</a>`,
+ commitId: `<a href="${currentProject.web_url}/-/commit/${data.short_id}" class="commit-sha">${data.short_id}</a>`,
commitStats,
},
false,
@@ -56,7 +56,7 @@ export const setLastCommitMessage = ({ commit, rootGetters }, data) => {
export const updateFilesAfterCommit = ({ commit, dispatch, rootState, rootGetters }, { data }) => {
const selectedProject = rootGetters.currentProject;
const lastCommit = {
- commit_path: `${selectedProject.web_url}/commit/${data.id}`,
+ commit_path: `${selectedProject.web_url}/-/commit/${data.id}`,
commit: {
id: data.id,
message: data.message,
diff --git a/app/assets/javascripts/monitoring/components/charts/time_series.vue b/app/assets/javascripts/monitoring/components/charts/time_series.vue
index e79755f4fb2..e58d9f23201 100644
--- a/app/assets/javascripts/monitoring/components/charts/time_series.vue
+++ b/app/assets/javascripts/monitoring/components/charts/time_series.vue
@@ -209,7 +209,7 @@ export default {
id,
createdAt: created_at,
sha,
- commitUrl: `${this.projectPath}/commit/${sha}`,
+ commitUrl: `${this.projectPath}/-/commit/${sha}`,
tag,
tagUrl: tag ? `${this.tagsPath}/${ref.name}` : null,
ref: ref.name,
diff --git a/app/assets/javascripts/test_utils/index.js b/app/assets/javascripts/test_utils/index.js
index 1a1f3e8d0a8..2727485fb95 100644
--- a/app/assets/javascripts/test_utils/index.js
+++ b/app/assets/javascripts/test_utils/index.js
@@ -1,5 +1,3 @@
-import 'core-js/es/map';
-import 'core-js/es/set';
import { Sortable } from 'sortablejs';
import simulateDrag from './simulate_drag';
import simulateInput from './simulate_input';