Skip to content

Commit

Permalink
Move askToSaveRegistryPath to the extension context's global state (#446
Browse files Browse the repository at this point in the history
)

* Move askToSaveRegistryPath to extn context's globalState

* Comments
  • Loading branch information
PrashanthCorp authored Sep 5, 2018
1 parent 029a9d7 commit d1bc4a1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions commands/push-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ImageNode } from '../explorer/models/imageNode';
import { RootNode } from '../explorer/models/rootNode';
import { ext } from '../extensionVariables';
import { reporter } from '../telemetry/telemetry';
import { askToSavePrefix } from './registrySettings';
import { askToSaveRegistryPath } from './registrySettings';
import { addImageTaggingTelemetry, getOrAskForImageAndTag, IHasImageDescriptorAndLabel, tagImage } from './tag-image';
const teleCmdId: string = 'vscode-docker.image.push';
const teleAzureId: string = 'vscode-docker.image.push.azureContainerRegistry';
Expand All @@ -23,7 +23,7 @@ export async function pushImage(actionContext: IActionContext, context: ImageNod
let [imageToPush, imageName] = await getOrAskForImageAndTag(actionContext, context instanceof RootNode ? undefined : context);

if (imageName.includes('/')) {
await askToSavePrefix(imageName);
await askToSaveRegistryPath(imageName);
} else {
//let addPrefixImagePush = "addPrefixImagePush";
let askToPushPrefix: boolean = true; // ext.context.workspaceState.get(addPrefixImagePush, true);
Expand Down
10 changes: 5 additions & 5 deletions commands/registrySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ export async function consolidateDefaultRegistrySettings(): Promise<void> {
}
}

export async function askToSavePrefix(imagePath: string, promptForSave?: boolean): Promise<void> {
export async function askToSaveRegistryPath(imagePath: string, promptForSave?: boolean): Promise<void> {
let askToSaveKey: string = 'docker.askToSaveRegistryPath';
let askToSavePath: boolean = promptForSave || ext.context.globalState.get<boolean>(askToSaveKey, true);
const configOptions: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('docker');
let askToSaveRegistryPath: boolean = promptForSave || configOptions.get<boolean>('askToSaveRegistryPath', true);

let prefix = "";
if (imagePath.includes('/')) {
prefix = imagePath.substring(0, imagePath.lastIndexOf('/'));
}
if (prefix && askToSaveRegistryPath !== false) {
if (prefix && askToSavePath) {
let userPrefixPreference: vscode.MessageItem = await ext.ui.showWarningMessage(`Would you like to save '${prefix}' as your default registry path?`, DialogResponses.yes, DialogResponses.no, DialogResponses.skipForNow);
if (userPrefixPreference === DialogResponses.yes || userPrefixPreference === DialogResponses.no) {
askToSaveRegistryPath = false;
await configOptions.update('askToSaveRegistryPath', false, vscode.ConfigurationTarget.Workspace);
await ext.context.globalState.update(askToSaveKey, false);
}
if (userPrefixPreference === DialogResponses.yes) {
await configOptions.update(configurationKeys.defaultRegistryPath, prefix, vscode.ConfigurationTarget.Workspace);
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,6 @@
"default": "",
"description": "Default registry and path when tagging an image"
},
"docker.askToSaveRegistryPath": {
"type": "boolean",
"default": true,
"description": "Ask the user whether to store the path prefix in defaultRegsitryPath on first push"
},
"docker.showExplorer": {
"type": "boolean",
"default": true,
Expand Down

0 comments on commit d1bc4a1

Please sign in to comment.