sdedic commented on code in PR #7607: URL: https://github.com/apache/netbeans/pull/7607#discussion_r1696656277
########## java/java.lsp.server/vscode/src/panels/guidesUtil.ts: ########## @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import * as vscode from 'vscode'; +import * as path from 'path'; +import * as os from 'os'; + +export const GUIDE_NOTIFICATION_CONFIGURATION_KEY = 'guides.notified'; + +export type NotificationActionType = 'ssh-connection' | 'run-container-image' +export type StatePropertyPrefix = 'sshGuide' | 'runContainerImageGuide' + +type GuideNotification = { + ocid: string; + actionType: NotificationActionType; +} + +export const sshConfigLocation = path.join(os.homedir(), '.ssh', 'config'); +export const dummyKeyPathLocation = path.join(os.homedir(), '<path-to-your-key>', 'ssh-key-yyyy-mm-dd.key'); + + +export function removeGuidePropertiesFromStateFor(context: vscode.ExtensionContext, statePropertyPrefix: StatePropertyPrefix) { + context.globalState.update(`${statePropertyPrefix}-publicIp`, undefined); + context.globalState.update(`${statePropertyPrefix}-ocid`, undefined); +} + +export function shouldHideGuideFor(actionType: NotificationActionType, ocid?: string) : boolean { + const notifiedGuides: Array<GuideNotification> | undefined = vscode.workspace.getConfiguration('netbeans').get<Array<GuideNotification>>(GUIDE_NOTIFICATION_CONFIGURATION_KEY); + return notifiedGuides && notifiedGuides.find((notified) => notified.ocid === ocid && notified.actionType === actionType) ? true : false; +} + +export async function toggleGuideFor(actionType: NotificationActionType, ocid: string) { + const notifiedGuides: Array<GuideNotification> = vscode.workspace.getConfiguration('netbeans').get<Array<GuideNotification>>(GUIDE_NOTIFICATION_CONFIGURATION_KEY) || []; + const notifiedForOcid = notifiedGuides.find((notified) => notified.ocid === ocid && notified.actionType === actionType) + + if (notifiedForOcid) { Review Comment: I am not sure if this belongs to (user) settings ... I think that vscode extensions usually use a `globalContext` for this kind of `do not show again` flags (i.e. standard welcome screens do). Depends on whether we want the user to manipulate with those settings. Edit: after an offline discussion - let's keep it in the settings; will be consistent with other oracle cloud-related extensions. Sorry for the noise. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
