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