|
| 1 | +/*! |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | +import * as nls from 'vscode-nls' |
| 6 | +const localize = nls.loadMessageBundle() |
| 7 | +import { AmazonQPromptSettings } from '../../shared/settings' |
| 8 | +import { telemetry } from '../../shared/telemetry/telemetry' |
| 9 | +import vscode from 'vscode' |
| 10 | +import { selectRegionProfileCommand } from '../commands/basicCommands' |
| 11 | +import { placeholder } from '../../shared/vscode/commands2' |
| 12 | +import { toastMessage } from '../commands/types' |
| 13 | + |
| 14 | +/** |
| 15 | + * Creates a toast message telling the user they need to select a Developer Profile |
| 16 | + */ |
| 17 | +export async function notifySelectDeveloperProfile() { |
| 18 | + const suppressId = 'amazonQSelectDeveloperProfile' |
| 19 | + const settings = AmazonQPromptSettings.instance |
| 20 | + const shouldShow = settings.isPromptEnabled(suppressId) |
| 21 | + if (!shouldShow) { |
| 22 | + return |
| 23 | + } |
| 24 | + |
| 25 | + const message = localize( |
| 26 | + 'aws.amazonq.profile.mustSelectMessage', |
| 27 | + 'You must select a Q Developer Profile for Amazon Q features to work.' |
| 28 | + ) |
| 29 | + const selectProfile = 'Select Profile' |
| 30 | + const dontShowAgain = 'Dont Show Again' |
| 31 | + |
| 32 | + await telemetry.toolkit_showNotification.run(async () => { |
| 33 | + telemetry.record({ id: 'mustSelectDeveloperProfileMessage' }) |
| 34 | + void vscode.window.showWarningMessage(message, selectProfile, dontShowAgain).then(async (resp) => { |
| 35 | + await telemetry.toolkit_invokeAction.run(async () => { |
| 36 | + if (resp === selectProfile) { |
| 37 | + // Show Profile |
| 38 | + telemetry.record({ action: 'select' }) |
| 39 | + void selectRegionProfileCommand.execute(placeholder, toastMessage) |
| 40 | + } else if (resp === dontShowAgain) { |
| 41 | + telemetry.record({ action: 'dontShowAgain' }) |
| 42 | + await settings.disablePrompt(suppressId) |
| 43 | + } else { |
| 44 | + telemetry.record({ action: 'ignore' }) |
| 45 | + } |
| 46 | + }) |
| 47 | + }) |
| 48 | + }) |
| 49 | +} |
0 commit comments