Move primary buttons on the right of the dialogs (#1382)

Closes #1368.
This commit is contained in:
Francesco Spissu 2022-09-20 11:48:19 +02:00 committed by GitHub
parent 671d2eabd4
commit 364f8b8e51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 5 deletions

View File

@ -181,10 +181,10 @@ export class AdditionalUrlsDialog extends AbstractDialog<string[]> {
); );
this.contentNode.appendChild(anchor); this.contentNode.appendChild(anchor);
this.appendAcceptButton(nls.localize('vscode/issueMainService/ok', 'OK'));
this.appendCloseButton( this.appendCloseButton(
nls.localize('vscode/issueMainService/cancel', 'Cancel') nls.localize('vscode/issueMainService/cancel', 'Cancel')
); );
this.appendAcceptButton(nls.localize('vscode/issueMainService/ok', 'OK'));
} }
get value(): string[] { get value(): string[] {

View File

@ -126,13 +126,13 @@ export class LibraryListWidget extends ListWidget<
), ),
message, message,
buttons: [ buttons: [
nls.localize('arduino/library/installAll', 'Install all'), nls.localize('vscode/issueMainService/cancel', 'Cancel'),
nls.localize( nls.localize(
'arduino/library/installOnly', 'arduino/library/installOnly',
'Install {0} only', 'Install {0} only',
item.name item.name
), ),
nls.localize('vscode/issueMainService/cancel', 'Cancel'), nls.localize('arduino/library/installAll', 'Install all'),
], ],
maxWidth: 740, // Aligned with `settings-dialog.css`. maxWidth: 740, // Aligned with `settings-dialog.css`.
}).open(); }).open();
@ -201,7 +201,9 @@ class MessageBoxDialog extends AbstractDialog<MessageBoxDialog.Result> {
options.buttons || [nls.localize('vscode/issueMainService/ok', 'OK')] options.buttons || [nls.localize('vscode/issueMainService/ok', 'OK')]
).forEach((text, index) => { ).forEach((text, index) => {
const button = this.createButton(text); const button = this.createButton(text);
button.classList.add(index === 0 ? 'main' : 'secondary'); const isPrimaryButton =
index === (options.buttons ? options.buttons.length - 1 : 0);
button.classList.add(isPrimaryButton ? 'main' : 'secondary');
this.controlPanel.appendChild(button); this.controlPanel.appendChild(button);
this.toDisposeOnDetach.push( this.toDisposeOnDetach.push(
addEventListener(button, 'click', () => { addEventListener(button, 'click', () => {

View File

@ -93,4 +93,5 @@
.p-Widget.dialogOverlay .dialogBlock .dialogContent.additional-urls-dialog { .p-Widget.dialogOverlay .dialogBlock .dialogContent.additional-urls-dialog {
display: block; display: block;
overflow: hidden;
} }

View File

@ -14,7 +14,8 @@ export class WorkspaceInputDialog extends TheiaWorkspaceInputDialog {
constructor( constructor(
@inject(WorkspaceInputDialogProps) @inject(WorkspaceInputDialogProps)
protected override readonly props: WorkspaceInputDialogProps, protected override readonly props: WorkspaceInputDialogProps,
@inject(LabelProvider) protected override readonly labelProvider: LabelProvider @inject(LabelProvider)
protected override readonly labelProvider: LabelProvider
) { ) {
super(props, labelProvider); super(props, labelProvider);
this.appendCloseButton( this.appendCloseButton(
@ -41,4 +42,14 @@ export class WorkspaceInputDialog extends TheiaWorkspaceInputDialog {
this.errorMessageNode.innerText = DialogError.getMessage(error); this.errorMessageNode.innerText = DialogError.getMessage(error);
} }
} }
protected override appendCloseButton(text: string): HTMLButtonElement {
this.closeButton = this.createButton(text);
this.controlPanel.insertBefore(
this.closeButton,
this.controlPanel.lastChild
);
this.closeButton.classList.add('secondary');
return this.closeButton;
}
} }