-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Match dialog button layout to OS (#6044)
This change updates the order of buttons in modals to match a user's native OS layout. The layout of buttons defaults to OS X button order when Positron is run in a web environment. Addresses #3548 ### Release Notes #### New Features - Updates modal button order to match native OS layout #### Bug Fixes - N/A ### QA Notes - [ ] Verify that keyboard navigation works for modals and there are no regressions with the behavior - [ ] Verify that confirmation dialogs with an Ok and Cancel button is ordered: - [ ] Ok/Cancel on windows - [ ] Cancel/Ok on non-windows environments - [ ] Verify that dialogs with more than two actions split actions so that the primary action and cancel action are positioned at the right end of the modal and all other tertiary actions are positioned at the left end of the modal. ### Screenshots <img width="1346" alt="Screenshot 2025-01-17 at 12 21 03 PM" src="https://github.com/user-attachments/assets/e71a93d5-33ce-4ea2-bafa-795bca7a222b" /> <img width="1346" alt="Screenshot 2025-01-17 at 12 20 47 PM" src="https://github.com/user-attachments/assets/875680fe-d187-4040-9661-4621a1f93621" /> <img width="1346" alt="Screenshot 2025-01-17 at 12 20 17 PM" src="https://github.com/user-attachments/assets/1fe06f71-e1ed-4d7d-bb18-c478ee6e5896" /> <img width="1346" alt="Screenshot 2025-01-17 at 12 20 09 PM" src="https://github.com/user-attachments/assets/58fea0e7-6b00-46cf-aa8f-9350ea96f7ac" /> https://github.com/user-attachments/assets/92b72df1-d87f-4e45-8982-52d8f01825b1 @:new-project-wizard @:win @:modal --------- Signed-off-by: Dhruvi Sompura <[email protected]> Co-authored-by: sharon <[email protected]>
- Loading branch information
1 parent
775a468
commit b07fed2
Showing
15 changed files
with
220 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...owser/positronComponents/positronModalDialog/components/platformNativeDialogActionBar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2025 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
|
||
// React. | ||
import React from 'react'; | ||
|
||
// Other dependencies. | ||
import * as platform from '../../../../../base/common/platform.js'; | ||
|
||
/** | ||
* PlatformNativeDialogActionBarProps interface. | ||
*/ | ||
interface PlatformNativeDialogActionBarProps { | ||
secondaryButton?: React.ReactNode, | ||
primaryButton?: React.ReactNode | ||
} | ||
|
||
/** | ||
* PlatformNativeDialogActionBar component. | ||
* @param props A PlatformNativeDialogActionBarProps that contains the component properties. | ||
* @returns The rendered component. | ||
*/ | ||
export const PlatformNativeDialogActionBar = ({ secondaryButton, primaryButton }: PlatformNativeDialogActionBarProps) => { | ||
// Render. | ||
return ( | ||
<> | ||
{ | ||
platform.isWindows | ||
? <>{primaryButton}{secondaryButton}</> | ||
: <>{secondaryButton}{primaryButton}</> | ||
} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/vs/workbench/browser/positronComponents/positronModalDialog/confirmDeleteModalDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
// CSS. | ||
import './positronModalDialog.css'; | ||
import './confirmDeleteModalDialog.css'; | ||
|
||
// React. | ||
import React, { PropsWithChildren } from 'react'; | ||
|
||
// Other dependencies. | ||
import { localize } from '../../../../nls.js'; | ||
import { Button } from '../../../../base/browser/ui/positronComponents/button/button.js'; | ||
import { ContentArea } from './components/contentArea.js'; | ||
import { PositronModalDialog, PositronModalDialogProps } from './positronModalDialog.js'; | ||
import { PlatformNativeDialogActionBar } from './components/platformNativeDialogActionBar.js'; | ||
|
||
/** | ||
* ConfirmDeleteModalDialogProps interface. | ||
*/ | ||
export interface ConfirmDeleteModalDialogProps extends PositronModalDialogProps { | ||
title: string; | ||
cancelButtonTitle?: string; | ||
deleteActionTitle?: string | ||
onCancel: () => (void | Promise<void>); | ||
onDeleteAction: () => (void | Promise<void>); | ||
} | ||
|
||
/** | ||
* ConfirmDeleteModalDialog component. | ||
* @param props A PropsWithChildren<ConfirmDeleteModalDialogProps> that contains the component | ||
* properties. | ||
* @returns The rendered component. | ||
*/ | ||
export const ConfirmDeleteModalDialog = (props: PropsWithChildren<ConfirmDeleteModalDialogProps>) => { | ||
const cancelButton = ( | ||
<Button | ||
className='action-bar-button' | ||
onPressed={async () => await props.onCancel()} | ||
> | ||
{props.cancelButtonTitle ?? localize('positron.cancel', "Cancel")} | ||
</Button> | ||
); | ||
const deleteButton = ( | ||
<Button | ||
className='action-bar-button default' | ||
onPressed={async () => await props.onDeleteAction()} | ||
> | ||
{props.deleteActionTitle ?? localize('positron.delete', "Delete")} | ||
</Button> | ||
); | ||
|
||
// Render. | ||
return ( | ||
<PositronModalDialog {...props}> | ||
<ContentArea> | ||
{props.children} | ||
</ContentArea> | ||
<div className='action-bar top-separator'> | ||
<div className='left-actions'> | ||
</div> | ||
<div className='right-actions'> | ||
<PlatformNativeDialogActionBar secondaryButton={cancelButton} primaryButton={deleteButton} /> | ||
</div> | ||
</div> | ||
</PositronModalDialog> | ||
); | ||
}; |
69 changes: 0 additions & 69 deletions
69
src/vs/workbench/browser/positronComponents/positronModalDialog/confirmationModalDialog.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.