fix: show warning on mobile webview before app quits (#1598)
This commit is contained in:
@@ -45,7 +45,9 @@ const WorkspaceSwitcherMenu: FunctionComponent<Props> = ({
|
|||||||
|
|
||||||
const signoutAll = useCallback(async () => {
|
const signoutAll = useCallback(async () => {
|
||||||
const confirmed = await viewControllerManager.application.alertService.confirm(
|
const confirmed = await viewControllerManager.application.alertService.confirm(
|
||||||
'Are you sure you want to sign out of all workspaces on this device?',
|
`Are you sure you want to sign out of all workspaces on this device?${
|
||||||
|
viewControllerManager.application.isNativeMobileWeb() && '<b> Your app will quit after sign out completes.</b>'
|
||||||
|
}`,
|
||||||
undefined,
|
undefined,
|
||||||
'Sign out all',
|
'Sign out all',
|
||||||
ButtonType.Danger,
|
ButtonType.Danger,
|
||||||
@@ -60,6 +62,47 @@ const WorkspaceSwitcherMenu: FunctionComponent<Props> = ({
|
|||||||
viewControllerManager.accountMenuController.setSigningOut(true)
|
viewControllerManager.accountMenuController.setSigningOut(true)
|
||||||
}, [viewControllerManager])
|
}, [viewControllerManager])
|
||||||
|
|
||||||
|
const activateWorkspace = useCallback(
|
||||||
|
async (descriptor: ApplicationDescriptor) => {
|
||||||
|
if (viewControllerManager.application.isNativeMobileWeb()) {
|
||||||
|
const confirmed = await viewControllerManager.application.alertService.confirm(
|
||||||
|
'<b>The app needs to be restarted to activate the workspace</b>',
|
||||||
|
undefined,
|
||||||
|
'Quit app and activate workspace',
|
||||||
|
ButtonType.Danger,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (confirmed) {
|
||||||
|
void mainApplicationGroup.unloadCurrentAndActivateDescriptor(descriptor)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainApplicationGroup.unloadCurrentAndActivateDescriptor(descriptor)
|
||||||
|
},
|
||||||
|
[mainApplicationGroup, viewControllerManager.application],
|
||||||
|
)
|
||||||
|
|
||||||
|
const addAnotherWorkspace = useCallback(async () => {
|
||||||
|
if (viewControllerManager.application.isNativeMobileWeb()) {
|
||||||
|
const confirmed = await viewControllerManager.application.alertService.confirm(
|
||||||
|
'<b>The app needs to be restarted to add another workspace</b>',
|
||||||
|
undefined,
|
||||||
|
'Quit app and add new workspace',
|
||||||
|
ButtonType.Danger,
|
||||||
|
)
|
||||||
|
|
||||||
|
if (confirmed) {
|
||||||
|
void mainApplicationGroup.unloadCurrentAndCreateNewDescriptor()
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainApplicationGroup.unloadCurrentAndCreateNewDescriptor()
|
||||||
|
}, [mainApplicationGroup, viewControllerManager.application])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Menu a11yLabel="Workspace switcher menu" className="px-0 focus:shadow-none" isOpen={isOpen}>
|
<Menu a11yLabel="Workspace switcher menu" className="px-0 focus:shadow-none" isOpen={isOpen}>
|
||||||
{applicationDescriptors.map((descriptor) => (
|
{applicationDescriptors.map((descriptor) => (
|
||||||
@@ -68,18 +111,13 @@ const WorkspaceSwitcherMenu: FunctionComponent<Props> = ({
|
|||||||
descriptor={descriptor}
|
descriptor={descriptor}
|
||||||
hideOptions={hideWorkspaceOptions}
|
hideOptions={hideWorkspaceOptions}
|
||||||
onDelete={destroyWorkspace}
|
onDelete={destroyWorkspace}
|
||||||
onClick={() => void mainApplicationGroup.unloadCurrentAndActivateDescriptor(descriptor)}
|
onClick={() => activateWorkspace(descriptor)}
|
||||||
renameDescriptor={(label: string) => mainApplicationGroup.renameDescriptor(descriptor, label)}
|
renameDescriptor={(label: string) => mainApplicationGroup.renameDescriptor(descriptor, label)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<MenuItemSeparator />
|
<MenuItemSeparator />
|
||||||
|
|
||||||
<MenuItem
|
<MenuItem type={MenuItemType.IconButton} onClick={addAnotherWorkspace}>
|
||||||
type={MenuItemType.IconButton}
|
|
||||||
onClick={() => {
|
|
||||||
void mainApplicationGroup.unloadCurrentAndCreateNewDescriptor()
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon type="user-add" className="mr-2 text-neutral" />
|
<Icon type="user-add" className="mr-2 text-neutral" />
|
||||||
Add another workspace
|
Add another workspace
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
@@ -41,7 +41,15 @@ const ConfirmSignoutModal: FunctionComponent<Props> = ({ application, viewContro
|
|||||||
<AlertDialogLabel className="sk-h3 sk-panel-section-title">Sign out workspace?</AlertDialogLabel>
|
<AlertDialogLabel className="sk-h3 sk-panel-section-title">Sign out workspace?</AlertDialogLabel>
|
||||||
<AlertDialogDescription className="sk-panel-row">
|
<AlertDialogDescription className="sk-panel-row">
|
||||||
<div>
|
<div>
|
||||||
<p className="text-foreground">{STRING_SIGN_OUT_CONFIRMATION}</p>
|
<p className="text-foreground">
|
||||||
|
{STRING_SIGN_OUT_CONFIRMATION}
|
||||||
|
{application.isNativeMobileWeb() && (
|
||||||
|
<div className="font-bold">
|
||||||
|
<br />
|
||||||
|
Your app will quit after sign out completes.
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
{showWorkspaceWarning && (
|
{showWorkspaceWarning && (
|
||||||
<>
|
<>
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
Reference in New Issue
Block a user