Commit 35421dd0 authored by Himanshu Kapoor's avatar Himanshu Kapoor Committed by Ezekiel Kigbo

Remove 3 dead properties on files

- permalink
- commitsPath
- blamePath
parent bb396938
......@@ -49,7 +49,6 @@ export const decorateFiles = ({
path,
url: `/${projectId}/tree/${branchId}/-/${path}/`,
type: 'tree',
parentTreeUrl: parentFolder ? parentFolder.url : `/${projectId}/tree/${branchId}/`,
tempFile,
changed: tempFile,
opened: tempFile,
......@@ -86,7 +85,6 @@ export const decorateFiles = ({
path,
url: `/${projectId}/blob/${branchId}/-/${path}`,
type: 'blob',
parentTreeUrl: fileFolder ? fileFolder.url : `/${projectId}/blob/${branchId}`,
tempFile,
changed: tempFile,
content,
......
......@@ -27,7 +27,6 @@ export const TOGGLE_BRANCH_OPEN = 'TOGGLE_BRANCH_OPEN';
export const SET_DIRECTORY_DATA = 'SET_DIRECTORY_DATA';
export const TOGGLE_TREE_OPEN = 'TOGGLE_TREE_OPEN';
export const SET_TREE_OPEN = 'SET_TREE_OPEN';
export const SET_LAST_COMMIT_URL = 'SET_LAST_COMMIT_URL';
export const CREATE_TREE = 'CREATE_TREE';
export const REMOVE_ALL_CHANGES_FILES = 'REMOVE_ALL_CHANGES_FILES';
......
......@@ -65,14 +65,10 @@ export default {
// NOTE: We can't clone `entry` in any of the below assignments because
// we need `state.entries` and the `entry.tree` to reference the same object.
if (!foundEntry) {
if (!foundEntry || foundEntry.deleted) {
Object.assign(state.entries, {
[key]: entry,
});
} else if (foundEntry.deleted) {
Object.assign(state.entries, {
[key]: Object.assign(entry, { replaces: true }),
});
} else {
const tree = entry.tree.filter(
f => foundEntry.tree.find(e => e.path === f.path) === undefined,
......@@ -147,7 +143,6 @@ export default {
raw: file.content,
changed: Boolean(changedFile),
staged: false,
replaces: false,
lastCommitSha: lastCommit.commit.id,
prevId: undefined,
......@@ -164,9 +159,6 @@ export default {
Object.assign(state.entries[file.path], {
rawPath: file.rawPath.replace(regex, file.path),
permalink: file.permalink.replace(regex, file.path),
commitsPath: file.commitsPath.replace(regex, file.path),
blamePath: file.blamePath.replace(regex, file.path),
});
}
},
......
......@@ -34,11 +34,6 @@ export default {
Object.assign(selectedTree, { tree });
},
[types.SET_LAST_COMMIT_URL](state, { tree = state, url }) {
Object.assign(tree, {
lastCommitPath: url,
});
},
[types.REMOVE_ALL_CHANGES_FILES](state) {
Object.assign(state, {
changedFiles: [],
......
......@@ -9,10 +9,8 @@ export default () => ({
stagedFiles: [],
endpoints: {},
lastCommitMsg: '',
lastCommitPath: '',
loading: false,
openFiles: [],
parentTreeUrl: '',
trees: {},
projects: {},
panelResizing: false,
......
......@@ -19,8 +19,6 @@ export const dataStructure = () => ({
active: false,
changed: false,
staged: false,
replaces: false,
lastCommitPath: '',
lastCommitSha: '',
lastCommit: {
id: '',
......@@ -29,16 +27,10 @@ export const dataStructure = () => ({
updatedAt: '',
author: '',
},
blamePath: '',
commitsPath: '',
permalink: '',
rawPath: '',
binary: false,
html: '',
raw: '',
content: '',
parentTreeUrl: '',
renderError: false,
base64: false,
editorRow: 1,
editorColumn: 1,
......@@ -63,19 +55,16 @@ export const decorateData = entity => {
url,
name,
path,
renderError,
content = '',
tempFile = false,
active = false,
opened = false,
changed = false,
parentTreeUrl = '',
base64 = false,
binary = false,
rawPath = '',
previewMode,
file_lock,
html,
parentPath = '',
} = entity;
......@@ -91,25 +80,17 @@ export const decorateData = entity => {
tempFile,
opened,
active,
parentTreeUrl,
changed,
renderError,
content,
base64,
binary,
rawPath,
previewMode,
file_lock,
html,
parentPath,
});
};
export const findEntry = (tree, type, name, prop = 'name') =>
tree.find(f => f.type === type && f[prop] === name);
export const findIndexOfFile = (state, file) => state.findIndex(f => f.path === file.path);
export const setPageTitle = title => {
document.title = title;
};
......@@ -124,7 +105,7 @@ export const commitActionForFile = file => {
return commitActionTypes.move;
} else if (file.deleted) {
return commitActionTypes.delete;
} else if (file.tempFile && !file.replaces) {
} else if (file.tempFile) {
return commitActionTypes.create;
}
......@@ -156,8 +137,7 @@ export const createCommitPayload = ({
previous_path: f.prevPath || undefined,
content: f.prevPath && !f.changed ? null : f.content || undefined,
encoding: f.base64 ? 'base64' : 'text',
last_commit_id:
newBranch || f.deleted || f.prevPath || f.replaces ? undefined : f.lastCommitSha,
last_commit_id: newBranch || f.deleted || f.prevPath ? undefined : f.lastCommitSha,
})),
start_sha: newBranch ? rootGetters.lastCommit.id : undefined,
});
......
......@@ -11,7 +11,6 @@ const createEntries = paths => {
const createUrl = base => (type === 'tree' ? `${base}/` : base);
const { name, parent } = splitParent(path);
const parentEntry = acc[parent];
const previewMode = viewerInformationForPath(name);
acc[path] = {
......@@ -26,9 +25,6 @@ const createEntries = paths => {
previewMode,
binary: (previewMode && previewMode.binary) || false,
parentPath: parent,
parentTreeUrl: parentEntry
? parentEntry.url
: createUrl(`/${TEST_PROJECT_ID}/${type}/${TEST_BRANCH_ID}`),
}),
tree: children.map(childName => expect.objectContaining({ name: childName })),
};
......
......@@ -44,7 +44,6 @@ describe('IDE store file actions', () => {
localFile = file('testFile');
localFile.active = true;
localFile.opened = true;
localFile.parentTreeUrl = 'parentTreeUrl';
store.state.openFiles.push(localFile);
store.state.entries[localFile.path] = localFile;
......@@ -254,13 +253,8 @@ describe('IDE store file actions', () => {
mock.onGet(`${RELATIVE_URL_ROOT}/test/test/-/7297abc/${localFile.path}`).replyOnce(
200,
{
blame_path: 'blame_path',
commits_path: 'commits_path',
permalink: 'permalink',
raw_path: 'raw_path',
binary: false,
html: '123',
render_error: '',
},
{
'page-title': 'testing getFileData',
......@@ -281,17 +275,6 @@ describe('IDE store file actions', () => {
.catch(done.fail);
});
it('sets the file data', done => {
store
.dispatch('getFileData', { path: localFile.path })
.then(() => {
expect(localFile.blamePath).toBe('blame_path');
done();
})
.catch(done.fail);
});
it('sets document title with the branchId', done => {
store
.dispatch('getFileData', { path: localFile.path })
......@@ -348,13 +331,8 @@ describe('IDE store file actions', () => {
mock.onGet(`${RELATIVE_URL_ROOT}/test/test/-/7297abc/old-dull-file`).replyOnce(
200,
{
blame_path: 'blame_path',
commits_path: 'commits_path',
permalink: 'permalink',
raw_path: 'raw_path',
binary: false,
html: '123',
render_error: '',
},
{
'page-title': 'testing old-dull-file',
......
......@@ -60,22 +60,14 @@ describe('IDE store file mutations', () => {
it('sets extra file data', () => {
mutations.SET_FILE_DATA(localState, {
data: {
blame_path: 'blame',
commits_path: 'commits',
permalink: 'permalink',
raw_path: 'raw',
binary: true,
render_error: 'render_error',
},
file: localFile,
});
expect(localFile.blamePath).toBe('blame');
expect(localFile.commitsPath).toBe('commits');
expect(localFile.permalink).toBe('permalink');
expect(localFile.rawPath).toBe('raw');
expect(localFile.binary).toBeTruthy();
expect(localFile.renderError).toBe('render_error');
expect(localFile.raw).toBeNull();
expect(localFile.baseRaw).toBeNull();
});
......
......@@ -120,24 +120,6 @@ describe('Multi-file store mutations', () => {
expect(localState.trees['gitlab-ce/master'].tree.length).toEqual(1);
expect(localState.entries.test.tempFile).toEqual(true);
});
it('marks entry as replacing previous entry if the old one has been deleted', () => {
const tmpFile = file('test');
localState.entries.test = { ...tmpFile, deleted: true };
mutations.CREATE_TMP_ENTRY(localState, {
data: {
entries: {
test: { ...tmpFile, tempFile: true, changed: true },
},
treeList: [tmpFile],
},
projectId: 'gitlab-ce',
branchId: 'master',
});
expect(localState.trees['gitlab-ce/master'].tree.length).toEqual(1);
expect(localState.entries.test.replaces).toEqual(true);
});
});
describe('UPDATE_TEMP_FLAG', () => {
......@@ -273,10 +255,6 @@ describe('Multi-file store mutations', () => {
...file('test'),
prevPath: 'testing-123',
rawPath: `${TEST_HOST}/testing-123`,
permalink: `${TEST_HOST}/testing-123`,
commitsPath: `${TEST_HOST}/testing-123`,
blamePath: `${TEST_HOST}/testing-123`,
replaces: true,
};
localState.entries.test = f;
localState.changedFiles.push(f);
......@@ -291,10 +269,6 @@ describe('Multi-file store mutations', () => {
expect(f).toEqual(
expect.objectContaining({
rawPath: `${TEST_HOST}/test`,
permalink: `${TEST_HOST}/test`,
commitsPath: `${TEST_HOST}/test`,
blamePath: `${TEST_HOST}/test`,
replaces: false,
prevId: undefined,
prevPath: undefined,
prevName: undefined,
......
......@@ -28,61 +28,6 @@ describe('Multi-file store utils', () => {
});
});
describe('findIndexOfFile', () => {
let localState;
beforeEach(() => {
localState = [
{
path: '1',
},
{
path: '2',
},
];
});
it('finds in the index of an entry by path', () => {
const index = utils.findIndexOfFile(localState, {
path: '2',
});
expect(index).toBe(1);
});
});
describe('findEntry', () => {
let localState;
beforeEach(() => {
localState = {
tree: [
{
type: 'tree',
name: 'test',
},
{
type: 'blob',
name: 'file',
},
],
};
});
it('returns an entry found by name', () => {
const foundEntry = utils.findEntry(localState.tree, 'tree', 'test');
expect(foundEntry.type).toBe('tree');
expect(foundEntry.name).toBe('test');
});
it('returns undefined when no entry found', () => {
const foundEntry = utils.findEntry(localState.tree, 'blob', 'test');
expect(foundEntry).toBeUndefined();
});
});
describe('createCommitPayload', () => {
it('returns API payload', () => {
const state = {
......@@ -106,7 +51,6 @@ describe('Multi-file store utils', () => {
},
{ ...file('deletedFile'), path: 'deletedFile', deleted: true },
{ ...file('renamedFile'), path: 'renamedFile', prevPath: 'prevPath' },
{ ...file('replacingFile'), path: 'replacingFile', replaces: true },
],
currentBranchId: 'master',
};
......@@ -154,14 +98,6 @@ describe('Multi-file store utils', () => {
last_commit_id: undefined,
previous_path: 'prevPath',
},
{
action: commitActionTypes.update,
file_path: 'replacingFile',
content: undefined,
encoding: 'text',
last_commit_id: undefined,
previous_path: undefined,
},
],
start_sha: undefined,
});
......
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