-
Notifications
You must be signed in to change notification settings - Fork 17
feat: prompt user to select lightning experince app #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,6 +104,41 @@ export class PreviewUtils { | |
| return Promise.resolve(device); | ||
| } | ||
|
|
||
| /** | ||
| * If an app name is provided then it will query the org to determine the DurableId for the provided app. | ||
| * Otherwise it will get a list of all of the lightning experience apps in the org that are visible/accessible | ||
| * by the user, prompts the user to select one, then returns the DurableId of the selected app. | ||
| * | ||
| * @param connection the connection to the org | ||
| * @param appName optional - either the DeveloperName or Label for an app | ||
| * @param logger optional - logger to be used for logging | ||
| * @returns the DurableId for an app. | ||
| */ | ||
| public static async getLightningExperienceAppId( | ||
| connection: Connection, | ||
| appName?: string, | ||
| logger?: Logger | ||
| ): Promise<string> { | ||
| if (appName) { | ||
| logger?.debug(`Determining App Id for ${appName}`); | ||
|
|
||
| // The appName is optional but if the user did provide an appName then it must be | ||
| // a valid one.... meaning that it should resolve to a valid appId. | ||
| const appId = await OrgUtils.getAppDefinitionDurableId(connection, appName); | ||
| if (!appId) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If appName is not valid, should user be prompted too?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not part of the UX design so we error out instead (which is consistent with the behavior of the Beta version). |
||
| return Promise.reject(new Error(messages.getMessage('error.fetching.app-id', [appName]))); | ||
| } | ||
|
|
||
| logger?.debug(`App Id is ${appId} for ${appName}`); | ||
| return appId; | ||
| } else { | ||
| logger?.debug('Prompting the user to select an app.'); | ||
| const appDefinition = await PromptUtils.promptUserToSelectLightningExperienceApp(connection); | ||
| logger?.debug(`App Id is ${appDefinition.DurableId} for ${appDefinition.Label}`); | ||
| return appDefinition.DurableId; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Generates the proper set of arguments to be used for launching desktop browser and navigating to the right location. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would do all of this in a single SQL statement using
JOINbut as I understand it SF SOQL statements don't supportJOINso instead I run 2 query and filter in code (since it won't be the case that an org would have thousands and thousands of apps... but rather a handful of apps)