This repository was archived by the owner on Jul 1, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheffectivePathsJsPickerFallback.ts
More file actions
44 lines (41 loc) · 1.63 KB
/
Copy patheffectivePathsJsPickerFallback.ts
File metadata and controls
44 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type { EffectivePathsIdsGateway } from './assembleEffectivePathsListResult'
import type { EpMobileGrantPhase } from './effectivePathsMobileGrantSession'
import { redirectToMobilePickerAuth } from './googleDrivePickerMobile'
import {
linkedWorkbookNamesFromGateway,
type EnsureEffectivePathsSpreadsheetAccessTitles,
} from './grantEffectivePathsSpreadsheetAccess'
export function isJsPickerGrantFailure(reason: string): boolean {
return reason === 'picker_failed' || reason === 'picker_not_configured'
}
function linkedPickerTitle(base: string, gateway?: EffectivePathsIdsGateway): string {
if (!gateway) return base
const names = linkedWorkbookNamesFromGateway(gateway)
return names.length > 0 ? `${base} (${names.join(', ')})` : base
}
/** Full-page Google one-pick OAuth when the JS Picker overlay cannot open (desktop Chrome, etc.). */
export async function redirectMobilePickerAfterJsFailure(options: {
phase: EpMobileGrantPhase
masterSpreadsheetId: string
masterSheetGid: number | null
spreadsheetIds: readonly string[]
multiselect: boolean
titles: EnsureEffectivePathsSpreadsheetAccessTitles
gateway?: EffectivePathsIdsGateway
}): Promise<never> {
const { phase, masterSpreadsheetId, masterSheetGid, spreadsheetIds, multiselect, titles, gateway } =
options
await redirectToMobilePickerAuth({
phase,
masterSpreadsheetId,
masterSheetGid,
spreadsheetIds: [...spreadsheetIds],
multiselect,
requireMasterSpreadsheetId: masterSpreadsheetId,
titles: {
...titles,
linkedWorkbooks: linkedPickerTitle(titles.linkedWorkbooks, gateway),
},
})
throw new Error('mobile_picker_redirect')
}