Skip to content

Commit

Permalink
use showDomainOnPrompts instead of passing down clientName, make clie…
Browse files Browse the repository at this point in the history
…ntName enum
  • Loading branch information
gracejychang committed Aug 1, 2024
1 parent 58e2618 commit 8ae9677
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/app/src/cli/prompts/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function selectAppPrompt(

export async function selectStorePrompt(
stores: OrganizationStore[],
clientName: string,
showDomainOnPrompt: boolean,
): Promise<OrganizationStore | undefined> {
if (stores.length === 0) return undefined
if (stores.length === 1) {
Expand All @@ -69,7 +69,7 @@ export async function selectStorePrompt(

const storeList = stores.map((store) => {
let label = store.shopName
if (clientName === 'app-management') {
if (showDomainOnPrompt) {
label = `${store.shopName} (${store.shopDomain})`
}
return {label, value: store.shopId}
Expand Down
9 changes: 4 additions & 5 deletions packages/app/src/cli/services/dev/select-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ConvertDevToTransferDisabledSchema,
ConvertDevToTransferDisabledStoreVariables,
} from '../../api/graphql/convert_dev_to_transfer_disabled_store.js'
import {DeveloperPlatformClient} from '../../utilities/developer-platform-client.js'
import {ClientName, DeveloperPlatformClient} from '../../utilities/developer-platform-client.js'
import {sleep} from '@shopify/cli-kit/node/system'
import {renderTasks} from '@shopify/cli-kit/node/ui'
import {partnersFqdn} from '@shopify/cli-kit/node/context/fqdn'
Expand Down Expand Up @@ -39,11 +39,10 @@ export async function selectStore(
org: Organization,
developerPlatformClient: DeveloperPlatformClient,
): Promise<OrganizationStore> {
const clientName = developerPlatformClient.clientName

const showDomainOnPrompt = developerPlatformClient.clientName === ClientName.AppManagement
// If no stores, guide the developer through creating one
// Then, with a store selected, make sure its transfer-disabled, prompting to convert if needed
let store = await selectStorePrompt(stores, clientName)
let store = await selectStorePrompt(stores, showDomainOnPrompt)
if (!store) {
outputInfo(`\n${await CreateStoreLink(org.id)}`)
await sleep(5)
Expand All @@ -65,7 +64,7 @@ export async function selectStore(
)
while (!storeIsValid) {
// eslint-disable-next-line no-await-in-loop
store = await selectStorePrompt(stores, clientName)
store = await selectStorePrompt(stores, showDomainOnPrompt)
if (!store) {
throw new CancelExecution()
}
Expand Down
5 changes: 5 additions & 0 deletions packages/app/src/cli/utilities/developer-platform-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ import {DevSessionDeleteMutation} from '../api/graphql/app-dev/generated/dev-ses
import {FunctionUploadUrlGenerateResponse} from '@shopify/cli-kit/node/api/partners'
import {isTruthy} from '@shopify/cli-kit/node/context/utilities'

export enum ClientName {
AppManagement = 'app-management',
Partners = 'partners',
}

export type Paginateable<T> = T & {
hasMorePages: boolean
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
AppVersionIdentifiers,
DevSessionOptions,
filterDisabledFlags,
ClientName,
} from '../developer-platform-client.js'
import {PartnersSession} from '../../services/context/partner-account-info.js'
import {
Expand Down Expand Up @@ -145,7 +146,7 @@ export interface GatedExtensionTemplate extends ExtensionTemplate {
}

export class AppManagementClient implements DeveloperPlatformClient {
public clientName = 'app-management'
public clientName = ClientName.AppManagement
public webUiName = 'Developer Dashboard'
public requiresOrganization = true
public supportsAtomicDeployments = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
Paginateable,
DevSessionOptions,
filterDisabledFlags,
ClientName,
} from '../developer-platform-client.js'
import {fetchCurrentAccountInformation, PartnersSession} from '../../../cli/services/context/partner-account-info.js'
import {
Expand Down Expand Up @@ -209,7 +210,7 @@ interface OrgAndAppsResponse {
}

export class PartnersClient implements DeveloperPlatformClient {
public clientName = 'partners'
public clientName = ClientName.Partners
public webUiName = 'Partner Dashboard'
public supportsAtomicDeployments = false
public requiresOrganization = false
Expand Down

0 comments on commit 8ae9677

Please sign in to comment.