Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Run on protected" option on Actions #1664

Merged
merged 4 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,10 @@
"filter",
"browser"
]
},
"runOnProtected": {
"type": "boolean",
"description": "If enabled, this Action will be allowed to run on protected/read only targets."
}
}
},
Expand Down
17 changes: 4 additions & 13 deletions src/api/CompileTools.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import path from 'path';
import vscode, { CustomExecution, EventEmitter, Pseudoterminal, TaskGroup, TaskRevealKind, WorkspaceFolder, commands, tasks, window } from 'vscode';
import vscode, { CustomExecution, EventEmitter, Pseudoterminal, TaskGroup, TaskRevealKind, WorkspaceFolder, commands, tasks } from 'vscode';
import { parseFSOptions } from '../filesystems/qsys/QSysFs';
import { Action, BrowserItem, CommandResult, DeploymentMethod, RemoteCommand, StandardIO } from '../typings';
import { GlobalConfiguration } from './Configuration';
Expand Down Expand Up @@ -86,17 +86,8 @@ export namespace CompileTools {
const content = instance.getContent();

const uriOptions = parseFSOptions(uri);

if (uriOptions.readonly) {
window.showWarningMessage(`Cannot run Actions against readonly objects.`);
return false;
}

if (config?.readOnlyMode) {
window.showWarningMessage(`Cannot run Actions while readonly mode is enabled in the connection settings.`);
return false;
}

const isProtected = uriOptions.readonly || config?.readOnlyMode;

const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);

if (connection && config && content) {
Expand All @@ -123,7 +114,7 @@ export namespace CompileTools {
});

// Then we get all the available Actions for the current context
availableActions = allActions.filter(action => action.type === uri.scheme && (!action.extensions || action.extensions.includes(extension) || action.extensions.includes(fragment) || action.extensions.includes(`GLOBAL`)))
availableActions = allActions.filter(action => action.type === uri.scheme && (!action.extensions || action.extensions.includes(extension) || action.extensions.includes(fragment) || action.extensions.includes(`GLOBAL`)) && (!isProtected || action.runOnProtected))
.sort((a, b) => (actionUsed.get(b.name) || 0) - (actionUsed.get(a.name) || 0))
.map(action => ({
label: action.name,
Expand Down
8 changes: 5 additions & 3 deletions src/locale/ids/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const da: Locale = {
'actions.workAction.create.title': `Opret aktion`,
'actions.workAction.edit.title': `Revider aktion "{0}"`,
'actions.workAction.duplicate.title': `Kopier aktion "{0}"`,
'actions.workAction.name': `Action navn`,
'actions.workAction.name': `Aktionsnavn`,
'actions.workAction.command': `Kommandoer`,
'actions.workAction.command.description': `Nedenfor er de tilgængelige variable, baseret på objekt typen. Du kan angive forskellige kommandoer på hver linie. Hver kommando er "stateless" og afvikles i eget job.`,
'actions.workAction.extensions': `Typer`,
Expand Down Expand Up @@ -264,10 +264,12 @@ export const da: Locale = {
'actions.workAction.refresh.description':'Liste niveauet for opfriskning efter aktion er udført.',
'actions.workAction.refresh.no':'Ingen',
'actions.workAction.refresh.no.description':'Ingen opfriskning',
'actions.workAction.refresh.parent':'Comtainer',
'actions.workAction.refresh.parent':'Container',
'actions.workAction.refresh.parent.description':'Den aktuelle container bliver opfrisket',
'actions.workAction.refresh.filter':'Filter',
'actions.workAction.refresh.filter.description':'Det aktuelle filter bliver opfrisket',
'actions.workAction.refresh.browser':'Vindue',
'actions.workAction.refresh.browser.description':'Hele vinduet bliver opfrisket'
'actions.workAction.refresh.browser.description':'Hele vinduet bliver opfrisket',
'actions.workAction.runOnProtected':'Må afvikles på sikret/skrive-beskyttet',
'actions.workAction.runOnProtected.description':'Tillader afvikling af denne aktion på sikrede eller skrive-beskyttede mål'
};
4 changes: 3 additions & 1 deletion src/locale/ids/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,7 @@ export const en: Locale = {
'actions.workAction.refresh.filter':'Filter',
'actions.workAction.refresh.filter.description':'The parent filter is refreshed',
'actions.workAction.refresh.browser':'Browser',
'actions.workAction.refresh.browser.description':'The entire browser is refreshed'
'actions.workAction.refresh.browser.description':'The entire browser is refreshed',
'actions.workAction.runOnProtected':'Run on protected/read only',
'actions.workAction.runOnProtected.description':'Allows the execution of this Action on protected or read only targets'
};
4 changes: 3 additions & 1 deletion src/locale/ids/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,5 +269,7 @@ export const fr: Locale = {
'actions.workAction.refresh.filter':'Filtre',
'actions.workAction.refresh.filter.description':'Le filtre parent est rafraîchi',
'actions.workAction.refresh.browser':'Navigateur',
'actions.workAction.refresh.browser.description':'Le navigateur est entièrement rafraîchi'
'actions.workAction.refresh.browser.description':'Le navigateur est entièrement rafraîchi',
'actions.workAction.runOnProtected':'Exécuter en mode protégé/lecture seule',
'actions.workAction.runOnProtected.description':`Autorise l'exécution de cette action sur des cibles protégés ou en lecture seule`
};
3 changes: 2 additions & 1 deletion src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export interface Action {
extensions?: string[];
deployFirst?: boolean;
postDownload?: string[];
refresh?: ActionRefresh
refresh?: ActionRefresh;
runOnProtected?:boolean;
}

export interface ConnectionData {
Expand Down
7 changes: 5 additions & 2 deletions src/webviews/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type ActionPage = {
type: ActionType
environment: ActionEnvironment
refresh: ActionRefresh
runOnProtected: boolean
buttons: "saveAction" | "deleteAction" | "cancelAction"
}

Expand Down Expand Up @@ -237,7 +238,8 @@ export namespace ActionsUI {
description: t('actions.workAction.refresh.browser'),
text: t('actions.workAction.refresh.browser.description')
}], t('actions.workAction.refresh.description')
)
)
.addCheckbox("runOnProtected", t("actions.workAction.runOnProtected"), t("actions.workAction.runOnProtected.description"), currentAction.runOnProtected)
.addHorizontalRule()
.addButtons(
{ id: `saveAction`, label: t(`save`) },
Expand Down Expand Up @@ -274,7 +276,8 @@ export namespace ActionsUI {
environment: data.environment,
name: data.name,
command: data.command,
refresh: data.refresh
refresh: data.refresh,
runOnProtected: data.runOnProtected
};

if (id >= 0) {
Expand Down