Skip to content

Commit f725a9e

Browse files
committed
handle openInNewTab front
1 parent ed70e4e commit f725a9e

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

resources/js/commands/CommandManager.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,27 @@ export class CommandManager {
4141

4242
get defaultCommandResponseHandlers(): CommandResponseHandlers {
4343
return {
44-
info: async ({ message, reload }, { formModal }) => {
45-
await showAlert(message, {
44+
info: async (data, { formModal }) => {
45+
await showAlert(data.message, {
4646
title: __('sharp::modals.command.info.title'),
4747
});
4848
if(formModal.shouldReopen) {
4949
formModal.reloadAndReopen();
50-
} else if(reload) {
50+
} else if(data.reload) {
5151
await this.handleCommandResponse({ action: 'reload' });
5252
}
5353
},
54-
link: ({ link }, { formModal }) => {
54+
link: (data, { formModal }) => {
5555
if(formModal.shouldReopen) {
5656
formModal.reloadAndReopen();
5757
return;
5858
}
59-
if(isSharpLink(link)) {
60-
router.visit(link);
59+
if(data.openInNewTab) {
60+
window.open(data.link, '_blank');
61+
} else if(isSharpLink(data.link)) {
62+
router.visit(data.link);
6163
} else {
62-
location.href = link;
64+
location.href = data.link;
6365
}
6466
},
6567
reload: (data, { formModal }) => {

resources/js/types/generated.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export type CommandFormData = {
6565
pageAlert: PageAlertData | null;
6666
};
6767
export type CommandResponseData =
68-
| { action: "link"; link: string }
68+
| { action: "link"; link: string; openInNewTab: boolean }
6969
| { action: "info"; message: string; reload: boolean }
7070
| { action: "refresh"; items?: Array<{ [key: string]: any }> }
7171
| { action: "reload" }
@@ -140,9 +140,6 @@ export type EmbedFormData = {
140140
fields: { [key: string]: FormFieldData };
141141
layout: FormLayoutData | null;
142142
};
143-
export type EmbeddedFieldAuthorizationsData = {
144-
view: boolean;
145-
};
146143
export type EntityListAuthorizationsData = {
147144
create: boolean;
148145
reorder: boolean;
@@ -811,7 +808,7 @@ export type ShowDashboardFieldData = {
811808
dashboardKey: string;
812809
hiddenCommands: Array<string>;
813810
endpointUrl: string;
814-
authorizations: EmbeddedFieldAuthorizationsData;
811+
authorizations: ShowFieldAuthorizationsData;
815812
label: string | null;
816813
hiddenFilters: { [key: string]: any } | null;
817814
};
@@ -838,10 +835,13 @@ export type ShowEntityListFieldData = {
838835
showSearchField: boolean;
839836
showCount: boolean;
840837
endpointUrl: string;
841-
authorizations: EmbeddedFieldAuthorizationsData;
838+
authorizations: ShowFieldAuthorizationsData;
842839
label: string | null;
843840
hiddenFilters: { [key: string]: any } | null;
844841
};
842+
export type ShowFieldAuthorizationsData = {
843+
view: boolean;
844+
};
845845
export type ShowFieldData =
846846
| ShowDashboardFieldData
847847
| ShowEntityListFieldData

0 commit comments

Comments
 (0)