Commit 2e8d297b authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/diffsMonacoJS' into 'master'

Fixes Monaco library loading on merge requests

See merge request gitlab-org/gitlab!32540
parents 9110bbda 4f55280a
import { commitItemIconMap } from './constants';
export default file => {
if (file.deleted) {
return commitItemIconMap.deleted;
} else if (file.tempFile && !file.prevPath) {
return commitItemIconMap.addition;
}
return commitItemIconMap.modified;
};
...@@ -4,7 +4,7 @@ import tooltip from '~/vue_shared/directives/tooltip'; ...@@ -4,7 +4,7 @@ import tooltip from '~/vue_shared/directives/tooltip';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import FileIcon from '~/vue_shared/components/file_icon.vue'; import FileIcon from '~/vue_shared/components/file_icon.vue';
import { viewerTypes } from '../../constants'; import { viewerTypes } from '../../constants';
import { getCommitIconMap } from '../../utils'; import getCommitIconMap from '../../commit_icon';
export default { export default {
components: { components: {
......
import { commitItemIconMap } from './constants';
import { languages } from 'monaco-editor'; import { languages } from 'monaco-editor';
import { flatten } from 'lodash'; import { flatten } from 'lodash';
...@@ -53,16 +52,6 @@ export function isTextFile(content, mimeType, fileName) { ...@@ -53,16 +52,6 @@ export function isTextFile(content, mimeType, fileName) {
return asciiRegex.test(content); return asciiRegex.test(content);
} }
export const getCommitIconMap = file => {
if (file.deleted) {
return commitItemIconMap.deleted;
} else if (file.tempFile && !file.prevPath) {
return commitItemIconMap.addition;
}
return commitItemIconMap.modified;
};
export const createPathWithExt = p => { export const createPathWithExt = p => {
const ext = p.lastIndexOf('.') >= 0 ? p.substring(p.lastIndexOf('.') + 1) : ''; const ext = p.lastIndexOf('.') >= 0 ? p.substring(p.lastIndexOf('.') + 1) : '';
......
<script> <script>
import { GlTooltipDirective } from '@gitlab/ui'; import { GlTooltipDirective } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { getCommitIconMap } from '~/ide/utils'; import getCommitIconMap from '~/ide/commit_icon';
import { __ } from '~/locale'; import { __ } from '~/locale';
export default { export default {
......
import { commitItemIconMap } from '~/ide/constants';
import { decorateData } from '~/ide/stores/utils';
import getCommitIconMap from '~/ide/commit_icon';
const createFile = (name = 'name', id = name, type = '', parent = null) =>
decorateData({
id,
type,
icon: 'icon',
url: 'url',
name,
path: parent ? `${parent.path}/${name}` : name,
parentPath: parent ? parent.path : '',
lastCommit: {},
});
describe('getCommitIconMap', () => {
let entry;
beforeEach(() => {
entry = createFile('Entry item');
});
it('renders "deleted" icon for deleted entries', () => {
entry.deleted = true;
expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.deleted);
});
it('renders "addition" icon for temp entries', () => {
entry.tempFile = true;
expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.addition);
});
it('renders "modified" icon for newly-renamed entries', () => {
entry.prevPath = 'foo/bar';
entry.tempFile = false;
expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.modified);
});
it('renders "modified" icon even for temp entries if they are newly-renamed', () => {
entry.prevPath = 'foo/bar';
entry.tempFile = true;
expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.modified);
});
});
import { commitItemIconMap } from '~/ide/constants'; import { isTextFile, registerLanguages, trimPathComponents } from '~/ide/utils';
import { getCommitIconMap, isTextFile, registerLanguages, trimPathComponents } from '~/ide/utils';
import { decorateData } from '~/ide/stores/utils';
import { languages } from 'monaco-editor'; import { languages } from 'monaco-editor';
describe('WebIDE utils', () => { describe('WebIDE utils', () => {
...@@ -62,48 +60,6 @@ describe('WebIDE utils', () => { ...@@ -62,48 +60,6 @@ describe('WebIDE utils', () => {
}); });
}); });
const createFile = (name = 'name', id = name, type = '', parent = null) =>
decorateData({
id,
type,
icon: 'icon',
url: 'url',
name,
path: parent ? `${parent.path}/${name}` : name,
parentPath: parent ? parent.path : '',
lastCommit: {},
});
describe('getCommitIconMap', () => {
let entry;
beforeEach(() => {
entry = createFile('Entry item');
});
it('renders "deleted" icon for deleted entries', () => {
entry.deleted = true;
expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.deleted);
});
it('renders "addition" icon for temp entries', () => {
entry.tempFile = true;
expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.addition);
});
it('renders "modified" icon for newly-renamed entries', () => {
entry.prevPath = 'foo/bar';
entry.tempFile = false;
expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.modified);
});
it('renders "modified" icon even for temp entries if they are newly-renamed', () => {
entry.prevPath = 'foo/bar';
entry.tempFile = true;
expect(getCommitIconMap(entry)).toEqual(commitItemIconMap.modified);
});
});
describe('trimPathComponents', () => { describe('trimPathComponents', () => {
it.each` it.each`
input | output input | output
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment