Skip to content

Commit 34d7cd4

Browse files
leigaolcrossrac
andauthored
fix(codewhisperer): "Don't show again" access token popup #3022
* Do Not Show Again btn and show once a week Co-authored-by: Rachel Cross <[email protected]>
1 parent c4232c3 commit 34d7cd4

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

src/codewhisperer/activation.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,44 @@ export async function activate(context: ExtContext): Promise<void> {
247247

248248
await vscode.commands.executeCommand('aws.codeWhisperer.refreshRootNode')
249249
const t = new Date()
250+
const doNotShowAgain =
251+
context.extensionContext.globalState.get<boolean>(
252+
CodeWhispererConstants.accessTokenMigrationDoNotShowAgainKey
253+
) || false
254+
const notificationLastShown =
255+
context.extensionContext.globalState.get<Date>(
256+
CodeWhispererConstants.accessTokenMigrationDoNotShowAgainLastShown
257+
) || t
258+
259+
//Add 7 days to notificationLastShown to determine whether warn message should show
260+
notificationLastShown.setDate(notificationLastShown.getDate() + 7)
261+
if (doNotShowAgain || notificationLastShown <= t) {
262+
return
263+
}
250264
if (t <= CodeWhispererConstants.accessTokenCutOffDate) {
251265
vscode.window
252266
.showWarningMessage(
253267
CodeWhispererConstants.accessTokenMigrationWarningMessage,
254-
CodeWhispererConstants.accessTokenMigrationWarningButtonMessage
268+
CodeWhispererConstants.accessTokenMigrationWarningButtonMessage,
269+
CodeWhispererConstants.accessTokenMigrationDoNotShowAgain
255270
)
256271
.then(async resp => {
257272
if (resp === CodeWhispererConstants.accessTokenMigrationWarningButtonMessage) {
258273
await vscode.commands.executeCommand('aws.codeWhisperer.refresh')
259274
await showSsoSignIn.execute()
275+
} else if (resp === CodeWhispererConstants.accessTokenMigrationDoNotShowAgain) {
276+
await vscode.window.showInformationMessage(
277+
CodeWhispererConstants.accessTokenMigrationDoNotShowAgainInfo,
278+
'OK'
279+
)
280+
await context.extensionContext.globalState.update(
281+
CodeWhispererConstants.accessTokenMigrationDoNotShowAgainKey,
282+
true
283+
)
284+
await context.extensionContext.globalState.update(
285+
CodeWhispererConstants.accessTokenMigrationDoNotShowAgainLastShown,
286+
t
287+
)
260288
}
261289
})
262290
} else {
@@ -271,6 +299,11 @@ export async function activate(context: ExtContext): Promise<void> {
271299
if (resp === CodeWhispererConstants.accessTokenMigrationErrorButtonMessage) {
272300
await vscode.commands.executeCommand('aws.codeWhisperer.refresh')
273301
await showSsoSignIn.execute()
302+
} else if (resp === CodeWhispererConstants.accessTokenMigrationDoNotShowAgain) {
303+
await context.extensionContext.globalState.update(
304+
CodeWhispererConstants.accessTokenMigrationDoNotShowAgainKey,
305+
true
306+
)
274307
}
275308
})
276309
}

src/codewhisperer/models/constants.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,12 @@ export const failedToConnectAwsBuilderId = `Failed to connect to AWS Builder ID`
235235
export const failedToConnectIamIdentityCenter = `Failed to connect to IAM Identity Center`
236236

237237
export const connectionExpired = `AWS Toolkit: Connection expired. Reauthenticate to continue.`
238+
239+
export const accessTokenMigrationDoNotShowAgain = `Don\'t Show Again`
240+
241+
export const accessTokenMigrationDoNotShowAgainKey = 'CODEWHISPERER_ACCESS_TOKEN_MIGRATION_DO_NOT_SHOW_AGAIN'
242+
243+
export const accessTokenMigrationDoNotShowAgainLastShown =
244+
'CODEWHISPERER_ACCESS_TOKEN_MIGRATION_DO_NOT_SHOW_AGAIN_LAST_SHOWN'
245+
246+
export const accessTokenMigrationDoNotShowAgainInfo = `You will not receive this notification again. If you would like to continue using CodeWhisperer after January 31, 2023, you can still connect with AWS. [Learn More](https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/codewhisper-setup-general.html).`

0 commit comments

Comments
 (0)