Skip to content

Commit

Permalink
Add backend part of "Show lesser dialogs" #95
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidFeldhoff committed Apr 3, 2021
1 parent 75d9b9f commit 8cc8061
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
7 changes: 5 additions & 2 deletions vscode-extension/src/App logic/Utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ export class Config {
static getTestSrcFolder(): string | undefined {
return this.getConfig().get<string>('testDirectory');
}
static getShowConfirmations(uri: Uri | undefined): boolean {
return this.getConfig(uri).get<boolean>('showConfirmations', true);
static getShowConfirmations(): boolean {
return this.getConfig().get<boolean>('showConfirmations', true);
}
static setShowConfirmations(newValue: boolean) {
this.getConfig().update('showConfirmations', newValue, ConfigurationTarget.Workspace);
}
private static getConfig(uri?: Uri): WorkspaceConfiguration {
return workspace.getConfiguration(this.app, uri);
Expand Down
6 changes: 3 additions & 3 deletions vscode-extension/src/App logic/Utils/userInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Config } from './config';

export abstract class UserInteraction {
abstract ask(question: string, options: string[], defaultOption: string): Promise<string | undefined>;

static questionDeleteElement(): string { return this.confirmDeletion('this element') }
static questionDeleteScenario(): string { return this.confirmDeletion('this scenario') }
static questionDeleteFeature(): string { return this.confirmDeletion('this feature') }
Expand All @@ -18,13 +18,13 @@ export abstract class UserInteraction {
static questionWhichProcedureToTake: string = 'To the new naming exists already a helper function with the same parameters. Which one to take?';
static responseYes: string = 'Yes';
static responseNo: string = 'No';

private static confirmDeletion(thing: string): string { return `Do you want to delete ${thing}?` }
private static confirmUpdate(thing: string): string { return `Do you want to update ${thing}?` }
}
export class VSCodeInformationOutput extends UserInteraction {
async ask(question: string, options: string[], defaultOption: string): Promise<string | undefined> {
if (options.length > 0 && !Config.getShowConfirmations(vscode.window.activeTextEditor?.document.uri))
if (options.length > 0 && !Config.getShowConfirmations())
return defaultOption

switch (options.length) {
Expand Down
7 changes: 2 additions & 5 deletions vscode-extension/src/Services/WebPanelCommandService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,12 @@ export class WebPanelCommandService {
}

async GetConfigurationCommand(message: IMessageBase) {
// TODO
let setting = false;
let setting = !Config.getShowConfirmations();
WebPanel.postMessage({ Command: 'GetConfiguration', setting });
}

async SetConfigurationCommand(message: IMessageBase) {
// TODO
//let setting = message.Data as boolean;
//
Config.setShowConfirmations(!message.Data)
WebPanel.postMessage({ Command: 'SetConfiguration', Data: null });
}
}

0 comments on commit 8cc8061

Please sign in to comment.