parent
d8dd75ca77
commit
be45d45404
|
@ -40,13 +40,6 @@ export default {
|
||||||
|
|
||||||
return __('Create file');
|
return __('Create file');
|
||||||
},
|
},
|
||||||
formLabelName() {
|
|
||||||
if (this.type === 'tree') {
|
|
||||||
return __('Directory name');
|
|
||||||
}
|
|
||||||
|
|
||||||
return __('File name');
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$refs.fieldName.focus();
|
this.$refs.fieldName.focus();
|
||||||
|
@ -83,7 +76,7 @@ export default {
|
||||||
>
|
>
|
||||||
<fieldset class="form-group append-bottom-0">
|
<fieldset class="form-group append-bottom-0">
|
||||||
<label class="label-light col-sm-3">
|
<label class="label-light col-sm-3">
|
||||||
{{ formLabelName }}
|
{{ __('Name') }}
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<input
|
<input
|
||||||
|
|
|
@ -112,6 +112,14 @@ export const updateDelayViewerUpdated = ({ commit }, delay) => {
|
||||||
commit(types.UPDATE_DELAY_VIEWER_CHANGE, delay);
|
commit(types.UPDATE_DELAY_VIEWER_CHANGE, delay);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateTempFlagForEntry = ({ commit, dispatch, state }, { entry, tempFile }) => {
|
||||||
|
commit(types.UPDATE_TEMP_FLAG, { path: entry.path, tempFile });
|
||||||
|
|
||||||
|
if (entry.parentPath) {
|
||||||
|
dispatch('updateTempFlagForEntry', { entry: state.entries[entry.parentPath], tempFile });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export * from './actions/tree';
|
export * from './actions/tree';
|
||||||
export * from './actions/file';
|
export * from './actions/file';
|
||||||
export * from './actions/project';
|
export * from './actions/project';
|
||||||
|
|
|
@ -127,6 +127,8 @@ export const updateFilesAfterCommit = (
|
||||||
},
|
},
|
||||||
{ root: true },
|
{ root: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
dispatch('updateTempFlagForEntry', { entry, tempFile: false }, { root: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
commit(rootTypes.REMOVE_ALL_CHANGES_FILES, null, { root: true });
|
commit(rootTypes.REMOVE_ALL_CHANGES_FILES, null, { root: true });
|
||||||
|
|
|
@ -53,3 +53,5 @@ export const UPDATE_DELAY_VIEWER_CHANGE = 'UPDATE_DELAY_VIEWER_CHANGE';
|
||||||
|
|
||||||
export const ADD_PENDING_TAB = 'ADD_PENDING_TAB';
|
export const ADD_PENDING_TAB = 'ADD_PENDING_TAB';
|
||||||
export const REMOVE_PENDING_TAB = 'REMOVE_PENDING_TAB';
|
export const REMOVE_PENDING_TAB = 'REMOVE_PENDING_TAB';
|
||||||
|
|
||||||
|
export const UPDATE_TEMP_FLAG = 'UPDATE_TEMP_FLAG';
|
||||||
|
|
|
@ -4,6 +4,7 @@ import mergeRequestMutation from './mutations/merge_request';
|
||||||
import fileMutations from './mutations/file';
|
import fileMutations from './mutations/file';
|
||||||
import treeMutations from './mutations/tree';
|
import treeMutations from './mutations/tree';
|
||||||
import branchMutations from './mutations/branch';
|
import branchMutations from './mutations/branch';
|
||||||
|
import { sortTree } from './utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
[types.SET_INITIAL_DATA](state, data) {
|
[types.SET_INITIAL_DATA](state, data) {
|
||||||
|
@ -68,7 +69,7 @@ export default {
|
||||||
f => foundEntry.tree.find(e => e.path === f.path) === undefined,
|
f => foundEntry.tree.find(e => e.path === f.path) === undefined,
|
||||||
);
|
);
|
||||||
Object.assign(foundEntry, {
|
Object.assign(foundEntry, {
|
||||||
tree: foundEntry.tree.concat(tree),
|
tree: sortTree(foundEntry.tree.concat(tree)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +82,16 @@ export default {
|
||||||
|
|
||||||
if (!foundEntry) {
|
if (!foundEntry) {
|
||||||
Object.assign(state.trees[`${projectId}/${branchId}`], {
|
Object.assign(state.trees[`${projectId}/${branchId}`], {
|
||||||
tree: state.trees[`${projectId}/${branchId}`].tree.concat(data.treeList),
|
tree: sortTree(state.trees[`${projectId}/${branchId}`].tree.concat(data.treeList)),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
[types.UPDATE_TEMP_FLAG](state, { path, tempFile }) {
|
||||||
|
Object.assign(state.entries[path], {
|
||||||
|
tempFile,
|
||||||
|
changed: tempFile,
|
||||||
|
});
|
||||||
|
},
|
||||||
[types.UPDATE_VIEWER](state, viewer) {
|
[types.UPDATE_VIEWER](state, viewer) {
|
||||||
Object.assign(state, {
|
Object.assign(state, {
|
||||||
viewer,
|
viewer,
|
||||||
|
|
|
@ -32,6 +32,7 @@ export const dataStructure = () => ({
|
||||||
raw: '',
|
raw: '',
|
||||||
content: '',
|
content: '',
|
||||||
parentTreeUrl: '',
|
parentTreeUrl: '',
|
||||||
|
parentPath: '',
|
||||||
renderError: false,
|
renderError: false,
|
||||||
base64: false,
|
base64: false,
|
||||||
editorRow: 1,
|
editorRow: 1,
|
||||||
|
@ -63,6 +64,7 @@ export const decorateData = entity => {
|
||||||
previewMode,
|
previewMode,
|
||||||
file_lock,
|
file_lock,
|
||||||
html,
|
html,
|
||||||
|
parentPath = '',
|
||||||
} = entity;
|
} = entity;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -79,6 +81,7 @@ export const decorateData = entity => {
|
||||||
opened,
|
opened,
|
||||||
active,
|
active,
|
||||||
parentTreeUrl,
|
parentTreeUrl,
|
||||||
|
parentPath,
|
||||||
changed,
|
changed,
|
||||||
renderError,
|
renderError,
|
||||||
content,
|
content,
|
||||||
|
@ -119,8 +122,8 @@ const sortTreesByTypeAndName = (a, b) => {
|
||||||
} else if (a.type === 'blob' && b.type === 'tree') {
|
} else if (a.type === 'blob' && b.type === 'tree') {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (a.name.toLowerCase() < b.name.toLowerCase()) return -1;
|
if (a.name < b.name) return -1;
|
||||||
if (a.name.toLowerCase() > b.name.toLowerCase()) return 1;
|
if (a.name > b.name) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ self.addEventListener('message', e => {
|
||||||
tempFile,
|
tempFile,
|
||||||
changed: tempFile,
|
changed: tempFile,
|
||||||
opened: tempFile,
|
opened: tempFile,
|
||||||
|
parentPath: parentFolder ? parentFolder.path : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.assign(acc, {
|
Object.assign(acc, {
|
||||||
|
@ -66,6 +67,7 @@ self.addEventListener('message', e => {
|
||||||
content,
|
content,
|
||||||
base64,
|
base64,
|
||||||
previewMode: viewerInformationForPath(blobName),
|
previewMode: viewerInformationForPath(blobName),
|
||||||
|
parentPath: fileFolder ? fileFolder.path : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.assign(acc, {
|
Object.assign(acc, {
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
v-if="!loading && folder"
|
v-if="!loading && folder"
|
||||||
:name="folderIconName"
|
:name="folderIconName"
|
||||||
:size="size"
|
:size="size"
|
||||||
|
css-classes="folder-icon"
|
||||||
/>
|
/>
|
||||||
<loading-icon
|
<loading-icon
|
||||||
v-if="loading"
|
v-if="loading"
|
||||||
|
|
|
@ -85,12 +85,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.folder {
|
.folder-icon {
|
||||||
svg {
|
|
||||||
fill: $gl-text-color-secondary;
|
fill: $gl-text-color-secondary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: $gl-text-color;
|
color: $gl-text-color;
|
||||||
|
@ -429,7 +427,7 @@
|
||||||
.projects-sidebar {
|
.projects-sidebar {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
height: 100%;
|
flex: 1;
|
||||||
|
|
||||||
.context-header {
|
.context-header {
|
||||||
width: auto;
|
width: auto;
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import * as urlUtils from '~/lib/utils/url_utility';
|
import * as urlUtils from '~/lib/utils/url_utility';
|
||||||
|
import * as actions from '~/ide/stores/actions';
|
||||||
import store from '~/ide/stores';
|
import store from '~/ide/stores';
|
||||||
import router from '~/ide/ide_router';
|
import router from '~/ide/ide_router';
|
||||||
import { resetStore, file } from '../helpers';
|
import { resetStore, file } from '../helpers';
|
||||||
|
import testAction from '../../helpers/vuex_action_helper';
|
||||||
|
|
||||||
describe('Multi-file store actions', () => {
|
describe('Multi-file store actions', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -191,9 +193,7 @@ describe('Multi-file store actions', () => {
|
||||||
})
|
})
|
||||||
.then(f => {
|
.then(f => {
|
||||||
expect(f.tempFile).toBeTruthy();
|
expect(f.tempFile).toBeTruthy();
|
||||||
expect(store.state.trees['abcproject/mybranch'].tree.length).toBe(
|
expect(store.state.trees['abcproject/mybranch'].tree.length).toBe(1);
|
||||||
1,
|
|
||||||
);
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
|
@ -303,4 +303,47 @@ describe('Multi-file store actions', () => {
|
||||||
.catch(done.fail);
|
.catch(done.fail);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updateTempFlagForEntry', () => {
|
||||||
|
it('commits UPDATE_TEMP_FLAG', done => {
|
||||||
|
const f = {
|
||||||
|
...file(),
|
||||||
|
path: 'test',
|
||||||
|
tempFile: true,
|
||||||
|
};
|
||||||
|
store.state.entries[f.path] = f;
|
||||||
|
|
||||||
|
testAction(
|
||||||
|
actions.updateTempFlagForEntry,
|
||||||
|
{ entry: f, tempFile: false },
|
||||||
|
store.state,
|
||||||
|
[{ type: 'UPDATE_TEMP_FLAG', payload: { path: f.path, tempFile: false } }],
|
||||||
|
[],
|
||||||
|
done,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('commits UPDATE_TEMP_FLAG and dispatches for parent', done => {
|
||||||
|
const parent = {
|
||||||
|
...file(),
|
||||||
|
path: 'testing',
|
||||||
|
};
|
||||||
|
const f = {
|
||||||
|
...file(),
|
||||||
|
path: 'test',
|
||||||
|
parentPath: 'testing',
|
||||||
|
};
|
||||||
|
store.state.entries[parent.path] = parent;
|
||||||
|
store.state.entries[f.path] = f;
|
||||||
|
|
||||||
|
testAction(
|
||||||
|
actions.updateTempFlagForEntry,
|
||||||
|
{ entry: f, tempFile: false },
|
||||||
|
store.state,
|
||||||
|
[{ type: 'UPDATE_TEMP_FLAG', payload: { path: f.path, tempFile: false } }],
|
||||||
|
[{ type: 'updateTempFlagForEntry', payload: { entry: parent, tempFile: false } }],
|
||||||
|
done,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -76,4 +76,26 @@ describe('Multi-file store mutations', () => {
|
||||||
expect(localState.viewer).toBe('diff');
|
expect(localState.viewer).toBe('diff');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('UPDATE_TEMP_FLAG', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
localState.entries.test = {
|
||||||
|
...file(),
|
||||||
|
tempFile: true,
|
||||||
|
changed: true,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
it('updates tempFile flag', () => {
|
||||||
|
mutations.UPDATE_TEMP_FLAG(localState, { path: 'test', tempFile: false });
|
||||||
|
|
||||||
|
expect(localState.entries.test.tempFile).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('updates changed flag', () => {
|
||||||
|
mutations.UPDATE_TEMP_FLAG(localState, { path: 'test', tempFile: false });
|
||||||
|
|
||||||
|
expect(localState.entries.test.changed).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue