Open in Google Play Console deep-links the app: Play developer id per credential profile (accounts play-developer, desktop Accounts), shared playAppUrl builder for desktop, CLI and watch; developer chooser instead of the console root

This commit is contained in:
CRTkafa 2026-10-23 09:20:35 +08:00
parent 7c769c18f4
commit 4a74989a95
33 changed files with 311 additions and 40 deletions

View file

@ -8,9 +8,18 @@ import { setShowIgnored } from '../lib/show-ignored';
import { type AppTab, type Nav, TAB_ICON, TAB_KEY, tabsFor } from '../nav';
import type { Data } from '../store';
import type { MenuInput, MenuItem } from './menu-logic';
import { pickConsoleId, playAppUrl } from '../../../../cli/lib/console-links';
export const ASC_APP = (id: string | null | undefined): string => (id ? `https://appstoreconnect.apple.com/apps/${encodeURIComponent(id)}/distribution` : 'https://appstoreconnect.apple.com/apps');
export const PLAY_HOME = 'https://play.google.com/console/';
/** The Play Console page of one app (console-links playAppUrl, shared with the CLI and watch): the app's dashboard when
* the developer id (status from the config / profile, else the app's Play account) and the console app id are known,
* else the developer's app list, else the developer chooser. Never the bare console root. */
export function playUrlFor(d: Data, app: UnifiedApp | null | undefined): string {
const st = app ? d.statusFor(app)?.app?.platforms.android : null;
const accId = app?.android?.account ?? app?.project?.playAccount ?? null;
const acc = accId ? d.accounts.find(a => a.id === accId) : undefined;
return playAppUrl({ developerId: pickConsoleId(st?.developerId, acc?.developerId), appId: st?.appId ?? null });
}
export function openUrl(d: Data, url: string): void {
api.openExternal(url).catch(e => d.toast({ kind: 'bad', title: t('link.openFailed'), detail: errorText(e) }));
@ -31,7 +40,7 @@ export function appMenu(app: UnifiedApp, d: Data, nav: Nav, opts: { showIgnored:
'sep',
(ios || android) && { label: t('cm.openConsole'), icon: 'external', submenu: [
ios && { label: 'App Store Connect', icon: 'external', onSelect: () => openUrl(d, ASC_APP(ios.id)) },
android && { label: 'Google Play Console', icon: 'external', onSelect: () => openUrl(d, PLAY_HOME) },
android && { label: 'Google Play Console', icon: 'external', onSelect: () => openUrl(d, playUrlFor(d, app)) },
] },
p && !p.missing && { label: t('cm.openFolder'), icon: 'folder', onSelect: () => { api.reveal(p.id).catch(e => d.toast({ kind: 'bad', title: t('cm.folderFailed'), detail: errorText(e) })); } },
{ label: t('cm.copy'), icon: 'copy', submenu: [
@ -68,7 +77,7 @@ export function appMenu(app: UnifiedApp, d: Data, nav: Nav, opts: { showIgnored:
export function consoleItem(d: Data, app: UnifiedApp, store: 'ios' | 'android'): MenuItem {
return store === 'ios'
? { label: t('cm.openIn', { place: 'App Store Connect' }), icon: 'external', onSelect: () => openUrl(d, ASC_APP(app.ios?.app.id)) }
: { label: t('cm.openIn', { place: 'Google Play Console' }), icon: 'external', onSelect: () => openUrl(d, PLAY_HOME) };
: { label: t('cm.openIn', { place: 'Google Play Console' }), icon: 'external', onSelect: () => openUrl(d, playUrlFor(d, app)) };
}
/** Menu of one store release: copy version / build, open the console. */
@ -82,9 +91,9 @@ export function releaseMenu(d: Data, app: UnifiedApp, store: 'ios' | 'android',
}
/** Both consoles of an app folder (App Store Connect with the app's id when the status knows it). */
export function projectConsoles(d: Data, ascAppId: string | null | undefined, ios: boolean, android: boolean): MenuInput {
export function projectConsoles(d: Data, ascAppId: string | null | undefined, ios: boolean, android: boolean, playUrl: string): MenuInput {
return [
ios && { label: t('cm.openIn', { place: 'App Store Connect' }), icon: 'external', onSelect: () => openUrl(d, ASC_APP(ascAppId)) },
android && { label: t('cm.openIn', { place: 'Google Play Console' }), icon: 'external', onSelect: () => openUrl(d, PLAY_HOME) },
android && { label: t('cm.openIn', { place: 'Google Play Console' }), icon: 'external', onSelect: () => openUrl(d, playUrl) },
];
}