Skip to content

Commit

Permalink
#319 Added a new Extension Setting "Enhanced Accessibility", that ena…
Browse files Browse the repository at this point in the history
…bles visual file change A|M|D|R|U indicators in the Commit Details View for users with colour blindness.
  • Loading branch information
mhutchie committed Jun 4, 2020
1 parent ce06096 commit 2821eaf
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 2 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,11 @@
"default": true,
"description": "Default state of the \"Include Untracked\" checkbox."
},
"git-graph.enhancedAccessibility": {
"type": "boolean",
"default": false,
"description": "Visual file change A|M|D|R|U indicators in the Commit Details View for users with colour blindness. In the future, this setting will enable any additional accessibility related features of Git Graph that aren't enabled by default."
},
"git-graph.fetchAndPrune": {
"type": "boolean",
"default": false,
Expand Down
7 changes: 7 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ class Config {
};
}

/**
* Get the value of the `git-graph.enhancedAccessibility` Extension Setting.
*/
get enhancedAccessibility() {
return !!this.config.get('enhancedAccessibility', false);
}

/**
* Get the value of the `git-graph.fetchAndPrune` Extension Setting.
*/
Expand Down
1 change: 1 addition & 0 deletions src/gitGraphView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ export class GitGraphView implements vscode.Disposable {
defaultColumnVisibility: config.defaultColumnVisibility,
defaultFileViewType: config.defaultFileViewType,
dialogDefaults: config.dialogDefaults,
enhancedAccessibility: config.enhancedAccessibility,
fetchAndPrune: config.fetchAndPrune,
fetchAvatars: config.fetchAvatars && this.extensionState.isAvatarStorageAvailable(),
graphColours: config.graphColours,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ export interface GitGraphViewConfig {
readonly defaultColumnVisibility: DefaultColumnVisibility;
readonly defaultFileViewType: FileViewType;
readonly dialogDefaults: DialogDefaults;
readonly enhancedAccessibility: boolean;
readonly fetchAndPrune: boolean;
readonly fetchAvatars: boolean;
readonly graphColours: string[];
Expand Down
62 changes: 62 additions & 0 deletions tests/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,68 @@ describe('Config', () => {
});
});

describe('enhancedAccessibility', () => {
it('Should return TRUE when the configuration value is TRUE', () => {
// Setup
workspaceConfiguration.get.mockReturnValueOnce(true);

// Run
const value = config.enhancedAccessibility;

// Assert
expect(workspaceConfiguration.get).toBeCalledWith('enhancedAccessibility', false);
expect(value).toBe(true);
});

it('Should return FALSE when the configuration value is FALSE', () => {
// Setup
workspaceConfiguration.get.mockReturnValueOnce(false);

// Run
const value = config.enhancedAccessibility;

// Assert
expect(workspaceConfiguration.get).toBeCalledWith('enhancedAccessibility', false);
expect(value).toBe(false);
});

it('Should return TRUE when the configuration value is truthy', () => {
// Setup
workspaceConfiguration.get.mockReturnValueOnce(5);

// Run
const value = config.enhancedAccessibility;

// Assert
expect(workspaceConfiguration.get).toBeCalledWith('enhancedAccessibility', false);
expect(value).toBe(true);
});

it('Should return FALSE when the configuration value is falsy', () => {
// Setup
workspaceConfiguration.get.mockReturnValueOnce(0);

// Run
const value = config.enhancedAccessibility;

// Assert
expect(workspaceConfiguration.get).toBeCalledWith('enhancedAccessibility', false);
expect(value).toBe(false);
});

it('Should return the default value (FALSE) when the configuration value is not set', () => {
// Setup
workspaceConfiguration.get.mockImplementationOnce((_, defaultValue) => defaultValue);

// Run
const value = config.enhancedAccessibility;

// Assert
expect(workspaceConfiguration.get).toBeCalledWith('enhancedAccessibility', false);
expect(value).toBe(false);
});
});

describe('fetchAndPrune', () => {
it('Should return TRUE when the configuration value is TRUE', () => {
// Setup
Expand Down
4 changes: 3 additions & 1 deletion web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2951,7 +2951,9 @@ function generateFileTreeLeafHtml(name: string, leaf: FileTreeLeaf, gitFiles: Re
const textFile = fileTreeFile.additions !== null && fileTreeFile.deletions !== null;
const diffPossible = fileTreeFile.type === GG.GitFileStatus.Untracked || textFile;
const encodedOldFilePath = encodeURIComponent(fileTreeFile.oldFilePath), encodedNewFilePath = encodeURIComponent(fileTreeFile.newFilePath);
return '<li data-pathseg="' + encodedName + '"><span class="fileTreeFileRecord"><span class="fileTreeFile' + (diffPossible ? ' gitDiffPossible' : '') + (leaf.reviewed ? '' : ' pendingReview') + '" data-oldfilepath="' + encodedOldFilePath + '" data-newfilepath="' + encodedNewFilePath + '" data-type="' + fileTreeFile.type + '" title="' + (diffPossible ? 'Click to View Diff' : 'Unable to View Diff' + (fileTreeFile.type !== GG.GitFileStatus.Deleted ? ' (this is a binary file)' : '')) + ' • ' + GIT_FILE_CHANGE_TYPES[fileTreeFile.type] + (fileTreeFile.type === GG.GitFileStatus.Renamed ? ' (' + escapeHtml(fileTreeFile.oldFilePath) + ' → ' + escapeHtml(fileTreeFile.newFilePath) + ')' : '') + '"><span class="fileTreeFileIcon">' + SVG_ICONS.file + '</span><span class="gitFileName ' + fileTreeFile.type + '">' + escapedName + '</span></span>' +
const changeTypeMessage = GIT_FILE_CHANGE_TYPES[fileTreeFile.type] + (fileTreeFile.type === GG.GitFileStatus.Renamed ? ' (' + escapeHtml(fileTreeFile.oldFilePath) + ' → ' + escapeHtml(fileTreeFile.newFilePath) + ')' : '');
return '<li data-pathseg="' + encodedName + '"><span class="fileTreeFileRecord"><span class="fileTreeFile' + (diffPossible ? ' gitDiffPossible' : '') + (leaf.reviewed ? '' : ' pendingReview') + '" data-oldfilepath="' + encodedOldFilePath + '" data-newfilepath="' + encodedNewFilePath + '" data-type="' + fileTreeFile.type + '" title="' + (diffPossible ? 'Click to View Diff' : 'Unable to View Diff' + (fileTreeFile.type !== GG.GitFileStatus.Deleted ? ' (this is a binary file)' : '')) + ' • ' + changeTypeMessage + '"><span class="fileTreeFileIcon">' + SVG_ICONS.file + '</span><span class="gitFileName ' + fileTreeFile.type + '">' + escapedName + '</span></span>' +
(initialState.config.enhancedAccessibility ? '<span class="fileTreeFileType" title="' + changeTypeMessage + '">' + fileTreeFile.type + '</span>' : '') +
(fileTreeFile.type !== GG.GitFileStatus.Added && fileTreeFile.type !== GG.GitFileStatus.Untracked && fileTreeFile.type !== GG.GitFileStatus.Deleted && textFile ? '<span class="fileTreeFileAddDel">(<span class="fileTreeFileAdd" title="' + fileTreeFile.additions + ' addition' + (fileTreeFile.additions !== 1 ? 's' : '') + '">+' + fileTreeFile.additions + '</span>|<span class="fileTreeFileDel" title="' + fileTreeFile.deletions + ' deletion' + (fileTreeFile.deletions !== 1 ? 's' : '') + '">-' + fileTreeFile.deletions + '</span>)</span>' : '') +
(fileTreeFile.newFilePath === lastViewedFile ? '<span id="cdvLastFileViewed" title="Last File Viewed">' + SVG_ICONS.eyeOpen + '</span>' : '') +
'<span class="copyGitFile fileTreeFileAction" title="Copy File Path to the Clipboard" data-filepath="' + encodedNewFilePath + '">' + SVG_ICONS.copy + '</span>' +
Expand Down
5 changes: 4 additions & 1 deletion web/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,12 @@ svg.openFolderIcon, svg.closedFolderIcon, svg.fileIcon{
.fileTreeFile.gitDiffPossible{
cursor:pointer;
}
.fileTreeFileAddDel{
.fileTreeFileAddDel, .fileTreeFileType{
margin-left:8px;
}
.fileTreeFileType{
cursor:help;
}
.fileTreeFileAdd, .fileTreeFileDel{
padding:0 3px;
cursor:help;
Expand Down

0 comments on commit 2821eaf

Please sign in to comment.