diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-11 21:09:19 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-11 21:09:19 +0000 |
commit | fca89bb73ff5b1d14c98c72481f9268fee107ea0 (patch) | |
tree | e1c8a2c4fe5df7f054fd09e49f53bcfb51e51c84 /app/assets/javascripts | |
parent | 76e9fc7b29c1ce716c26932e9fbec0f3c99f53f4 (diff) | |
download | gitlab-ce-fca89bb73ff5b1d14c98c72481f9268fee107ea0.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/boards/index.js | 12 | ||||
-rw-r--r-- | app/assets/javascripts/boards/models/assignee.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/boards/models/issue.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/boards/models/list.js | 5 | ||||
-rw-r--r-- | app/assets/javascripts/boards/stores/boards_store.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/ide/components/new_dropdown/upload.vue | 21 | ||||
-rw-r--r-- | app/assets/javascripts/ide/utils.js | 53 | ||||
-rw-r--r-- | app/assets/javascripts/monitoring/components/panel_type.vue | 16 |
8 files changed, 85 insertions, 42 deletions
diff --git a/app/assets/javascripts/boards/index.js b/app/assets/javascripts/boards/index.js index f72fc8d54b3..781cb0c1cc9 100644 --- a/app/assets/javascripts/boards/index.js +++ b/app/assets/javascripts/boards/index.js @@ -84,7 +84,6 @@ export default () => { rootPath: $boardApp.dataset.rootPath, bulkUpdatePath: $boardApp.dataset.bulkUpdatePath, detailIssue: boardsStore.detail, - defaultAvatar: $boardApp.dataset.defaultAvatar, }, computed: { detailIssueVisible() { @@ -130,13 +129,10 @@ export default () => { position = -1; } - boardsStore.addList( - { - ...listObj, - position, - }, - this.defaultAvatar, - ); + boardsStore.addList({ + ...listObj, + position, + }); }); boardsStore.addBlankState(); diff --git a/app/assets/javascripts/boards/models/assignee.js b/app/assets/javascripts/boards/models/assignee.js index 4a29b0d0581..5f5758583bb 100644 --- a/app/assets/javascripts/boards/models/assignee.js +++ b/app/assets/javascripts/boards/models/assignee.js @@ -1,9 +1,9 @@ export default class ListAssignee { - constructor(obj, defaultAvatar) { + constructor(obj) { this.id = obj.id; this.name = obj.name; this.username = obj.username; - this.avatar = obj.avatar_url || obj.avatar || defaultAvatar; + this.avatar = obj.avatar_url || obj.avatar || gon.default_avatar_url; this.path = obj.path; this.state = obj.state; this.webUrl = obj.web_url || obj.webUrl; diff --git a/app/assets/javascripts/boards/models/issue.js b/app/assets/javascripts/boards/models/issue.js index 4f5d583e61f..d099c4b930c 100644 --- a/app/assets/javascripts/boards/models/issue.js +++ b/app/assets/javascripts/boards/models/issue.js @@ -10,7 +10,7 @@ import IssueProject from './project'; import boardsStore from '../stores/boards_store'; class ListIssue { - constructor(obj, defaultAvatar) { + constructor(obj) { this.subscribed = obj.subscribed; this.labels = []; this.assignees = []; @@ -22,11 +22,11 @@ class ListIssue { this.closed = obj.closed; this.isLoading = {}; - this.refreshData(obj, defaultAvatar); + this.refreshData(obj); } - refreshData(obj, defaultAvatar) { - boardsStore.refreshIssueData(this, obj, defaultAvatar); + refreshData(obj) { + boardsStore.refreshIssueData(this, obj); } addLabel(label) { diff --git a/app/assets/javascripts/boards/models/list.js b/app/assets/javascripts/boards/models/list.js index ff50b8ed7d1..990b648190a 100644 --- a/app/assets/javascripts/boards/models/list.js +++ b/app/assets/javascripts/boards/models/list.js @@ -36,7 +36,7 @@ const TYPES = { }; class List { - constructor(obj, defaultAvatar) { + constructor(obj) { this.id = obj.id; this._uid = this.guid(); this.position = obj.position; @@ -55,7 +55,6 @@ class List { this.maxIssueCount = Object.hasOwnProperty.call(obj, 'max_issue_count') ? obj.max_issue_count : 0; - this.defaultAvatar = defaultAvatar; if (obj.label) { this.label = new ListLabel(obj.label); @@ -156,7 +155,7 @@ class List { createIssues(data) { data.forEach(issueObj => { - this.addIssue(new ListIssue(issueObj, this.defaultAvatar)); + this.addIssue(new ListIssue(issueObj)); }); } diff --git a/app/assets/javascripts/boards/stores/boards_store.js b/app/assets/javascripts/boards/stores/boards_store.js index 2a2cff3d07d..528dc4ed68e 100644 --- a/app/assets/javascripts/boards/stores/boards_store.js +++ b/app/assets/javascripts/boards/stores/boards_store.js @@ -74,8 +74,8 @@ const boardsStore = { showPage(page) { this.state.currentPage = page; }, - addList(listObj, defaultAvatar) { - const list = new List(listObj, defaultAvatar); + addList(listObj) { + const list = new List(listObj); this.state.lists = _.sortBy([...this.state.lists, list], 'position'); return list; @@ -602,7 +602,7 @@ const boardsStore = { clearMultiSelect() { this.multiSelect.list = []; }, - refreshIssueData(issue, obj, defaultAvatar) { + refreshIssueData(issue, obj) { issue.id = obj.id; issue.iid = obj.iid; issue.title = obj.title; @@ -631,7 +631,7 @@ const boardsStore = { } if (obj.assignees) { - issue.assignees = obj.assignees.map(a => new ListAssignee(a, defaultAvatar)); + issue.assignees = obj.assignees.map(a => new ListAssignee(a)); } }, }; diff --git a/app/assets/javascripts/ide/components/new_dropdown/upload.vue b/app/assets/javascripts/ide/components/new_dropdown/upload.vue index 0efb0012246..7261e0590c8 100644 --- a/app/assets/javascripts/ide/components/new_dropdown/upload.vue +++ b/app/assets/javascripts/ide/components/new_dropdown/upload.vue @@ -1,5 +1,6 @@ <script> import ItemButton from './button.vue'; +import { isTextFile } from '~/ide/utils'; export default { components: { @@ -23,29 +24,11 @@ export default { }, }, methods: { - isText(content, fileType) { - const knownBinaryFileTypes = ['image/']; - const knownTextFileTypes = ['text/']; - const isKnownBinaryFileType = knownBinaryFileTypes.find(type => fileType.includes(type)); - const isKnownTextFileType = knownTextFileTypes.find(type => fileType.includes(type)); - const asciiRegex = /^[ -~\t\n\r]+$/; // tests whether a string contains ascii characters only (ranges from space to tilde, tabs and new lines) - - if (isKnownBinaryFileType) { - return false; - } - - if (isKnownTextFileType) { - return true; - } - - // if it's not a known file type, determine the type by evaluating the file contents - return asciiRegex.test(content); - }, createFile(target, file) { const { name } = file; const encodedContent = target.result.split('base64,')[1]; const rawContent = encodedContent ? atob(encodedContent) : ''; - const isText = this.isText(rawContent, file.type); + const isText = isTextFile(rawContent, file.type, name); const emitCreateEvent = content => this.$emit('create', { diff --git a/app/assets/javascripts/ide/utils.js b/app/assets/javascripts/ide/utils.js index ae579fef25f..64ac539a4ff 100644 --- a/app/assets/javascripts/ide/utils.js +++ b/app/assets/javascripts/ide/utils.js @@ -1,4 +1,57 @@ import { commitItemIconMap } from './constants'; +import { languages } from 'monaco-editor'; +import { flatten } from 'lodash'; + +const toLowerCase = x => x.toLowerCase(); + +const monacoLanguages = languages.getLanguages(); +const monacoExtensions = new Set( + flatten(monacoLanguages.map(lang => lang.extensions?.map(toLowerCase) || [])), +); +const monacoMimetypes = new Set( + flatten(monacoLanguages.map(lang => lang.mimetypes?.map(toLowerCase) || [])), +); +const monacoFilenames = new Set( + flatten(monacoLanguages.map(lang => lang.filenames?.map(toLowerCase) || [])), +); + +const KNOWN_TYPES = [ + { + isText: false, + isMatch(mimeType) { + return mimeType.toLowerCase().includes('image/'); + }, + }, + { + isText: true, + isMatch(mimeType) { + return mimeType.toLowerCase().includes('text/'); + }, + }, + { + isText: true, + isMatch(mimeType, fileName) { + const fileExtension = fileName.includes('.') ? `.${fileName.split('.').pop()}` : ''; + + return ( + monacoExtensions.has(fileExtension.toLowerCase()) || + monacoMimetypes.has(mimeType.toLowerCase()) || + monacoFilenames.has(fileName.toLowerCase()) + ); + }, + }, +]; + +export function isTextFile(content, mimeType, fileName) { + const knownType = KNOWN_TYPES.find(type => type.isMatch(mimeType, fileName)); + + if (knownType) return knownType.isText; + + // does the string contain ascii characters only (ranges from space to tilde, tabs and new lines) + const asciiRegex = /^[ -~\t\n\r]+$/; + // for unknown types, determine the type by evaluating the file contents + return asciiRegex.test(content); +} export const getCommitIconMap = file => { if (file.deleted) { diff --git a/app/assets/javascripts/monitoring/components/panel_type.vue b/app/assets/javascripts/monitoring/components/panel_type.vue index f2f0fff694e..4573ec58ab8 100644 --- a/app/assets/javascripts/monitoring/components/panel_type.vue +++ b/app/assets/javascripts/monitoring/components/panel_type.vue @@ -11,7 +11,7 @@ import { GlTooltip, GlTooltipDirective, } from '@gitlab/ui'; -import { __ } from '~/locale'; +import { __, n__ } from '~/locale'; import Icon from '~/vue_shared/components/icon.vue'; import MonitorTimeSeriesChart from './charts/time_series.vue'; import MonitorAnomalyChart from './charts/anomaly.vue'; @@ -120,6 +120,12 @@ export default { !this.isPanelType('stacked-column') ); }, + editCustomMetricLink() { + return this.graphData?.metrics[0].edit_path; + }, + editCustomMetricLinkText() { + return n__('Metrics|Edit metric', 'Metrics|Edit metrics', this.graphData.metrics.length); + }, }, mounted() { this.refreshTitleTooltip(); @@ -195,7 +201,13 @@ export default { <template slot="button-content"> <icon name="ellipsis_v" class="text-secondary" /> </template> - + <gl-dropdown-item + v-if="editCustomMetricLink" + ref="editMetricLink" + :href="editCustomMetricLink" + > + {{ editCustomMetricLinkText }} + </gl-dropdown-item> <gl-dropdown-item v-if="logsPathWithTimeRange" ref="viewLogsLink" |