@backstage/plugin-app 0.4.3-next.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/apis/DefaultDialogApi.esm.js +69 -15
- package/dist/apis/DefaultDialogApi.esm.js.map +1 -1
- package/dist/extensions/AppLanguageApi.esm.js +4 -5
- package/dist/extensions/AppLanguageApi.esm.js.map +1 -1
- package/dist/extensions/DialogDisplay.esm.js +1 -15
- package/dist/extensions/DialogDisplay.esm.js.map +1 -1
- package/dist/plugins/app/package.json.esm.js +1 -1
- package/package.json +17 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @backstage/plugin-app
|
|
2
2
|
|
|
3
|
+
## 0.4.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- effa7bf: Migrated `AppLanguageApi` extension to use the new `configSchema` option.
|
|
8
|
+
- e5baa20: Added support for configuring URL redirects on the `app/routes` extension. Redirects can be configured through `app-config` as an array of `{from, to}` path pairs, which will cause navigation to the `from` path to be redirected to the `to` path.
|
|
9
|
+
|
|
10
|
+
For example:
|
|
11
|
+
|
|
12
|
+
```yaml
|
|
13
|
+
app:
|
|
14
|
+
extensions:
|
|
15
|
+
- app/routes:
|
|
16
|
+
config:
|
|
17
|
+
redirects:
|
|
18
|
+
- from: /old-path
|
|
19
|
+
to: /new-path
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- 9244b70: The default auth implementation now checks for a `logoutUrl` in the logout response body. If the auth provider returns one (e.g. Auth0 federated logout), the browser is redirected to that URL to clear the provider's session cookies. This is backward compatible — providers that return an empty response are unaffected.
|
|
23
|
+
- e4804ab: Updated the default `DialogApi` implementation to support the new `open` method. The dialog display layer no longer renders any dialog chrome — callers provide their own dialog component. The deprecated `show` and `showModal` methods now use `open` internally with a Material UI dialog wrapper for backward compatibility.
|
|
24
|
+
- d66a3ec: Updated the `PageLayout` swap to pass a clickable `titleLink` on the `PluginHeader`, resolved from the plugin's root route ref.
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/ui@0.14.0
|
|
27
|
+
- @backstage/theme@0.7.3
|
|
28
|
+
- @backstage/frontend-plugin-api@0.16.0
|
|
29
|
+
- @backstage/core-components@0.18.9
|
|
30
|
+
- @backstage/filter-predicates@0.1.2
|
|
31
|
+
- @backstage/plugin-permission-react@0.5.0
|
|
32
|
+
- @backstage/core-plugin-api@1.12.5
|
|
33
|
+
- @backstage/integration-react@1.2.17
|
|
34
|
+
- @backstage/plugin-app-react@0.2.2
|
|
35
|
+
|
|
3
36
|
## 0.4.3-next.2
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -1,26 +1,80 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import Dialog from '@material-ui/core/Dialog';
|
|
3
|
+
|
|
1
4
|
class DefaultDialogApi {
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
if (!this.#
|
|
5
|
+
#onOpen;
|
|
6
|
+
open(elementOrComponent) {
|
|
7
|
+
if (!this.#onOpen) {
|
|
5
8
|
throw new Error("Dialog API has not been connected");
|
|
6
9
|
}
|
|
7
|
-
return this.#
|
|
8
|
-
component: typeof elementOrComponent === "function" ? elementOrComponent : () => elementOrComponent
|
|
9
|
-
modal: false
|
|
10
|
+
return this.#onOpen({
|
|
11
|
+
component: typeof elementOrComponent === "function" ? elementOrComponent : () => elementOrComponent
|
|
10
12
|
});
|
|
11
13
|
}
|
|
14
|
+
/** @deprecated Use {@link DefaultDialogApi.open} instead */
|
|
15
|
+
show(elementOrComponent) {
|
|
16
|
+
console.warn(
|
|
17
|
+
"DialogApi.show() is deprecated and will be removed in a future release. Use DialogApi.open() instead."
|
|
18
|
+
);
|
|
19
|
+
const innerDialog = this.open(({ dialog }) => /* @__PURE__ */ jsx(
|
|
20
|
+
DeprecatedMuiDialogWrapper,
|
|
21
|
+
{
|
|
22
|
+
dialog,
|
|
23
|
+
content: elementOrComponent,
|
|
24
|
+
modal: false
|
|
25
|
+
}
|
|
26
|
+
));
|
|
27
|
+
return wrapDialogHandle(innerDialog, false);
|
|
28
|
+
}
|
|
29
|
+
/** @deprecated Use {@link DefaultDialogApi.open} instead */
|
|
12
30
|
showModal(elementOrComponent) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
console.warn(
|
|
32
|
+
"DialogApi.showModal() is deprecated and will be removed in a future release. Use DialogApi.open() instead."
|
|
33
|
+
);
|
|
34
|
+
const innerDialog = this.open(({ dialog }) => /* @__PURE__ */ jsx(
|
|
35
|
+
DeprecatedMuiDialogWrapper,
|
|
36
|
+
{
|
|
37
|
+
dialog,
|
|
38
|
+
content: elementOrComponent,
|
|
39
|
+
modal: true
|
|
40
|
+
}
|
|
41
|
+
));
|
|
42
|
+
return wrapDialogHandle(innerDialog, true);
|
|
43
|
+
}
|
|
44
|
+
connect(onOpen) {
|
|
45
|
+
this.#onOpen = onOpen;
|
|
20
46
|
}
|
|
21
|
-
|
|
22
|
-
|
|
47
|
+
}
|
|
48
|
+
function DeprecatedMuiDialogWrapper({
|
|
49
|
+
dialog,
|
|
50
|
+
content,
|
|
51
|
+
modal
|
|
52
|
+
}) {
|
|
53
|
+
if (typeof content === "function") {
|
|
54
|
+
const Content = content;
|
|
55
|
+
return /* @__PURE__ */ jsx(Dialog, { open: true, onClose: modal ? void 0 : () => dialog.close(), children: /* @__PURE__ */ jsx(Content, { dialog }) });
|
|
23
56
|
}
|
|
57
|
+
return /* @__PURE__ */ jsx(Dialog, { open: true, onClose: modal ? void 0 : () => dialog.close(), children: content });
|
|
58
|
+
}
|
|
59
|
+
function wrapDialogHandle(innerDialog, modal) {
|
|
60
|
+
return {
|
|
61
|
+
close(...args) {
|
|
62
|
+
innerDialog.close(...args);
|
|
63
|
+
},
|
|
64
|
+
result() {
|
|
65
|
+
return innerDialog.result();
|
|
66
|
+
},
|
|
67
|
+
update(newContent) {
|
|
68
|
+
innerDialog.update(({ dialog }) => /* @__PURE__ */ jsx(
|
|
69
|
+
DeprecatedMuiDialogWrapper,
|
|
70
|
+
{
|
|
71
|
+
dialog,
|
|
72
|
+
content: newContent,
|
|
73
|
+
modal
|
|
74
|
+
}
|
|
75
|
+
));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
24
78
|
}
|
|
25
79
|
|
|
26
80
|
export { DefaultDialogApi };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultDialogApi.esm.js","sources":["../../src/apis/DefaultDialogApi.
|
|
1
|
+
{"version":3,"file":"DefaultDialogApi.esm.js","sources":["../../src/apis/DefaultDialogApi.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DialogApi, DialogApiDialog } from '@backstage/frontend-plugin-api';\nimport Dialog from '@material-ui/core/Dialog';\n\nexport type OnOpenDialog = (options: {\n component: (props: { dialog: DialogApiDialog<any> }) => JSX.Element;\n}) => DialogApiDialog<unknown>;\n\n/**\n * Default implementation for the {@link DialogApi}.\n * @internal\n */\nexport class DefaultDialogApi implements DialogApi {\n #onOpen?: OnOpenDialog;\n\n open<TResult = void>(\n elementOrComponent:\n | JSX.Element\n | ((props: { dialog: DialogApiDialog<TResult> }) => JSX.Element),\n ): DialogApiDialog<TResult> {\n if (!this.#onOpen) {\n throw new Error('Dialog API has not been connected');\n }\n return this.#onOpen({\n component:\n typeof elementOrComponent === 'function'\n ? elementOrComponent\n : () => elementOrComponent,\n }) as DialogApiDialog<TResult>;\n }\n\n /** @deprecated Use {@link DefaultDialogApi.open} instead */\n show<TResult = void>(\n elementOrComponent:\n | JSX.Element\n | ((props: {\n dialog: DialogApiDialog<TResult | undefined>;\n }) => JSX.Element),\n ): DialogApiDialog<TResult | undefined> {\n // eslint-disable-next-line no-console\n console.warn(\n 'DialogApi.show() is deprecated and will be removed in a future release. Use DialogApi.open() instead.',\n );\n const innerDialog = this.open<TResult | undefined>(({ dialog }) => (\n <DeprecatedMuiDialogWrapper\n dialog={dialog}\n content={elementOrComponent}\n modal={false}\n />\n ));\n return wrapDialogHandle(innerDialog, false);\n }\n\n /** @deprecated Use {@link DefaultDialogApi.open} instead */\n showModal<TResult = void>(\n elementOrComponent:\n | JSX.Element\n | ((props: { dialog: DialogApiDialog<TResult> }) => JSX.Element),\n ): DialogApiDialog<TResult> {\n // eslint-disable-next-line no-console\n console.warn(\n 'DialogApi.showModal() is deprecated and will be removed in a future release. Use DialogApi.open() instead.',\n );\n const innerDialog = this.open<TResult>(({ dialog }) => (\n <DeprecatedMuiDialogWrapper\n dialog={dialog}\n content={elementOrComponent}\n modal\n />\n ));\n return wrapDialogHandle(innerDialog, true);\n }\n\n connect(onOpen: OnOpenDialog): void {\n this.#onOpen = onOpen;\n }\n}\n\nfunction DeprecatedMuiDialogWrapper({\n dialog,\n content,\n modal,\n}: {\n dialog: DialogApiDialog<any>;\n content:\n | JSX.Element\n | ((props: { dialog: DialogApiDialog<any> }) => JSX.Element);\n modal: boolean;\n}) {\n if (typeof content === 'function') {\n const Content = content;\n return (\n <Dialog open onClose={modal ? undefined : () => dialog.close()}>\n <Content dialog={dialog} />\n </Dialog>\n );\n }\n return (\n <Dialog open onClose={modal ? undefined : () => dialog.close()}>\n {content}\n </Dialog>\n );\n}\n\nfunction wrapDialogHandle<TResult>(\n innerDialog: DialogApiDialog<TResult>,\n modal: boolean,\n): DialogApiDialog<TResult> {\n return {\n close(...args: any[]) {\n (innerDialog.close as any)(...args);\n },\n result() {\n return innerDialog.result();\n },\n update(newContent: any) {\n innerDialog.update(({ dialog }: { dialog: DialogApiDialog<TResult> }) => (\n <DeprecatedMuiDialogWrapper\n dialog={dialog}\n content={newContent}\n modal={modal}\n />\n ));\n },\n };\n}\n"],"names":[],"mappings":";;;AA2BO,MAAM,gBAAA,CAAsC;AAAA,EACjD,OAAA;AAAA,EAEA,KACE,kBAAA,EAG0B;AAC1B,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACjB,MAAA,MAAM,IAAI,MAAM,mCAAmC,CAAA;AAAA,IACrD;AACA,IAAA,OAAO,KAAK,OAAA,CAAQ;AAAA,MAClB,SAAA,EACE,OAAO,kBAAA,KAAuB,UAAA,GAC1B,qBACA,MAAM;AAAA,KACb,CAAA;AAAA,EACH;AAAA;AAAA,EAGA,KACE,kBAAA,EAKsC;AAEtC,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN;AAAA,KACF;AACA,IAAA,MAAM,cAAc,IAAA,CAAK,IAAA,CAA0B,CAAC,EAAE,QAAO,qBAC3D,GAAA;AAAA,MAAC,0BAAA;AAAA,MAAA;AAAA,QACC,MAAA;AAAA,QACA,OAAA,EAAS,kBAAA;AAAA,QACT,KAAA,EAAO;AAAA;AAAA,KAEV,CAAA;AACD,IAAA,OAAO,gBAAA,CAAiB,aAAa,KAAK,CAAA;AAAA,EAC5C;AAAA;AAAA,EAGA,UACE,kBAAA,EAG0B;AAE1B,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN;AAAA,KACF;AACA,IAAA,MAAM,cAAc,IAAA,CAAK,IAAA,CAAc,CAAC,EAAE,QAAO,qBAC/C,GAAA;AAAA,MAAC,0BAAA;AAAA,MAAA;AAAA,QACC,MAAA;AAAA,QACA,OAAA,EAAS,kBAAA;AAAA,QACT,KAAA,EAAK;AAAA;AAAA,KAER,CAAA;AACD,IAAA,OAAO,gBAAA,CAAiB,aAAa,IAAI,CAAA;AAAA,EAC3C;AAAA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guageApi/AppLanguageSelector.esm.js';
|
|
2
2
|
import { ApiBlueprint, appLanguageApiRef } from '@backstage/frontend-plugin-api';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
|
|
4
5
|
const AppLanguageApi = ApiBlueprint.makeWithOverrides({
|
|
5
6
|
name: "app-language",
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
availableLanguages: (z) => z.array(z.string()).optional()
|
|
10
|
-
}
|
|
7
|
+
configSchema: {
|
|
8
|
+
defaultLanguage: z.string().optional(),
|
|
9
|
+
availableLanguages: z.array(z.string()).optional()
|
|
11
10
|
},
|
|
12
11
|
factory(originalFactory, { config }) {
|
|
13
12
|
return originalFactory(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppLanguageApi.esm.js","sources":["../../src/extensions/AppLanguageApi.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppLanguageSelector } from '../../../../packages/core-app-api/src/apis/implementations/AppLanguageApi';\nimport { appLanguageApiRef } from '@backstage/frontend-plugin-api';\nimport { ApiBlueprint } from '@backstage/frontend-plugin-api';\n\nexport const AppLanguageApi = ApiBlueprint.makeWithOverrides({\n name: 'app-language',\n
|
|
1
|
+
{"version":3,"file":"AppLanguageApi.esm.js","sources":["../../src/extensions/AppLanguageApi.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppLanguageSelector } from '../../../../packages/core-app-api/src/apis/implementations/AppLanguageApi';\nimport { appLanguageApiRef } from '@backstage/frontend-plugin-api';\nimport { ApiBlueprint } from '@backstage/frontend-plugin-api';\nimport { z } from 'zod';\n\nexport const AppLanguageApi = ApiBlueprint.makeWithOverrides({\n name: 'app-language',\n configSchema: {\n defaultLanguage: z.string().optional(),\n availableLanguages: z.array(z.string()).optional(),\n },\n factory(originalFactory, { config }) {\n return originalFactory(defineParams =>\n defineParams({\n api: appLanguageApiRef,\n deps: {},\n factory: () =>\n AppLanguageSelector.createWithStorage({\n defaultLanguage: config.defaultLanguage,\n availableLanguages: config.availableLanguages,\n }),\n }),\n );\n },\n});\n"],"names":[],"mappings":";;;;AAsBO,MAAM,cAAA,GAAiB,aAAa,iBAAA,CAAkB;AAAA,EAC3D,IAAA,EAAM,cAAA;AAAA,EACN,YAAA,EAAc;AAAA,IACZ,eAAA,EAAiB,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA,IACrC,oBAAoB,CAAA,CAAE,KAAA,CAAM,EAAE,MAAA,EAAQ,EAAE,QAAA;AAAS,GACnD;AAAA,EACA,OAAA,CAAQ,eAAA,EAAiB,EAAE,MAAA,EAAO,EAAG;AACnC,IAAA,OAAO,eAAA;AAAA,MAAgB,kBACrB,YAAA,CAAa;AAAA,QACX,GAAA,EAAK,iBAAA;AAAA,QACL,MAAM,EAAC;AAAA,QACP,OAAA,EAAS,MACP,mBAAA,CAAoB,iBAAA,CAAkB;AAAA,UACpC,iBAAiB,MAAA,CAAO,eAAA;AAAA,UACxB,oBAAoB,MAAA,CAAO;AAAA,SAC5B;AAAA,OACJ;AAAA,KACH;AAAA,EACF;AACF,CAAC;;;;"}
|
|
@@ -2,7 +2,6 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { Fragment, useState, useEffect } from 'react';
|
|
3
3
|
import { AppRootElementBlueprint, dialogApiRef } from '@backstage/frontend-plugin-api';
|
|
4
4
|
import { createDeferred } from '@backstage/types';
|
|
5
|
-
import Dialog from '@material-ui/core/Dialog';
|
|
6
5
|
|
|
7
6
|
let dialogId = 0;
|
|
8
7
|
function getDialogId() {
|
|
@@ -19,7 +18,6 @@ function DialogDisplay({
|
|
|
19
18
|
const deferred = createDeferred();
|
|
20
19
|
const dialog = {
|
|
21
20
|
id,
|
|
22
|
-
modal: options.modal,
|
|
23
21
|
close(result) {
|
|
24
22
|
deferred.resolve(result);
|
|
25
23
|
setDialogs((ds) => ds.filter((d) => d.dialog.id !== id));
|
|
@@ -40,19 +38,7 @@ function DialogDisplay({
|
|
|
40
38
|
});
|
|
41
39
|
}, [dialogApi]);
|
|
42
40
|
if (dialogs.length > 0) {
|
|
43
|
-
|
|
44
|
-
return /* @__PURE__ */ jsx(
|
|
45
|
-
Dialog,
|
|
46
|
-
{
|
|
47
|
-
open: true,
|
|
48
|
-
onClose: () => {
|
|
49
|
-
if (!lastDialog.dialog.modal) {
|
|
50
|
-
lastDialog.dialog.close();
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
children: lastDialog.element
|
|
54
|
-
}
|
|
55
|
-
);
|
|
41
|
+
return dialogs[dialogs.length - 1].element;
|
|
56
42
|
}
|
|
57
43
|
return null;
|
|
58
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DialogDisplay.esm.js","sources":["../../src/extensions/DialogDisplay.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment, useEffect, useState } from 'react';\nimport {\n AppRootElementBlueprint,\n DialogApi,\n DialogApiDialog,\n dialogApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { createDeferred } from '@backstage/types';\nimport {
|
|
1
|
+
{"version":3,"file":"DialogDisplay.esm.js","sources":["../../src/extensions/DialogDisplay.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment, useEffect, useState } from 'react';\nimport {\n AppRootElementBlueprint,\n DialogApi,\n DialogApiDialog,\n dialogApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { createDeferred } from '@backstage/types';\nimport { OnOpenDialog } from '../apis/DefaultDialogApi';\n\nlet dialogId = 0;\nfunction getDialogId() {\n dialogId += 1;\n return dialogId.toString(36);\n}\n\ntype DialogState = DialogApiDialog<unknown> & {\n id: string;\n};\n\n/**\n * The other half of the default implementation of the {@link DialogApi}.\n *\n * This component is responsible for rendering the dialogs in the React tree\n * and managing a stack of dialogs. It renders only the most recently opened\n * dialog, without any dialog chrome — the caller is expected to provide their\n * own dialog component (overlay, backdrop, surface, etc.).\n *\n * It expects the implementation of the {@link DialogApi} to be the\n * `DefaultDialogApi`. If one is replaced the other must be too.\n *\n * @internal\n */\nfunction DialogDisplay({\n dialogApi,\n}: {\n dialogApi: DialogApi & { connect(onOpen: OnOpenDialog): void };\n}) {\n const [dialogs, setDialogs] = useState<\n { dialog: DialogState; element: React.JSX.Element }[]\n >([]);\n\n useEffect(() => {\n dialogApi.connect(options => {\n const id = getDialogId();\n const deferred = createDeferred<unknown>();\n const dialog: DialogState = {\n id,\n close(result) {\n deferred.resolve(result);\n setDialogs(ds => ds.filter(d => d.dialog.id !== id));\n },\n update(ElementOrComponent) {\n const element =\n typeof ElementOrComponent === 'function' ? (\n <ElementOrComponent dialog={dialog} />\n ) : (\n ElementOrComponent\n );\n setDialogs(ds =>\n ds.map(d => (d.dialog.id === id ? { dialog, element } : d)),\n );\n },\n async result() {\n return deferred;\n },\n };\n const element = <options.component dialog={dialog} />;\n setDialogs(ds => [...ds, { dialog, element }]);\n return dialog;\n });\n }, [dialogApi]);\n\n if (dialogs.length > 0) {\n return dialogs[dialogs.length - 1].element;\n }\n\n return null;\n}\n\nexport const dialogDisplayAppRootElement =\n AppRootElementBlueprint.makeWithOverrides({\n name: 'dialog-display',\n factory(originalFactory, { apis }) {\n const dialogApi = apis.get(dialogApiRef);\n if (!isInternalDialogApi(dialogApi)) {\n return originalFactory({\n element: <Fragment />,\n });\n }\n return originalFactory({\n element: <DialogDisplay dialogApi={dialogApi} />,\n });\n },\n });\n\nfunction isInternalDialogApi(\n dialogApi?: DialogApi,\n): dialogApi is DialogApi & { connect(onOpen: OnOpenDialog): void } {\n if (!dialogApi) {\n return false;\n }\n return 'connect' in dialogApi;\n}\n"],"names":["element"],"mappings":";;;;;AA0BA,IAAI,QAAA,GAAW,CAAA;AACf,SAAS,WAAA,GAAc;AACrB,EAAA,QAAA,IAAY,CAAA;AACZ,EAAA,OAAO,QAAA,CAAS,SAAS,EAAE,CAAA;AAC7B;AAmBA,SAAS,aAAA,CAAc;AAAA,EACrB;AACF,CAAA,EAEG;AACD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,QAAA,CAE5B,EAAE,CAAA;AAEJ,EAAA,SAAA,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,MAAA,GAAS,CAAC,CAAA,CAAE,OAAA;AAAA,EACrC;AAEA,EAAA,OAAO,IAAA;AACT;AAEO,MAAM,2BAAA,GACX,wBAAwB,iBAAA,CAAkB;AAAA,EACxC,IAAA,EAAM,gBAAA;AAAA,EACN,OAAA,CAAQ,eAAA,EAAiB,EAAE,IAAA,EAAK,EAAG;AACjC,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,GAAA,CAAI,YAAY,CAAA;AACvC,IAAA,IAAI,CAAC,mBAAA,CAAoB,SAAS,CAAA,EAAG;AACnC,MAAA,OAAO,eAAA,CAAgB;AAAA,QACrB,OAAA,sBAAU,QAAA,EAAA,EAAS;AAAA,OACpB,CAAA;AAAA,IACH;AACA,IAAA,OAAO,eAAA,CAAgB;AAAA,MACrB,OAAA,kBAAS,GAAA,CAAC,aAAA,EAAA,EAAc,SAAA,EAAsB;AAAA,KAC/C,CAAA;AAAA,EACH;AACF,CAAC;AAEH,SAAS,oBACP,SAAA,EACkE;AAClE,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,SAAA,IAAa,SAAA;AACtB;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-app",
|
|
3
|
-
"version": "0.4.3
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "frontend-plugin",
|
|
6
6
|
"pluginId": "app",
|
|
@@ -63,17 +63,17 @@
|
|
|
63
63
|
"test": "backstage-cli package test"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@backstage/core-components": "0.18.9
|
|
67
|
-
"@backstage/core-plugin-api": "1.12.5
|
|
68
|
-
"@backstage/filter-predicates": "0.1.2
|
|
69
|
-
"@backstage/frontend-plugin-api": "0.16.0
|
|
70
|
-
"@backstage/integration-react": "1.2.17
|
|
71
|
-
"@backstage/plugin-app-react": "0.2.2
|
|
72
|
-
"@backstage/plugin-permission-react": "0.
|
|
73
|
-
"@backstage/theme": "0.7.3
|
|
74
|
-
"@backstage/types": "1.2.2",
|
|
75
|
-
"@backstage/ui": "0.14.0
|
|
76
|
-
"@backstage/version-bridge": "1.0.12",
|
|
66
|
+
"@backstage/core-components": "^0.18.9",
|
|
67
|
+
"@backstage/core-plugin-api": "^1.12.5",
|
|
68
|
+
"@backstage/filter-predicates": "^0.1.2",
|
|
69
|
+
"@backstage/frontend-plugin-api": "^0.16.0",
|
|
70
|
+
"@backstage/integration-react": "^1.2.17",
|
|
71
|
+
"@backstage/plugin-app-react": "^0.2.2",
|
|
72
|
+
"@backstage/plugin-permission-react": "^0.5.0",
|
|
73
|
+
"@backstage/theme": "^0.7.3",
|
|
74
|
+
"@backstage/types": "^1.2.2",
|
|
75
|
+
"@backstage/ui": "^0.14.0",
|
|
76
|
+
"@backstage/version-bridge": "^1.0.12",
|
|
77
77
|
"@material-ui/core": "^4.9.13",
|
|
78
78
|
"@material-ui/icons": "^4.9.1",
|
|
79
79
|
"@material-ui/lab": "^4.0.0-alpha.61",
|
|
@@ -88,11 +88,11 @@
|
|
|
88
88
|
"zod": "^3.25.76 || ^4.0.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@backstage/cli": "0.36.1
|
|
92
|
-
"@backstage/dev-utils": "1.1.22
|
|
93
|
-
"@backstage/frontend-defaults": "0.5.1
|
|
94
|
-
"@backstage/frontend-test-utils": "0.5.2
|
|
95
|
-
"@backstage/test-utils": "1.7.17
|
|
91
|
+
"@backstage/cli": "^0.36.1",
|
|
92
|
+
"@backstage/dev-utils": "^1.1.22",
|
|
93
|
+
"@backstage/frontend-defaults": "^0.5.1",
|
|
94
|
+
"@backstage/frontend-test-utils": "^0.5.2",
|
|
95
|
+
"@backstage/test-utils": "^1.7.17",
|
|
96
96
|
"@testing-library/jest-dom": "^6.0.0",
|
|
97
97
|
"@testing-library/react": "^16.0.0",
|
|
98
98
|
"@testing-library/user-event": "^14.0.0",
|