diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e2701a..e814777 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ * extension is build for [Visual Studio Code 1.22](https://code.visualstudio.com/updates/v1_22) now * using new progress api for deploy operations now * using emoji icons for deploy operations in output window now -* buttons are shown in the status bar after a deploy operation +* buttons are shown in the status bar after a deploy operation, added `showStatusWhenFinished` to control this ... s. [issue #53](https://github.com/mkloubert/vscode-deploy-reloaded/issues/53) * added `$lines` function for quick code executions * updated the following [npm](https://www.npmjs.com/) modules: * [aws-sdk](https://www.npmjs.com/package/aws-sdk) `2.222.1` diff --git a/img/demo28.gif b/img/demo28.gif index 7df4a84..5b3b3be 100644 Binary files a/img/demo28.gif and b/img/demo28.gif differ diff --git a/package.json b/package.json index b914c2c..a6cf2dd 100644 --- a/package.json +++ b/package.json @@ -1317,6 +1317,26 @@ } ] }, + "showStatusWhenFinished": { + "description": "Show workspace name as prefix in popup messages or not.", + "oneOf": [ + { + "description": "Show a button in the status bar, after a deploy operation has been finished or not.", + "type": "boolean", + "default": false + }, + { + "description": "Shows a button in the status bar, after a deploy operation has been finished and defines the time, in milliseconds, after it should disapears automatically.", + "type": "integer", + "minimum": 0, + "default": 60000 + }, + { + "description": "Shows a button in the status bar, after a deploy operation has been finished.", + "type": "null" + } + ] + }, "showWorkspaceNameInPopups": { "description": "Show workspace name as prefix in popup messages or not.", "type": "boolean", diff --git a/src/contracts.ts b/src/contracts.ts index da2c739..a267da7 100644 --- a/src/contracts.ts +++ b/src/contracts.ts @@ -257,7 +257,7 @@ export interface Configuration extends deploy_packages.WithFastFileCheckSettings /** * Indicates, if non saved documents will be saved automatically, before they are going to be deployed or not. */ - readonly saveBeforeDeploy?: boolean; + readonly saveBeforeDeploy?: boolean; /** * Show a popup after a successfull deploy operation or not. */ @@ -266,6 +266,10 @@ export interface Configuration extends deploy_packages.WithFastFileCheckSettings * Shows a popup when a deploy operation has been finished. */ readonly showPopupWhenFinished?: deploy_gui.ShowPopupWhenFinishedValue; + /** + * Show a button in the status bar after a deploy operation has been finished. + */ + readonly showStatusWhenFinished?: boolean | number | null; /** * Show workspace name as prefix in popup messages or not. */ diff --git a/src/delete.ts b/src/delete.ts index b247357..97c118f 100644 --- a/src/delete.ts +++ b/src/delete.ts @@ -174,7 +174,7 @@ export async function deleteFilesIn(files: string[], }, { location: vscode.ProgressLocation.Notification, cancellable: true, - title: ME.t('delete.deletingFiles'), + title: ME.t('DELETE.deletingFiles'), }); } @@ -288,6 +288,8 @@ async function deleteFilesInWithProgress(progress: deploy_helpers.ProgressContex succeeded: [], }; + const OVERALL_WATCH = deploy_helpers.startWatch(); + // "finished button" await ME.invokeForFinishedButton( deploy_contracts.DeployOperation.Delete, @@ -321,15 +323,11 @@ async function deleteFilesInWithProgress(progress: deploy_helpers.ProgressContex btn.color = new vscode.ThemeColor(color); btn.text = `${icon} ` + `[${NOW.format( ME.t('time.timeWithSeconds') )}] ` + - ME.t('DELETE.finishedButton.text'); + ME.t('DELETE.finishedButton.text', + OVERALL_WATCH.stop()); btn.tooltip = ME.t('DELETE.finishedButton.tooltip'); - btn.show(); - - ME.setTimeoutForFinishedButton( - deploy_contracts.DeployOperation.Delete, - (b) => b.hide() - ); + ME.showFinishedButton(deploy_contracts.DeployOperation.Delete); } ); }; diff --git a/src/deploy.ts b/src/deploy.ts index e81ef13..e09c6f5 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -552,6 +552,8 @@ async function deployFilesToWithProgress(progress: deploy_helpers.ProgressContex succeeded: [], }; + const OVERALL_WATCH = deploy_helpers.startWatch(); + // "finished button" await ME.invokeForFinishedButton( deploy_contracts.DeployOperation.Deploy, @@ -585,15 +587,11 @@ async function deployFilesToWithProgress(progress: deploy_helpers.ProgressContex btn.color = new vscode.ThemeColor(color); btn.text = `${icon} ` + `[${NOW.format( ME.t('time.timeWithSeconds') )}] ` + - ME.t('deploy.finishedButton.text'); + ME.t('deploy.finishedButton.text', + OVERALL_WATCH.stop()); btn.tooltip = ME.t('deploy.finishedButton.tooltip'); - btn.show(); - - ME.setTimeoutForFinishedButton( - deploy_contracts.DeployOperation.Deploy, - (b) => b.hide() - ); + ME.showFinishedButton(deploy_contracts.DeployOperation.Deploy); } ); }; diff --git a/src/lang/de.ts b/src/lang/de.ts index 9fb779f..6230976 100644 --- a/src/lang/de.ts +++ b/src/lang/de.ts @@ -95,7 +95,7 @@ export const translation: Translation = { operationFailed: "Konnte das Löschen nicht durchführen (s. Debugkonsole 'STRG/CMD + SHIFT + Y')!", }, finishedButton: { - text: "Löschen abgeschlossen", + text: "Löschen abgeschlossen ({0:trim,ending_space}ms)", tooltip: "Hier klicken, um die Ausgabe zu öffnen ...", }, finishedOperation: "Das Löschen der Dateien in{0:trim,surround,leading_space} wurde erfolgreich abgeschlossen.", @@ -174,7 +174,7 @@ export const translation: Translation = { label: "Dateiliste", }, finishedButton: { - text: "Bereitstellen abgeschlossen", + text: "Bereitstellen abgeschlossen ({0:trim,ending_space}ms)", tooltip: "Hier klicken, um die Ausgabe zu öffnen ...", }, finishedOperation: "Das Bereitstellen der Dateien in{0:trim,surround,leading_space} wurde erfolgreich abgeschlossen.", @@ -473,7 +473,7 @@ export const translation: Translation = { operationForSourceFailed: "Das Laden der Datei(en) aus der Quelle{0:trim,surround,leading_space} schlug fehl:{1:trim,surround,leading_space}", }, finishedButton: { - text: "Laden abgeschlossen", + text: "Laden abgeschlossen ({0:trim,ending_space}ms)", tooltip: "Hier klicken, um die Ausgabe zu öffnen ...", }, finishedOperation: "Das Laden der Dateien von{0:trim,surround,leading_space} wurde erfolgreich abgeschlossen.", diff --git a/src/lang/en.ts b/src/lang/en.ts index 69d5759..dd60c21 100644 --- a/src/lang/en.ts +++ b/src/lang/en.ts @@ -95,7 +95,7 @@ export const translation: Translation = { operationFailed: "Delete operation failed (s. debug console 'CTRL/CMD + SHIFT + Y')!", }, finishedButton: { - text: "Delete operation finished", + text: "Delete operation finished ({0:trim,ending_space}ms)", tooltip: "Click here to open output ...", }, finishedOperation: "Deleting files in{0:trim,surround,leading_space} has been finished.", @@ -168,7 +168,7 @@ export const translation: Translation = { label: "File list", }, finishedButton: { - text: "Deploy operation finished", + text: "Deploy operation finished ({0:trim,ending_space}ms)", tooltip: "Click here to open output ...", }, finishedOperation: "Deploying files to{0:trim,surround,leading_space} has been finished.", @@ -474,7 +474,7 @@ export const translation: Translation = { operationForSourceFailed: "Pulling file(s) from source{0:trim,surround,leading_space} failed:{1:trim,surround,leading_space}", }, finishedButton: { - text: "Pull operation finished", + text: "Pull operation finished ({0:trim,ending_space}ms)", tooltip: "Click here to open output ...", }, finishedOperation: "Pulling files from{0:trim,surround,leading_space} has been finished.", diff --git a/src/pull.ts b/src/pull.ts index d9db093..1f4d9af 100644 --- a/src/pull.ts +++ b/src/pull.ts @@ -560,6 +560,8 @@ async function pullFilesFromWithProgress(progress: deploy_helpers.ProgressContex succeeded: [], }; + const OVERALL_WATCH = deploy_helpers.startWatch(); + // "finished button" await ME.invokeForFinishedButton( deploy_contracts.DeployOperation.Pull, @@ -593,15 +595,11 @@ async function pullFilesFromWithProgress(progress: deploy_helpers.ProgressContex btn.color = new vscode.ThemeColor(color); btn.text = `${icon} ` + `[${NOW.format( ME.t('time.timeWithSeconds') )}] ` + - ME.t('pull.finishedButton.text'); + ME.t('pull.finishedButton.text', + OVERALL_WATCH.stop()); btn.tooltip = ME.t('pull.finishedButton.tooltip'); - btn.show(); - - ME.setTimeoutForFinishedButton( - deploy_contracts.DeployOperation.Pull, - (b) => b.hide() - ); + ME.showFinishedButton(deploy_contracts.DeployOperation.Pull); } ); }; diff --git a/src/workspaces.ts b/src/workspaces.ts index 9d1ff31..9113a95 100644 --- a/src/workspaces.ts +++ b/src/workspaces.ts @@ -4454,6 +4454,55 @@ export class Workspace extends deploy_helpers.WorkspaceBase implements deploy_co } } + /** + * Shows a "finished button". + * + * @param {deploy_contracts.DeployOperation} operation The type of deploy operation. + * + * @return {boolean} Operation was successful or not. + */ + public showFinishedButton(operation: deploy_contracts.DeployOperation) { + const CFG = this.config; + if (!CFG) { + return; + } + + const BTN = this.getFinishedButton(operation); + if (BTN) { + const SHOW_STATUS_WHEN_FINISHED = CFG.showStatusWhenFinished; + + let showButton = true; + let hideAfter: number; + if (null !== SHOW_STATUS_WHEN_FINISHED) { + if (_.isBoolean(SHOW_STATUS_WHEN_FINISHED)) { + showButton = SHOW_STATUS_WHEN_FINISHED; + hideAfter = 60000; + } + else { + hideAfter = parseInt( + deploy_helpers.toStringSafe(SHOW_STATUS_WHEN_FINISHED).trim() + ); + } + } + + if (showButton) { + BTN.show(); + + if (!isNaN(hideAfter)) { + this.setTimeoutForFinishedButton( + operation, + (b) => b.hide(), + hideAfter, + ); + } + } + + return true; + } + + return false; + } + /** * Promise (and safe) version of 'vscode.window.showErrorMessage()' function. *