Skip to content

Commit

Permalink
Refactored object browser delete action
Browse files Browse the repository at this point in the history
Signed-off-by: Seb Julliand <sebjulliand@gmail.com>
  • Loading branch information
sebjulliand committed Feb 23, 2024
1 parent 92aaab6 commit 561c277
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 42 deletions.
16 changes: 1 addition & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1224,13 +1224,6 @@
"category": "IBM i",
"icon": "$(files)"
},
{
"command": "code-for-ibmi.deleteMember",
"enablement": "code-for-ibmi:connected",
"title": "Delete...",
"category": "IBM i",
"icon": "$(symbol-file)"
},
{
"command": "code-for-ibmi.updateMemberText",
"enablement": "code-for-ibmi:connected",
Expand Down Expand Up @@ -1523,13 +1516,6 @@
"category": "IBM i",
"icon": "$(symbol-file)"
},
{
"command": "code-for-ibmi.deleteObject",
"enablement": "code-for-ibmi:connected",
"title": "Delete...",
"category": "IBM i",
"icon": "$(symbol-file)"
},
{
"command": "code-for-ibmi.renameObject",
"enablement": "code-for-ibmi:connected",
Expand Down Expand Up @@ -2527,7 +2513,7 @@
"group": "1_objActions@2"
},
{
"command": "code-for-ibmi.deleteObject",
"command": "code-for-ibmi.objectBrowser.delete",
"when": "view == objectBrowser && viewItem =~ /^object/",
"group": "1_objActions@5"
},
Expand Down
1 change: 0 additions & 1 deletion src/locale/ids/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export const da: Locale = {
'objectBrowser.copyObject.infoMessage': `Kopierede objekt {0} {1} til {2}.`,
'objectBrowser.copyObject.infoMessage2': `Kopierede objekt {0} {1} til {2}. Opfrisk object browser.`,
'objectBrowser.copyObject.errorMessage4': `Fejl ved kopiering af objekt {0}! {1}`,
'objectBrowser.deleteObject.warningMessage': `Er du sikker på at du vil slette {0} {1}?`,
'objectBrowser.deleteObject.infoMessage': `Slettede {0} {1}.`,
'objectBrowser.deleteObject.errorMessage': `Fejl ved sletning af objekt! {0}`,
'objectBrowser.deleteObject.progress':'Sletter objekt {0} {1}...',
Expand Down
1 change: 0 additions & 1 deletion src/locale/ids/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export const en: Locale = {
'objectBrowser.copyObject.infoMessage': `Copied object {0} {1} to {2}.`,
'objectBrowser.copyObject.infoMessage2': `Copied object {0} {1} to {2}. Refresh object browser.`,
'objectBrowser.copyObject.errorMessage4': `Error copying object {0}! {1}`,
'objectBrowser.deleteObject.warningMessage': `Are you sure you want to delete {0} {1}?`,
'objectBrowser.deleteObject.infoMessage': `Deleted {0} {1}.`,
'objectBrowser.deleteObject.errorMessage': `Error deleting object! {0}`,
'objectBrowser.deleteObject.progress':'Deleting object {0} {1}...',
Expand Down
1 change: 0 additions & 1 deletion src/locale/ids/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export const fr: Locale = {
'objectBrowser.copyObject.infoMessage': `Objet {0} {1} copié vers {2}.`,
'objectBrowser.copyObject.infoMessage2': `Objet {0} {1} copié vers {2}. Rafraîchissement de l'explorateur d'objet.`,
'objectBrowser.copyObject.errorMessage4': `Erreur lors de la copie de l'objet {0}! {1}`,
'objectBrowser.deleteObject.warningMessage': `Êtes-vous sûr de vouloir supprimer {0} {1}?`,
'objectBrowser.deleteObject.infoMessage': `{0} {1} supprimé.`,
'objectBrowser.deleteObject.errorMessage': `Erreur lors de la suppression de l'objet! {0}`,
'objectBrowser.deleteObject.progress':`Suppression de l'objet {0} {1}...`,
Expand Down
24 changes: 0 additions & 24 deletions src/views/objectBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,30 +1047,6 @@ export function initializeObjectBrowser(context: vscode.ExtensionContext) {
} while (newPath && !newPathOK)
}),

vscode.commands.registerCommand(`code-for-ibmi.deleteObject`, async (node: ObjectBrowserObjectItem | ObjectBrowserSourcePhysicalFileItem) => {
let result = await vscode.window.showWarningMessage(t(`objectBrowser.deleteObject.warningMessage`, node.path, node.object.type.toUpperCase()), t(`Yes`), t(`Cancel`));

if (result === t(`Yes`)) {
const connection = getConnection();
await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: t("objectBrowser.deleteObject.progress", node.path, node.object.type.toUpperCase()) }
, async (progress) => {
// TODO: Progress message about deleting!
const deleteResult = await connection.runCommand({
command: `DLTOBJ OBJ(${node.path}) OBJTYPE(${node.object.type})`,
noLibList: true
});

if (deleteResult.code === 0) {
vscode.window.showInformationMessage(t(`objectBrowser.deleteObject.infoMessage`, node.path, node.object.type.toUpperCase()));
objectBrowser.refresh(node.parent);
} else {
vscode.window.showErrorMessage(t(`objectBrowser.deleteObject.errorMessage`, deleteResult.stderr));
}
}
);
}
}),

vscode.commands.registerCommand(`code-for-ibmi.renameObject`, async (node: ObjectBrowserObjectItem) => {
let [, newObject] = node.path.split(`/`);
let newObjectOK;
Expand Down

0 comments on commit 561c277

Please sign in to comment.