This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from seokju-na/geeks-diary-67
Base vcs redux center (state / actions / reducer)
- Loading branch information
Showing
14 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as path from 'path'; | ||
import { Dummy, TextDummy, TypesDummy } from '../../../test/helpers'; | ||
import { VcsFileChange, VcsFileChangeStatusTypes } from '../../core/vcs'; | ||
|
||
|
||
export class VcsFileChangeDummy implements Dummy<VcsFileChange> { | ||
private filePath = new TextDummy('file'); | ||
private status = new TypesDummy<VcsFileChangeStatusTypes>([ | ||
VcsFileChangeStatusTypes.REMOVED, | ||
VcsFileChangeStatusTypes.MODIFIED, | ||
VcsFileChangeStatusTypes.RENAMED, | ||
VcsFileChangeStatusTypes.NEW, | ||
]); | ||
|
||
constructor(public readonly workspaceDir: string = '/test/workspace') { | ||
} | ||
|
||
create(status = this.status.create()): VcsFileChange { | ||
const filePath = this.filePath.create(); | ||
let fileChange = { | ||
filePath, | ||
workingDirectoryPath: this.workspaceDir, | ||
absoluteFilePath: path.resolve(this.workspaceDir, filePath), | ||
status, | ||
} as VcsFileChange; | ||
|
||
if (status === VcsFileChangeStatusTypes.RENAMED) { | ||
fileChange = { | ||
...fileChange, | ||
headToIndexDiff: { | ||
oldFilePath: 'old-file', | ||
newFilePath: filePath, | ||
}, | ||
}; | ||
} | ||
|
||
return fileChange; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export * from './vcs.module'; | ||
export * from './vcs.service'; | ||
export * from './vcs-authentication-database'; | ||
export * from './vcs.state'; | ||
export * from './vcs.actions'; | ||
export * from './vcs.reducer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './vcs-view.module'; | ||
export * from './vcs-manager/vcs-manager.component'; |
2 changes: 2 additions & 0 deletions
2
src/browser/vcs/vcs-view/vcs-manager/vcs-manager.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<div class="VcsManager"> | ||
</div> |
2 changes: 2 additions & 0 deletions
2
src/browser/vcs/vcs-view/vcs-manager/vcs-manager.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.VcsManager { | ||
} |
17 changes: 17 additions & 0 deletions
17
src/browser/vcs/vcs-view/vcs-manager/vcs-manager.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
|
||
|
||
@Component({ | ||
selector: 'gd-vcs-manager', | ||
templateUrl: './vcs-manager.component.html', | ||
styleUrls: ['./vcs-manager.component.scss'], | ||
}) | ||
export class VcsManagerComponent implements OnInit { | ||
|
||
constructor() { | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { UiModule } from '../../ui/ui.module'; | ||
import { VcsManagerComponent } from './vcs-manager/vcs-manager.component'; | ||
|
||
|
||
@NgModule({ | ||
imports: [ | ||
UiModule, | ||
], | ||
declarations: [ | ||
VcsManagerComponent, | ||
], | ||
entryComponents: [ | ||
VcsManagerComponent, | ||
], | ||
exports: [ | ||
VcsManagerComponent, | ||
], | ||
}) | ||
export class VcsViewModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { VcsFileChange } from '../../core/vcs'; | ||
|
||
|
||
export enum VcsActionTypes { | ||
UPDATE_FILE_CHANGES = '[Vcs] Update file changes', | ||
} | ||
|
||
|
||
export class UpdateFileChangesAction implements Action { | ||
readonly type = VcsActionTypes.UPDATE_FILE_CHANGES; | ||
|
||
constructor(public readonly payload: { fileChanges: VcsFileChange[] }) { | ||
} | ||
} | ||
|
||
|
||
export type VcsAction = | ||
UpdateFileChangesAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createDummies } from '../../../test/helpers'; | ||
import { VcsFileChangeDummy } from './dummies'; | ||
import { UpdateFileChangesAction } from './vcs.actions'; | ||
import { vcsReducer } from './vcs.reducer'; | ||
|
||
|
||
describe('browser.vcs.vcsReducer', () => { | ||
const fileChangeDummy = new VcsFileChangeDummy(); | ||
|
||
describe('UPDATE_FILE_CHANGES', () => { | ||
it('should set file changes.', () => { | ||
const fileChanges = createDummies(fileChangeDummy, 10); | ||
const action = new UpdateFileChangesAction({ fileChanges }); | ||
|
||
const result = vcsReducer(undefined, action); | ||
|
||
expect(result.fileChanges).toEqual(fileChanges); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ActionReducerMap } from '@ngrx/store'; | ||
import { VcsAction, VcsActionTypes } from './vcs.actions'; | ||
import { createVcsInitialState, VcsState, VcsStateWithRoot } from './vcs.state'; | ||
|
||
|
||
export function vcsReducer( | ||
state: VcsState = createVcsInitialState(), | ||
action: VcsAction, | ||
): VcsState { | ||
switch (action.type) { | ||
case VcsActionTypes.UPDATE_FILE_CHANGES: | ||
return { | ||
...state, | ||
fileChanges: [...action.payload.fileChanges], | ||
}; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
|
||
export const vcsReducerMap: ActionReducerMap<VcsStateWithRoot> = { | ||
vcs: vcsReducer, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { VcsFileChange } from '../../core/vcs'; | ||
|
||
|
||
export function createVcsInitialState(): VcsState { | ||
return { | ||
fileChanges: [], | ||
}; | ||
} | ||
|
||
|
||
export interface VcsState { | ||
readonly fileChanges: VcsFileChange[]; | ||
} | ||
|
||
|
||
export interface VcsStateWithRoot { | ||
vcs: VcsState; | ||
} |