Commit dba40985 authored by Phil Hughes's avatar Phil Hughes

added support for staged files

parent 509c0cbf
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
return `${this.changedIcon}-solid`; return `${this.changedIcon}-solid`;
}, },
changedIconClass() { changedIconClass() {
return `multi-${this.changedIcon} prepend-left-5 pull-left`; return `multi-${this.changedIcon} pull-left`;
}, },
tooltipTitle() { tooltipTitle() {
if (!this.showTooltip) return undefined; if (!this.showTooltip) return undefined;
...@@ -72,13 +72,7 @@ export default { ...@@ -72,13 +72,7 @@ export default {
class="ide-file-changed-icon" class="ide-file-changed-icon"
> >
<icon <icon
v-if="file.staged && showStagedIcon" v-if="file.changed || file.tempFile || file.staged"
:name="stagedIcon"
:size="12"
:css-classes="changedIconClass"
/>
<icon
v-if="file.changed || file.tempFile || (file.staged && !showStagedIcon)"
:name="changedIcon" :name="changedIcon"
:size="12" :size="12"
:css-classes="changedIconClass" :css-classes="changedIconClass"
......
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
return this.file.tempFile ? `file-addition${prefix}` : `file-modified${prefix}`; return this.file.tempFile ? `file-addition${prefix}` : `file-modified${prefix}`;
}, },
iconClass() { iconClass() {
return `multi-file-${this.file.tempFile ? 'additions' : 'modified'} append-right-8`; return `multi-file-${this.file.tempFile ? 'addition' : 'modified'} append-right-8`;
}, },
}, },
methods: { methods: {
......
...@@ -42,7 +42,17 @@ export const collapseButtonTooltip = state => ...@@ -42,7 +42,17 @@ export const collapseButtonTooltip = state =>
export const hasMergeRequest = state => !!state.currentMergeRequestId; export const hasMergeRequest = state => !!state.currentMergeRequestId;
export const getChangesInFolder = state => path => export const getChangesInFolder = state => path => {
state.changedFiles.filter(f => f.path.replace(new RegExp(`/${f.name}$`), '') === path).length; const changedFilesCount = state.changedFiles.filter(
f => f.path.replace(new RegExp(`/${f.name}$`), '') === path,
).length;
const stagedFilesCount = state.stagedFiles.filter(
f =>
f.path.replace(new RegExp(`/${f.name}$`), '') === path &&
!state.changedFiles.find(changedF => changedF.path === f.path),
).length;
return changedFilesCount + stagedFilesCount;
};
export const getStagedFile = state => path => state.stagedFiles.find(f => f.path === path); export const getStagedFile = state => path => state.stagedFiles.find(f => f.path === path);
...@@ -589,8 +589,8 @@ ...@@ -589,8 +589,8 @@
} }
} }
.multi-file-additions, .multi-file-addition,
.multi-file-additions-solid { .multi-file-addition-solid {
color: $green-500; color: $green-500;
} }
......
...@@ -81,6 +81,36 @@ describe('IDE store getters', () => { ...@@ -81,6 +81,36 @@ describe('IDE store getters', () => {
expect(getters.getChangesInFolder(localState)('test')).toBe(1); expect(getters.getChangesInFolder(localState)('test')).toBe(1);
}); });
it('returns length of changed & staged files for a path', () => {
localState.changedFiles.push(
{
path: 'test/index',
name: 'index',
},
{
path: 'testing/123',
name: '123',
},
);
localState.stagedFiles.push(
{
path: 'test/123',
name: '123',
},
{
path: 'test/index',
name: 'index',
},
{
path: 'testing/12345',
name: '12345',
},
);
expect(getters.getChangesInFolder(localState)('test')).toBe(2);
});
it('returns length of changed & tempFiles files for a path', () => { it('returns length of changed & tempFiles files for a path', () => {
localState.changedFiles.push( localState.changedFiles.push(
{ {
......
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