Skip to content

Commit

Permalink
add Read-Only option for compare
Browse files Browse the repository at this point in the history
Signed-off-by: Billie Simmons <[email protected]>
  • Loading branch information
JillieBeanSim committed Oct 18, 2023
1 parent f627742 commit 89376d3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/zowe-explorer/i18n/sample/package.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,6 @@
"pasteFile": "Paste",
"selectForCompare": "Select for Compare",
"compareWithSelected": "Compare with Selected",
"compareWithSelectedReadOnly": "Compare with Selected (Read-Only)",
"compareFileStarted": "A file has been chosen for compare"
}
14 changes: 14 additions & 0 deletions packages/zowe-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,11 @@
"title": "%compareWithSelected%",
"category": "Zowe Explorer"
},
{
"command": "zowe.compareWithSelectedReadOnly",
"title": "%compareWithSelectedReadOnly%",
"category": "Zowe Explorer"
},
{
"command": "zowe.compareFileStarted",
"title": "%compareFileStarted%",
Expand Down Expand Up @@ -1382,6 +1387,11 @@
"when": "viewItem =~ /^(textFile|member.*|ds.*)/ && !listMultiSelection && zowe.compareFileStarted",
"command": "zowe.compareWithSelected",
"group": "010_zowe_fileOperations@2"
},
{
"when": "viewItem =~ /^(textFile|member.*|ds.*)/ && !listMultiSelection && zowe.compareFileStarted",
"command": "zowe.compareWithSelectedReadOnly",
"group": "010_zowe_fileOperations@3"
}
],
"commandPalette": [
Expand Down Expand Up @@ -1736,6 +1746,10 @@
{
"command": "zowe.compareWithSelected",
"when": "never"
},
{
"command": "zowe.compareWithSelectedReadOnly",
"when": "never"
}
]
},
Expand Down
1 change: 1 addition & 0 deletions packages/zowe-explorer/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,6 @@
"pasteFile": "Paste",
"selectForCompare": "Select for Compare",
"compareWithSelected": "Compare with Selected",
"compareWithSelectedReadOnly": "Compare with Selected (Read-Only)",
"compareFileStarted": "A file has been chosen for compare"
}
8 changes: 8 additions & 0 deletions packages/zowe-explorer/src/shared/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ export function registerCommonCommands(context: vscode.ExtensionContext, provide
globals.resetCompareChoices();
})
);
context.subscriptions.push(
vscode.commands.registerCommand("zowe.compareWithSelectedReadOnly", async (node: IZoweTreeNode) => {
globals.filesToCompare.push(node);
ZoweLogger.trace(`${String(globals.filesToCompare[0].label)} will be compared with selected.`);
await LocalFileManagement.compareChosenFileContent(true);
globals.resetCompareChoices();
})
);
context.subscriptions.push(
vscode.commands.registerCommand("zowe.compareFileStarted", () => {
ZoweLogger.trace(`Checking if any files have been chosen for compare: ${String(globals.FILE_SELECTED_TO_COMPARE)}`);
Expand Down
9 changes: 8 additions & 1 deletion packages/zowe-explorer/src/utils/LocalFileManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class LocalFileManagement {
* Function that triggers compare of the 2 files selected for compare in the active editor
* @returns {Promise<void>}
*/
public static async compareChosenFileContent(): Promise<void> {
public static async compareChosenFileContent(readOnly = false): Promise<void> {
const docUriArray: vscode.Uri[] = [];
for (const node of globals.filesToCompare) {
const fileInfo = await this.getCompareFilePaths(node);
Expand All @@ -95,6 +95,9 @@ export class LocalFileManagement {
globals.resetCompareChoices();
if (docUriArray.length === 2) {
vscode.commands.executeCommand("vscode.diff", docUriArray[0], docUriArray[1]);
if (readOnly) {
this.readOnlyFile();
}
}
}

Expand All @@ -116,4 +119,8 @@ export class LocalFileManagement {
}
return fileInfo;
}

private static readOnlyFile(): void {
vscode.commands.executeCommand("workbench.action.files.setActiveEditorReadonlyInSession");
}
}

0 comments on commit 89376d3

Please sign in to comment.