@backstage/plugin-user-settings 0.8.21 → 0.8.22-next.1
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 +39 -0
- package/dist/alpha.d.ts +38 -0
- package/dist/alpha.esm.js +1 -1
- package/dist/alpha.esm.js.map +1 -1
- package/dist/components/AuthProviders/DefaultProviderSettings.esm.js +30 -9
- package/dist/components/AuthProviders/DefaultProviderSettings.esm.js.map +1 -1
- package/dist/components/AuthProviders/EmptyProviders.esm.js +35 -34
- package/dist/components/AuthProviders/EmptyProviders.esm.js.map +1 -1
- package/dist/components/AuthProviders/ProviderSettingsItem.esm.js +5 -2
- package/dist/components/AuthProviders/ProviderSettingsItem.esm.js.map +1 -1
- package/dist/components/AuthProviders/UserSettingsAuthProviders.esm.js +4 -1
- package/dist/components/AuthProviders/UserSettingsAuthProviders.esm.js.map +1 -1
- package/dist/components/DefaultSettingsPage/DefaultSettingsPage.esm.js +20 -3
- package/dist/components/DefaultSettingsPage/DefaultSettingsPage.esm.js.map +1 -1
- package/dist/components/FeatureFlags/EmptyFlags.esm.js +35 -30
- package/dist/components/FeatureFlags/EmptyFlags.esm.js.map +1 -1
- package/dist/components/FeatureFlags/FeatureFlagsItem.esm.js +21 -6
- package/dist/components/FeatureFlags/FeatureFlagsItem.esm.js.map +1 -1
- package/dist/components/FeatureFlags/UserSettingsFeatureFlags.esm.js +7 -4
- package/dist/components/FeatureFlags/UserSettingsFeatureFlags.esm.js.map +1 -1
- package/dist/components/General/UserSettingsIdentityCard.esm.js +12 -4
- package/dist/components/General/UserSettingsIdentityCard.esm.js.map +1 -1
- package/dist/components/General/UserSettingsLanguageToggle.esm.js +3 -1
- package/dist/components/General/UserSettingsLanguageToggle.esm.js.map +1 -1
- package/dist/components/General/UserSettingsMenu.esm.js +5 -2
- package/dist/components/General/UserSettingsMenu.esm.js.map +1 -1
- package/dist/components/General/UserSettingsPinToggle.esm.js +7 -4
- package/dist/components/General/UserSettingsPinToggle.esm.js.map +1 -1
- package/dist/components/Settings.esm.js +4 -1
- package/dist/components/Settings.esm.js.map +1 -1
- package/dist/components/SettingsLayout/SettingsLayout.esm.js +4 -1
- package/dist/components/SettingsLayout/SettingsLayout.esm.js.map +1 -1
- package/dist/translation.esm.js +79 -1
- package/dist/translation.esm.js.map +1 -1
- package/package.json +17 -17
|
@@ -2,6 +2,8 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import Button from '@material-ui/core/Button';
|
|
3
3
|
import Typography from '@material-ui/core/Typography';
|
|
4
4
|
import { EmptyState, CodeSnippet } from '@backstage/core-components';
|
|
5
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
6
|
+
import { userSettingsTranslationRef } from '../../translation.esm.js';
|
|
5
7
|
|
|
6
8
|
const EXAMPLE = `import { createPlugin } from '@backstage/core-plugin-api';
|
|
7
9
|
|
|
@@ -10,36 +12,39 @@ export default createPlugin({
|
|
|
10
12
|
featureFlags: [{ name: 'enable-example-feature' }],
|
|
11
13
|
});
|
|
12
14
|
`;
|
|
13
|
-
const EmptyFlags = () =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/* @__PURE__ */
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
15
|
+
const EmptyFlags = () => {
|
|
16
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
EmptyState,
|
|
19
|
+
{
|
|
20
|
+
missing: "content",
|
|
21
|
+
title: t("featureFlags.emptyFlags.title"),
|
|
22
|
+
description: t("featureFlags.emptyFlags.description"),
|
|
23
|
+
action: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body1", children: t("featureFlags.emptyFlags.action.title") }),
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
CodeSnippet,
|
|
27
|
+
{
|
|
28
|
+
text: EXAMPLE,
|
|
29
|
+
language: "typescript",
|
|
30
|
+
showLineNumbers: true,
|
|
31
|
+
highlightedNumbers: [6],
|
|
32
|
+
customStyle: { background: "inherit", fontSize: "115%" }
|
|
33
|
+
}
|
|
34
|
+
),
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
Button,
|
|
37
|
+
{
|
|
38
|
+
variant: "contained",
|
|
39
|
+
color: "primary",
|
|
40
|
+
href: "https://backstage.io/docs/api/utility-apis",
|
|
41
|
+
children: t("featureFlags.emptyFlags.action.readMoreButtonTitle")
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
] })
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
};
|
|
43
48
|
|
|
44
49
|
export { EmptyFlags };
|
|
45
50
|
//# sourceMappingURL=EmptyFlags.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyFlags.esm.js","sources":["../../../src/components/FeatureFlags/EmptyFlags.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 Button from '@material-ui/core/Button';\nimport Typography from '@material-ui/core/Typography';\nimport { CodeSnippet, EmptyState } from '@backstage/core-components';\n\nconst EXAMPLE = `import { createPlugin } from '@backstage/core-plugin-api';\n\nexport default createPlugin({\n id: 'plugin-name',\n featureFlags: [{ name: 'enable-example-feature' }],\n});\n`;\n\nexport const EmptyFlags = () => (\n <EmptyState\n
|
|
1
|
+
{"version":3,"file":"EmptyFlags.esm.js","sources":["../../../src/components/FeatureFlags/EmptyFlags.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 Button from '@material-ui/core/Button';\nimport Typography from '@material-ui/core/Typography';\nimport { CodeSnippet, EmptyState } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { userSettingsTranslationRef } from '../../translation';\n\nconst EXAMPLE = `import { createPlugin } from '@backstage/core-plugin-api';\n\nexport default createPlugin({\n id: 'plugin-name',\n featureFlags: [{ name: 'enable-example-feature' }],\n});\n`;\n\nexport const EmptyFlags = () => {\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n return (\n <EmptyState\n missing=\"content\"\n title={t('featureFlags.emptyFlags.title')}\n description={t('featureFlags.emptyFlags.description')}\n action={\n <>\n <Typography variant=\"body1\">\n {t('featureFlags.emptyFlags.action.title')}\n </Typography>\n <CodeSnippet\n text={EXAMPLE}\n language=\"typescript\"\n showLineNumbers\n highlightedNumbers={[6]}\n customStyle={{ background: 'inherit', fontSize: '115%' }}\n />\n <Button\n variant=\"contained\"\n color=\"primary\"\n href=\"https://backstage.io/docs/api/utility-apis\"\n >\n {t('featureFlags.emptyFlags.action.readMoreButtonTitle')}\n </Button>\n </>\n }\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;AAsBA,MAAM,OAAU,GAAA,CAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAQT,MAAM,aAAa,MAAM;AAC9B,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA;AAE1D,EACE,uBAAA,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,OAAQ,EAAA,SAAA;AAAA,MACR,KAAA,EAAO,EAAE,+BAA+B,CAAA;AAAA,MACxC,WAAA,EAAa,EAAE,qCAAqC,CAAA;AAAA,MACpD,wBAEI,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OACjB,EAAA,QAAA,EAAA,CAAA,CAAE,sCAAsC,CAC3C,EAAA,CAAA;AAAA,wBACA,GAAA;AAAA,UAAC,WAAA;AAAA,UAAA;AAAA,YACC,IAAM,EAAA,OAAA;AAAA,YACN,QAAS,EAAA,YAAA;AAAA,YACT,eAAe,EAAA,IAAA;AAAA,YACf,kBAAA,EAAoB,CAAC,CAAC,CAAA;AAAA,YACtB,WAAa,EAAA,EAAE,UAAY,EAAA,SAAA,EAAW,UAAU,MAAO;AAAA;AAAA,SACzD;AAAA,wBACA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,OAAQ,EAAA,WAAA;AAAA,YACR,KAAM,EAAA,SAAA;AAAA,YACN,IAAK,EAAA,4CAAA;AAAA,YAEJ,YAAE,oDAAoD;AAAA;AAAA;AACzD,OACF,EAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -4,17 +4,32 @@ import ListItemText from '@material-ui/core/ListItemText';
|
|
|
4
4
|
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
|
5
5
|
import Switch from '@material-ui/core/Switch';
|
|
6
6
|
import Tooltip from '@material-ui/core/Tooltip';
|
|
7
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
8
|
+
import { userSettingsTranslationRef } from '../../translation.esm.js';
|
|
7
9
|
|
|
8
|
-
const getSecondaryText = (flag) => {
|
|
10
|
+
const getSecondaryText = (flag, t) => {
|
|
9
11
|
if (flag.description) {
|
|
10
12
|
return flag.description;
|
|
11
13
|
}
|
|
12
|
-
return flag.pluginId ?
|
|
14
|
+
return flag.pluginId ? t("featureFlags.flagItem.subtitle.registeredInPlugin", {
|
|
15
|
+
pluginId: flag.pluginId
|
|
16
|
+
}) : t("featureFlags.flagItem.subtitle.registeredInApplication");
|
|
17
|
+
};
|
|
18
|
+
const FlagItem = ({ flag, enabled, toggleHandler }) => {
|
|
19
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
20
|
+
return /* @__PURE__ */ jsxs(ListItem, { divider: true, button: true, onClick: () => toggleHandler(flag.name), children: [
|
|
21
|
+
/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(
|
|
22
|
+
Tooltip,
|
|
23
|
+
{
|
|
24
|
+
placement: "top",
|
|
25
|
+
arrow: true,
|
|
26
|
+
title: enabled ? t("featureFlags.flagItem.title.disable") : t("featureFlags.flagItem.title.enable"),
|
|
27
|
+
children: /* @__PURE__ */ jsx(Switch, { color: "primary", checked: enabled, name: flag.name })
|
|
28
|
+
}
|
|
29
|
+
) }),
|
|
30
|
+
/* @__PURE__ */ jsx(ListItemText, { primary: flag.name, secondary: getSecondaryText(flag, t) })
|
|
31
|
+
] });
|
|
13
32
|
};
|
|
14
|
-
const FlagItem = ({ flag, enabled, toggleHandler }) => /* @__PURE__ */ jsxs(ListItem, { divider: true, button: true, onClick: () => toggleHandler(flag.name), children: [
|
|
15
|
-
/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Tooltip, { placement: "top", arrow: true, title: enabled ? "Disable" : "Enable", children: /* @__PURE__ */ jsx(Switch, { color: "primary", checked: enabled, name: flag.name }) }) }),
|
|
16
|
-
/* @__PURE__ */ jsx(ListItemText, { primary: flag.name, secondary: getSecondaryText(flag) })
|
|
17
|
-
] });
|
|
18
33
|
|
|
19
34
|
export { FlagItem };
|
|
20
35
|
//# sourceMappingURL=FeatureFlagsItem.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureFlagsItem.esm.js","sources":["../../../src/components/FeatureFlags/FeatureFlagsItem.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 ListItem from '@material-ui/core/ListItem';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport Switch from '@material-ui/core/Switch';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { FeatureFlag } from '@backstage/core-plugin-api';\n\ntype Props = {\n flag: FeatureFlag;\n enabled: boolean;\n toggleHandler: Function;\n};\n\nconst getSecondaryText = (flag: FeatureFlag) => {\n if (flag.description) {\n return flag.description;\n }\n return flag.pluginId\n ?
|
|
1
|
+
{"version":3,"file":"FeatureFlagsItem.esm.js","sources":["../../../src/components/FeatureFlags/FeatureFlagsItem.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 ListItem from '@material-ui/core/ListItem';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport Switch from '@material-ui/core/Switch';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { FeatureFlag } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { userSettingsTranslationRef } from '../../translation';\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\n\ntype Props = {\n flag: FeatureFlag;\n enabled: boolean;\n toggleHandler: Function;\n};\n\nconst getSecondaryText = (\n flag: FeatureFlag,\n t: TranslationFunction<typeof userSettingsTranslationRef.T>,\n) => {\n if (flag.description) {\n return flag.description;\n }\n return flag.pluginId\n ? t('featureFlags.flagItem.subtitle.registeredInPlugin', {\n pluginId: flag.pluginId,\n })\n : t('featureFlags.flagItem.subtitle.registeredInApplication');\n};\n\nexport const FlagItem = ({ flag, enabled, toggleHandler }: Props) => {\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n return (\n <ListItem divider button onClick={() => toggleHandler(flag.name)}>\n <ListItemIcon>\n <Tooltip\n placement=\"top\"\n arrow\n title={\n enabled\n ? t('featureFlags.flagItem.title.disable')\n : t('featureFlags.flagItem.title.enable')\n }\n >\n <Switch color=\"primary\" checked={enabled} name={flag.name} />\n </Tooltip>\n </ListItemIcon>\n <ListItemText primary={flag.name} secondary={getSecondaryText(flag, t)} />\n </ListItem>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAgCA,MAAM,gBAAA,GAAmB,CACvB,IAAA,EACA,CACG,KAAA;AACH,EAAA,IAAI,KAAK,WAAa,EAAA;AACpB,IAAA,OAAO,IAAK,CAAA,WAAA;AAAA;AAEd,EAAO,OAAA,IAAA,CAAK,QACR,GAAA,CAAA,CAAE,mDAAqD,EAAA;AAAA,IACrD,UAAU,IAAK,CAAA;AAAA,GAChB,CACD,GAAA,CAAA,CAAE,wDAAwD,CAAA;AAChE,CAAA;AAEO,MAAM,WAAW,CAAC,EAAE,IAAM,EAAA,OAAA,EAAS,eAA2B,KAAA;AACnE,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA;AAE1D,EACE,uBAAA,IAAA,CAAC,QAAS,EAAA,EAAA,OAAA,EAAO,IAAC,EAAA,MAAA,EAAM,IAAC,EAAA,OAAA,EAAS,MAAM,aAAA,CAAc,IAAK,CAAA,IAAI,CAC7D,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,YACC,EAAA,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,SAAU,EAAA,KAAA;AAAA,QACV,KAAK,EAAA,IAAA;AAAA,QACL,OACE,OACI,GAAA,CAAA,CAAE,qCAAqC,CAAA,GACvC,EAAE,oCAAoC,CAAA;AAAA,QAG5C,QAAA,kBAAA,GAAA,CAAC,UAAO,KAAM,EAAA,SAAA,EAAU,SAAS,OAAS,EAAA,IAAA,EAAM,KAAK,IAAM,EAAA;AAAA;AAAA,KAE/D,EAAA,CAAA;AAAA,oBACA,GAAA,CAAC,gBAAa,OAAS,EAAA,IAAA,CAAK,MAAM,SAAW,EAAA,gBAAA,CAAiB,IAAM,EAAA,CAAC,CAAG,EAAA;AAAA,GAC1E,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -10,6 +10,8 @@ import { FlagItem } from './FeatureFlagsItem.esm.js';
|
|
|
10
10
|
import { useApi, featureFlagsApiRef, FeatureFlagState } from '@backstage/core-plugin-api';
|
|
11
11
|
import { InfoCard } from '@backstage/core-components';
|
|
12
12
|
import ClearIcon from '@material-ui/icons/Clear';
|
|
13
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
14
|
+
import { userSettingsTranslationRef } from '../../translation.esm.js';
|
|
13
15
|
|
|
14
16
|
const sortFlags = (flags, featureFlagsApi) => {
|
|
15
17
|
const activeFlags = flags.filter((flag) => featureFlagsApi.isActive(flag.name));
|
|
@@ -30,6 +32,7 @@ const UserSettingsFeatureFlags = () => {
|
|
|
30
32
|
);
|
|
31
33
|
const [state, setState] = useState(initialFlagState);
|
|
32
34
|
const [filterInput, setFilterInput] = useState("");
|
|
35
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
33
36
|
const toggleFlag = useCallback(
|
|
34
37
|
(flagName) => {
|
|
35
38
|
const newState = featureFlagsApi.isActive(flagName) ? FeatureFlagState.None : FeatureFlagState.Active;
|
|
@@ -57,13 +60,13 @@ const UserSettingsFeatureFlags = () => {
|
|
|
57
60
|
});
|
|
58
61
|
const Header = () => /* @__PURE__ */ jsxs(Grid, { container: true, style: { justifyContent: "space-between" }, children: [
|
|
59
62
|
/* @__PURE__ */ jsxs(Grid, { item: true, xs: 6, md: 8, children: [
|
|
60
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h5", children: "
|
|
61
|
-
/* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: "
|
|
63
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h5", children: t("featureFlags.title") }),
|
|
64
|
+
/* @__PURE__ */ jsx(Typography, { variant: "subtitle1", children: t("featureFlags.description") })
|
|
62
65
|
] }),
|
|
63
66
|
featureFlags.length >= 10 && /* @__PURE__ */ jsx(Grid, { item: true, xs: 6, md: 4, children: /* @__PURE__ */ jsx(
|
|
64
67
|
TextField,
|
|
65
68
|
{
|
|
66
|
-
label: "
|
|
69
|
+
label: t("featureFlags.filterTitle"),
|
|
67
70
|
style: { display: "flex", justifyContent: "flex-end" },
|
|
68
71
|
inputRef: (ref) => ref && ref.focus(),
|
|
69
72
|
InputProps: {
|
|
@@ -71,7 +74,7 @@ const UserSettingsFeatureFlags = () => {
|
|
|
71
74
|
endAdornment: /* @__PURE__ */ jsx(
|
|
72
75
|
IconButton,
|
|
73
76
|
{
|
|
74
|
-
"aria-label": "
|
|
77
|
+
"aria-label": t("featureFlags.clearFilter"),
|
|
75
78
|
onClick: clearFilterInput,
|
|
76
79
|
edge: "end",
|
|
77
80
|
children: /* @__PURE__ */ jsx(ClearIcon, {})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsFeatureFlags.esm.js","sources":["../../../src/components/FeatureFlags/UserSettingsFeatureFlags.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useRef, useCallback, useState } from 'react';\nimport List from '@material-ui/core/List';\nimport TextField from '@material-ui/core/TextField';\nimport IconButton from '@material-ui/core/IconButton';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { EmptyFlags } from './EmptyFlags';\nimport { FlagItem } from './FeatureFlagsItem';\nimport {\n FeatureFlag,\n FeatureFlagsApi,\n featureFlagsApiRef,\n FeatureFlagState,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { InfoCard } from '@backstage/core-components';\nimport ClearIcon from '@material-ui/icons/Clear';\n\nexport const sortFlags = (\n flags: FeatureFlag[],\n featureFlagsApi: FeatureFlagsApi,\n): FeatureFlag[] => {\n const activeFlags = flags.filter(flag => featureFlagsApi.isActive(flag.name));\n const idleFlags = flags.filter(flag => !featureFlagsApi.isActive(flag.name));\n return [...activeFlags, ...idleFlags];\n};\n\n/** @public */\nexport const UserSettingsFeatureFlags = () => {\n const featureFlagsApi = useApi(featureFlagsApiRef);\n const inputRef = useRef<HTMLElement>();\n\n const initialFeatureFlags = featureFlagsApi.getRegisteredFlags();\n const initialFeatureFlagsSorted = sortFlags(\n initialFeatureFlags,\n featureFlagsApi,\n );\n const [featureFlags] = useState(initialFeatureFlagsSorted);\n\n const initialFlagState = Object.fromEntries(\n featureFlags.map(({ name }) => [name, featureFlagsApi.isActive(name)]),\n );\n\n const [state, setState] = useState<Record<string, boolean>>(initialFlagState);\n const [filterInput, setFilterInput] = useState<string>('');\n\n const toggleFlag = useCallback(\n (flagName: string) => {\n const newState = featureFlagsApi.isActive(flagName)\n ? FeatureFlagState.None\n : FeatureFlagState.Active;\n\n featureFlagsApi.save({\n states: { [flagName]: newState },\n merge: true,\n });\n\n setState(prevState => ({\n ...prevState,\n [flagName]: newState === FeatureFlagState.Active,\n }));\n },\n [featureFlagsApi],\n );\n\n if (!featureFlags.length) {\n return <EmptyFlags />;\n }\n\n const clearFilterInput = () => {\n setFilterInput('');\n inputRef?.current?.focus();\n };\n\n const filteredFeatureFlags = featureFlags.filter(featureFlag => {\n const featureFlagName = featureFlag.name.toLocaleLowerCase('en-US');\n return featureFlagName.includes(filterInput.toLocaleLowerCase('en-US'));\n });\n\n const Header = () => (\n <Grid container style={{ justifyContent: 'space-between' }}>\n <Grid item xs={6} md={8}>\n <Typography variant=\"h5\">
|
|
1
|
+
{"version":3,"file":"UserSettingsFeatureFlags.esm.js","sources":["../../../src/components/FeatureFlags/UserSettingsFeatureFlags.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useRef, useCallback, useState } from 'react';\nimport List from '@material-ui/core/List';\nimport TextField from '@material-ui/core/TextField';\nimport IconButton from '@material-ui/core/IconButton';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { EmptyFlags } from './EmptyFlags';\nimport { FlagItem } from './FeatureFlagsItem';\nimport {\n FeatureFlag,\n FeatureFlagsApi,\n featureFlagsApiRef,\n FeatureFlagState,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { InfoCard } from '@backstage/core-components';\nimport ClearIcon from '@material-ui/icons/Clear';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { userSettingsTranslationRef } from '../../translation';\n\nexport const sortFlags = (\n flags: FeatureFlag[],\n featureFlagsApi: FeatureFlagsApi,\n): FeatureFlag[] => {\n const activeFlags = flags.filter(flag => featureFlagsApi.isActive(flag.name));\n const idleFlags = flags.filter(flag => !featureFlagsApi.isActive(flag.name));\n return [...activeFlags, ...idleFlags];\n};\n\n/** @public */\nexport const UserSettingsFeatureFlags = () => {\n const featureFlagsApi = useApi(featureFlagsApiRef);\n const inputRef = useRef<HTMLElement>();\n\n const initialFeatureFlags = featureFlagsApi.getRegisteredFlags();\n const initialFeatureFlagsSorted = sortFlags(\n initialFeatureFlags,\n featureFlagsApi,\n );\n const [featureFlags] = useState(initialFeatureFlagsSorted);\n\n const initialFlagState = Object.fromEntries(\n featureFlags.map(({ name }) => [name, featureFlagsApi.isActive(name)]),\n );\n\n const [state, setState] = useState<Record<string, boolean>>(initialFlagState);\n const [filterInput, setFilterInput] = useState<string>('');\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n const toggleFlag = useCallback(\n (flagName: string) => {\n const newState = featureFlagsApi.isActive(flagName)\n ? FeatureFlagState.None\n : FeatureFlagState.Active;\n\n featureFlagsApi.save({\n states: { [flagName]: newState },\n merge: true,\n });\n\n setState(prevState => ({\n ...prevState,\n [flagName]: newState === FeatureFlagState.Active,\n }));\n },\n [featureFlagsApi],\n );\n\n if (!featureFlags.length) {\n return <EmptyFlags />;\n }\n\n const clearFilterInput = () => {\n setFilterInput('');\n inputRef?.current?.focus();\n };\n\n const filteredFeatureFlags = featureFlags.filter(featureFlag => {\n const featureFlagName = featureFlag.name.toLocaleLowerCase('en-US');\n return featureFlagName.includes(filterInput.toLocaleLowerCase('en-US'));\n });\n\n const Header = () => (\n <Grid container style={{ justifyContent: 'space-between' }}>\n <Grid item xs={6} md={8}>\n <Typography variant=\"h5\">{t('featureFlags.title')}</Typography>\n <Typography variant=\"subtitle1\">\n {t('featureFlags.description')}\n </Typography>\n </Grid>\n {featureFlags.length >= 10 && (\n <Grid item xs={6} md={4}>\n <TextField\n label={t('featureFlags.filterTitle')}\n style={{ display: 'flex', justifyContent: 'flex-end' }}\n inputRef={ref => ref && ref.focus()}\n InputProps={{\n ...(filterInput.length && {\n endAdornment: (\n <IconButton\n aria-label={t('featureFlags.clearFilter')}\n onClick={clearFilterInput}\n edge=\"end\"\n >\n <ClearIcon />\n </IconButton>\n ),\n }),\n }}\n onChange={e => setFilterInput(e.target.value)}\n value={filterInput}\n />\n </Grid>\n )}\n </Grid>\n );\n\n return (\n <InfoCard title={<Header />}>\n <List dense>\n {filteredFeatureFlags.map(featureFlag => {\n const enabled = Boolean(state[featureFlag.name]);\n\n return (\n <FlagItem\n key={featureFlag.name}\n flag={featureFlag}\n enabled={enabled}\n toggleHandler={toggleFlag}\n />\n );\n })}\n </List>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAoCa,MAAA,SAAA,GAAY,CACvB,KAAA,EACA,eACkB,KAAA;AAClB,EAAM,MAAA,WAAA,GAAc,MAAM,MAAO,CAAA,CAAA,IAAA,KAAQ,gBAAgB,QAAS,CAAA,IAAA,CAAK,IAAI,CAAC,CAAA;AAC5E,EAAM,MAAA,SAAA,GAAY,MAAM,MAAO,CAAA,CAAA,IAAA,KAAQ,CAAC,eAAgB,CAAA,QAAA,CAAS,IAAK,CAAA,IAAI,CAAC,CAAA;AAC3E,EAAA,OAAO,CAAC,GAAG,WAAa,EAAA,GAAG,SAAS,CAAA;AACtC;AAGO,MAAM,2BAA2B,MAAM;AAC5C,EAA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AA,MAAA,EAAQ,gBAAgB,UAAW,EAAA;AAAA,QACrD,QAAU,EAAA,CAAA,GAAA,KAAO,GAAO,IAAA,GAAA,CAAI,KAAM,EAAA;AAAA,QAClC,UAAY,EAAA;AAAA,UACV,GAAI,YAAY,MAAU,IAAA;AAAA,YACxB,YACE,kBAAA,GAAA;AAAA,cAAC,UAAA;AAAA,cAAA;AAAA,gBACC,YAAA,EAAY,EAAE,0BAA0B,CAAA;AAAA,gBACxC,OAAS,EAAA,gBAAA;AAAA,gBACT,IAAK,EAAA,KAAA;AAAA,gBAEL,8BAAC,SAAU,EAAA,EAAA;AAAA;AAAA;AACb;AAEJ,SACF;AAAA,QACA,QAAU,EAAA,CAAA,CAAA,KAAK,cAAe,CAAA,CAAA,CAAE,OAAO,KAAK,CAAA;AAAA,QAC5C,KAAO,EAAA;AAAA;AAAA,KAEX,EAAA;AAAA,GAEJ,EAAA,CAAA;AAGF,EAAA,uBACG,GAAA,CAAA,QAAA,EAAA,EAAS,KAAO,kBAAA,GAAA,CAAC,MAAO,EAAA,EAAA,CAAA,EACvB,QAAC,kBAAA,GAAA,CAAA,IAAA,EAAA,EAAK,KAAK,EAAA,IAAA,EACR,QAAqB,EAAA,oBAAA,CAAA,GAAA,CAAI,CAAe,WAAA,KAAA;AACvC,IAAA,MAAM,OAAU,GAAA,OAAA,CAAQ,KAAM,CAAA,WAAA,CAAY,IAAI,CAAC,CAAA;AAE/C,IACE,uBAAA,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QAEC,IAAM,EAAA,WAAA;AAAA,QACN,OAAA;AAAA,QACA,aAAe,EAAA;AAAA,OAAA;AAAA,MAHV,WAAY,CAAA;AAAA,KAInB;AAAA,GAEH,GACH,CACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -4,26 +4,34 @@ import { EntityRefLinks } from '@backstage/plugin-catalog-react';
|
|
|
4
4
|
import Grid from '@material-ui/core/Grid';
|
|
5
5
|
import Typography from '@material-ui/core/Typography';
|
|
6
6
|
import { useUserProfile } from '../useUserProfileInfo.esm.js';
|
|
7
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
8
|
+
import { userSettingsTranslationRef } from '../../translation.esm.js';
|
|
7
9
|
|
|
8
10
|
const Contents = () => {
|
|
9
11
|
const { backstageIdentity } = useUserProfile();
|
|
12
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
10
13
|
if (!backstageIdentity) {
|
|
11
|
-
return /* @__PURE__ */ jsx(Typography, { children: "
|
|
14
|
+
return /* @__PURE__ */ jsx(Typography, { children: t("identityCard.noIdentityTitle") });
|
|
12
15
|
}
|
|
13
16
|
return /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 1, children: [
|
|
14
17
|
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", gutterBottom: true, children: [
|
|
15
|
-
"
|
|
18
|
+
t("identityCard.userEntity"),
|
|
19
|
+
":",
|
|
16
20
|
" ",
|
|
17
21
|
/* @__PURE__ */ jsx(EntityRefLinks, { entityRefs: [backstageIdentity.userEntityRef] })
|
|
18
22
|
] }) }),
|
|
19
23
|
/* @__PURE__ */ jsx(Grid, { item: true, xs: 12, children: /* @__PURE__ */ jsxs(Typography, { variant: "subtitle1", children: [
|
|
20
|
-
"
|
|
24
|
+
t("identityCard.ownershipEntities"),
|
|
25
|
+
":",
|
|
21
26
|
" ",
|
|
22
27
|
/* @__PURE__ */ jsx(EntityRefLinks, { entityRefs: backstageIdentity.ownershipEntityRefs })
|
|
23
28
|
] }) })
|
|
24
29
|
] });
|
|
25
30
|
};
|
|
26
|
-
const UserSettingsIdentityCard = () =>
|
|
31
|
+
const UserSettingsIdentityCard = () => {
|
|
32
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
33
|
+
return /* @__PURE__ */ jsx(InfoCard, { title: t("identityCard.title"), children: /* @__PURE__ */ jsx(Contents, {}) });
|
|
34
|
+
};
|
|
27
35
|
|
|
28
36
|
export { UserSettingsIdentityCard };
|
|
29
37
|
//# sourceMappingURL=UserSettingsIdentityCard.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsIdentityCard.esm.js","sources":["../../../src/components/General/UserSettingsIdentityCard.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { InfoCard } from '@backstage/core-components';\nimport { EntityRefLinks } from '@backstage/plugin-catalog-react';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { useUserProfile } from '../useUserProfileInfo';\n\nconst Contents = () => {\n const { backstageIdentity } = useUserProfile();\n\n if (!backstageIdentity) {\n return <Typography>
|
|
1
|
+
{"version":3,"file":"UserSettingsIdentityCard.esm.js","sources":["../../../src/components/General/UserSettingsIdentityCard.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { InfoCard } from '@backstage/core-components';\nimport { EntityRefLinks } from '@backstage/plugin-catalog-react';\nimport Grid from '@material-ui/core/Grid';\nimport Typography from '@material-ui/core/Typography';\nimport { useUserProfile } from '../useUserProfileInfo';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { userSettingsTranslationRef } from '../../translation';\n\nconst Contents = () => {\n const { backstageIdentity } = useUserProfile();\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n if (!backstageIdentity) {\n return <Typography>{t('identityCard.noIdentityTitle')}</Typography>;\n }\n\n return (\n <Grid container spacing={1}>\n <Grid item xs={12}>\n <Typography variant=\"subtitle1\" gutterBottom>\n {t('identityCard.userEntity')}:{' '}\n <EntityRefLinks entityRefs={[backstageIdentity.userEntityRef]} />\n </Typography>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"subtitle1\">\n {t('identityCard.ownershipEntities')}:{' '}\n <EntityRefLinks entityRefs={backstageIdentity.ownershipEntityRefs} />\n </Typography>\n </Grid>\n </Grid>\n );\n};\n\n/** @public */\nexport const UserSettingsIdentityCard = () => {\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n return (\n <InfoCard title={t('identityCard.title')}>\n <Contents />\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAwBA,MAAM,WAAW,MAAM;AACrB,EAAM,MAAA,EAAE,iBAAkB,EAAA,GAAI,cAAe,EAAA;AAC7C,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA;AAE1D,EAAA,IAAI,CAAC,iBAAmB,EAAA;AACtB,IAAA,uBAAQ,GAAA,CAAA,UAAA,EAAA,EAAY,QAAE,EAAA,CAAA,CAAA,8BAA8B,CAAE,EAAA,CAAA;AAAA;AAGxD,EAAA,uBACG,IAAA,CAAA,IAAA,EAAA,EAAK,SAAS,EAAA,IAAA,EAAC,SAAS,CACvB,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,IAAA,EAAA,EAAK,IAAI,EAAA,IAAA,EAAC,EAAI,EAAA,EAAA,EACb,+BAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,WAAY,EAAA,YAAA,EAAY,IACzC,EAAA,QAAA,EAAA;AAAA,MAAA,CAAA,CAAE,yBAAyB,CAAA;AAAA,MAAE,GAAA;AAAA,MAAE,GAAA;AAAA,0BAC/B,cAAe,EAAA,EAAA,UAAA,EAAY,CAAC,iBAAA,CAAkB,aAAa,CAAG,EAAA;AAAA,KAAA,EACjE,CACF,EAAA,CAAA;AAAA,oBACA,GAAA,CAAC,QAAK,IAAI,EAAA,IAAA,EAAC,IAAI,EACb,EAAA,QAAA,kBAAA,IAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,WACjB,EAAA,QAAA,EAAA;AAAA,MAAA,CAAA,CAAE,gCAAgC,CAAA;AAAA,MAAE,GAAA;AAAA,MAAE,GAAA;AAAA,sBACtC,GAAA,CAAA,cAAA,EAAA,EAAe,UAAY,EAAA,iBAAA,CAAkB,mBAAqB,EAAA;AAAA,KAAA,EACrE,CACF,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ,CAAA;AAGO,MAAM,2BAA2B,MAAM;AAC5C,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA;AAE1D,EACE,uBAAA,GAAA,CAAC,YAAS,KAAO,EAAA,CAAA,CAAE,oBAAoB,CACrC,EAAA,QAAA,kBAAA,GAAA,CAAC,YAAS,CACZ,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -42,6 +42,7 @@ const useStyles = makeStyles((theme) => ({
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
}));
|
|
45
|
+
const capitalize = (s) => s.charAt(0).toLocaleUpperCase("en-US") + s.slice(1);
|
|
45
46
|
const UserSettingsLanguageToggle = () => {
|
|
46
47
|
const classes = useStyles();
|
|
47
48
|
const languageApi = useApi(appLanguageApiRef);
|
|
@@ -63,7 +64,8 @@ const UserSettingsLanguageToggle = () => {
|
|
|
63
64
|
const names = new Intl.DisplayNames([language], {
|
|
64
65
|
type: "language"
|
|
65
66
|
});
|
|
66
|
-
|
|
67
|
+
const languageDisplayName = names.of(language);
|
|
68
|
+
return languageDisplayName ? capitalize(languageDisplayName) : language;
|
|
67
69
|
} catch (err) {
|
|
68
70
|
return language;
|
|
69
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsLanguageToggle.esm.js","sources":["../../../src/components/General/UserSettingsLanguageToggle.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useState } from 'react';\nimport {\n useTranslationRef,\n appLanguageApiRef,\n} from '@backstage/core-plugin-api/alpha';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { userSettingsTranslationRef } from '../../translation';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useObservable from 'react-use/esm/useObservable';\nimport { Select } from '@backstage/core-components';\n\nconst useStyles = makeStyles(theme => ({\n container: {\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n justifyContent: 'space-between',\n alignItems: 'center',\n paddingBottom: 8,\n paddingRight: 16,\n },\n list: {\n width: 'initial',\n [theme.breakpoints.down('xs')]: {\n width: '100%',\n padding: `0 0 12px`,\n },\n },\n listItemText: {\n paddingRight: 0,\n paddingLeft: 0,\n },\n listItemSecondaryAction: {\n position: 'relative',\n transform: 'unset',\n top: 'auto',\n right: 'auto',\n paddingLeft: 16,\n [theme.breakpoints.down('xs')]: {\n paddingLeft: 0,\n },\n },\n}));\n\n/** @public */\nexport const UserSettingsLanguageToggle = () => {\n const classes = useStyles();\n const languageApi = useApi(appLanguageApiRef);\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n const [languageObservable] = useState(() => languageApi.language$());\n const { language: currentLanguage } = useObservable(\n languageObservable,\n languageApi.getLanguage(),\n );\n\n const { languages } = languageApi.getAvailableLanguages();\n\n if (languages.length <= 1) {\n return null;\n }\n\n const handleSetLanguage = (newLanguage: string | undefined) => {\n languageApi.setLanguage(newLanguage);\n };\n\n const getLanguageDisplayName = (language: string) => {\n try {\n const names = new Intl.DisplayNames([language], {\n type: 'language',\n });\n
|
|
1
|
+
{"version":3,"file":"UserSettingsLanguageToggle.esm.js","sources":["../../../src/components/General/UserSettingsLanguageToggle.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useState } from 'react';\nimport {\n useTranslationRef,\n appLanguageApiRef,\n} from '@backstage/core-plugin-api/alpha';\nimport ListItem from '@material-ui/core/ListItem';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { userSettingsTranslationRef } from '../../translation';\nimport { useApi } from '@backstage/core-plugin-api';\nimport useObservable from 'react-use/esm/useObservable';\nimport { Select } from '@backstage/core-components';\n\nconst useStyles = makeStyles(theme => ({\n container: {\n display: 'flex',\n flexWrap: 'wrap',\n width: '100%',\n justifyContent: 'space-between',\n alignItems: 'center',\n paddingBottom: 8,\n paddingRight: 16,\n },\n list: {\n width: 'initial',\n [theme.breakpoints.down('xs')]: {\n width: '100%',\n padding: `0 0 12px`,\n },\n },\n listItemText: {\n paddingRight: 0,\n paddingLeft: 0,\n },\n listItemSecondaryAction: {\n position: 'relative',\n transform: 'unset',\n top: 'auto',\n right: 'auto',\n paddingLeft: 16,\n [theme.breakpoints.down('xs')]: {\n paddingLeft: 0,\n },\n },\n}));\n\nconst capitalize = (s: string) =>\n s.charAt(0).toLocaleUpperCase('en-US') + s.slice(1);\n\n/** @public */\nexport const UserSettingsLanguageToggle = () => {\n const classes = useStyles();\n const languageApi = useApi(appLanguageApiRef);\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n const [languageObservable] = useState(() => languageApi.language$());\n const { language: currentLanguage } = useObservable(\n languageObservable,\n languageApi.getLanguage(),\n );\n\n const { languages } = languageApi.getAvailableLanguages();\n\n if (languages.length <= 1) {\n return null;\n }\n\n const handleSetLanguage = (newLanguage: string | undefined) => {\n languageApi.setLanguage(newLanguage);\n };\n\n const getLanguageDisplayName = (language: string) => {\n try {\n const names = new Intl.DisplayNames([language], {\n type: 'language',\n });\n const languageDisplayName = names.of(language);\n return languageDisplayName ? capitalize(languageDisplayName) : language;\n } catch (err) {\n return language;\n }\n };\n\n return (\n <ListItem\n className={classes.list}\n classes={{ container: classes.container }}\n >\n <ListItemText\n className={classes.listItemText}\n primary={t('languageToggle.title')}\n secondary={t('languageToggle.description')}\n />\n <ListItemSecondaryAction className={classes.listItemSecondaryAction}>\n <Select\n label=\"\"\n selected={currentLanguage}\n items={languages.map(language => ({\n label: getLanguageDisplayName(language),\n value: language,\n }))}\n onChange={selectedItems => handleSetLanguage(selectedItems as string)}\n />\n </ListItemSecondaryAction>\n </ListItem>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA8BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,SAAW,EAAA;AAAA,IACT,OAAS,EAAA,MAAA;AAAA,IACT,QAAU,EAAA,MAAA;AAAA,IACV,KAAO,EAAA,MAAA;AAAA,IACP,cAAgB,EAAA,eAAA;AAAA,IAChB,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GAAA,CAAI,CAAa,QAAA,MAAA;AAAA,cAChC,KAAA,EAAO,uBAAuB,QAAQ,CAAA;AAAA,cACtC,KAAO,EAAA;AAAA,aACP,CAAA,CAAA;AAAA,YACF,QAAA,EAAU,CAAiB,aAAA,KAAA,iBAAA,CAAkB,aAAuB;AAAA;AAAA,SAExE,EAAA;AAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -7,12 +7,15 @@ import MenuItem from '@material-ui/core/MenuItem';
|
|
|
7
7
|
import SignOutIcon from '@material-ui/icons/MeetingRoom';
|
|
8
8
|
import MoreVertIcon from '@material-ui/icons/MoreVert';
|
|
9
9
|
import { useApi, errorApiRef, identityApiRef } from '@backstage/core-plugin-api';
|
|
10
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
11
|
+
import { userSettingsTranslationRef } from '../../translation.esm.js';
|
|
10
12
|
|
|
11
13
|
const UserSettingsMenu = () => {
|
|
12
14
|
const errorApi = useApi(errorApiRef);
|
|
13
15
|
const identityApi = useApi(identityApiRef);
|
|
14
16
|
const [open, setOpen] = useState(false);
|
|
15
17
|
const [anchorEl, setAnchorEl] = useState(void 0);
|
|
18
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
16
19
|
const handleOpen = (event) => {
|
|
17
20
|
setAnchorEl(event.currentTarget);
|
|
18
21
|
setOpen(true);
|
|
@@ -26,7 +29,7 @@ const UserSettingsMenu = () => {
|
|
|
26
29
|
IconButton,
|
|
27
30
|
{
|
|
28
31
|
"data-testid": "user-settings-menu",
|
|
29
|
-
"aria-label": "
|
|
32
|
+
"aria-label": t("signOutMenu.moreIconTitle"),
|
|
30
33
|
onClick: handleOpen,
|
|
31
34
|
children: /* @__PURE__ */ jsx(MoreVertIcon, {})
|
|
32
35
|
}
|
|
@@ -38,7 +41,7 @@ const UserSettingsMenu = () => {
|
|
|
38
41
|
onClick: () => identityApi.signOut().catch((error) => errorApi.post(error)),
|
|
39
42
|
children: [
|
|
40
43
|
/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(SignOutIcon, {}) }),
|
|
41
|
-
"
|
|
44
|
+
t("signOutMenu.title")
|
|
42
45
|
]
|
|
43
46
|
}
|
|
44
47
|
) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsMenu.esm.js","sources":["../../../src/components/General/UserSettingsMenu.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { MouseEvent, useState } from 'react';\nimport IconButton from '@material-ui/core/IconButton';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport Menu from '@material-ui/core/Menu';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport SignOutIcon from '@material-ui/icons/MeetingRoom';\nimport MoreVertIcon from '@material-ui/icons/MoreVert';\nimport {\n identityApiRef,\n errorApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\n\n/** @public */\nexport const UserSettingsMenu = () => {\n const errorApi = useApi(errorApiRef);\n const identityApi = useApi(identityApiRef);\n const [open, setOpen] = useState(false);\n const [anchorEl, setAnchorEl] = useState<undefined | HTMLElement>(undefined);\n\n const handleOpen = (event: MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n setOpen(true);\n };\n\n const handleClose = () => {\n setAnchorEl(undefined);\n setOpen(false);\n };\n\n return (\n <>\n <IconButton\n data-testid=\"user-settings-menu\"\n aria-label
|
|
1
|
+
{"version":3,"file":"UserSettingsMenu.esm.js","sources":["../../../src/components/General/UserSettingsMenu.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { MouseEvent, useState } from 'react';\nimport IconButton from '@material-ui/core/IconButton';\nimport ListItemIcon from '@material-ui/core/ListItemIcon';\nimport Menu from '@material-ui/core/Menu';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport SignOutIcon from '@material-ui/icons/MeetingRoom';\nimport MoreVertIcon from '@material-ui/icons/MoreVert';\nimport {\n identityApiRef,\n errorApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { userSettingsTranslationRef } from '../../translation';\n\n/** @public */\nexport const UserSettingsMenu = () => {\n const errorApi = useApi(errorApiRef);\n const identityApi = useApi(identityApiRef);\n const [open, setOpen] = useState(false);\n const [anchorEl, setAnchorEl] = useState<undefined | HTMLElement>(undefined);\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n const handleOpen = (event: MouseEvent<HTMLButtonElement>) => {\n setAnchorEl(event.currentTarget);\n setOpen(true);\n };\n\n const handleClose = () => {\n setAnchorEl(undefined);\n setOpen(false);\n };\n\n return (\n <>\n <IconButton\n data-testid=\"user-settings-menu\"\n aria-label={t('signOutMenu.moreIconTitle')}\n onClick={handleOpen}\n >\n <MoreVertIcon />\n </IconButton>\n <Menu anchorEl={anchorEl} open={open} onClose={handleClose}>\n <MenuItem\n data-testid=\"sign-out\"\n onClick={() =>\n identityApi.signOut().catch(error => errorApi.post(error))\n }\n >\n <ListItemIcon>\n <SignOutIcon />\n </ListItemIcon>\n {t('signOutMenu.title')}\n </MenuItem>\n </Menu>\n </>\n );\n};\n"],"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AC,GAAA,CAAA,YAAA,EAAA,EACC,QAAC,kBAAA,GAAA,CAAA,WAAA,EAAA,EAAY,CACf,EAAA,CAAA;AAAA,UACC,EAAE,mBAAmB;AAAA;AAAA;AAAA,KAE1B,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -5,15 +5,18 @@ import ListItemText from '@material-ui/core/ListItemText';
|
|
|
5
5
|
import Switch from '@material-ui/core/Switch';
|
|
6
6
|
import Tooltip from '@material-ui/core/Tooltip';
|
|
7
7
|
import { useSidebarPinState } from '@backstage/core-components';
|
|
8
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
9
|
+
import { userSettingsTranslationRef } from '../../translation.esm.js';
|
|
8
10
|
|
|
9
11
|
const UserSettingsPinToggle = () => {
|
|
10
12
|
const { isPinned, toggleSidebarPinState } = useSidebarPinState();
|
|
13
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
11
14
|
return /* @__PURE__ */ jsxs(ListItem, { children: [
|
|
12
15
|
/* @__PURE__ */ jsx(
|
|
13
16
|
ListItemText,
|
|
14
17
|
{
|
|
15
|
-
primary: "
|
|
16
|
-
secondary: "
|
|
18
|
+
primary: t("pinToggle.title"),
|
|
19
|
+
secondary: t("pinToggle.description")
|
|
17
20
|
}
|
|
18
21
|
),
|
|
19
22
|
/* @__PURE__ */ jsx(ListItemSecondaryAction, { children: /* @__PURE__ */ jsx(
|
|
@@ -21,7 +24,7 @@ const UserSettingsPinToggle = () => {
|
|
|
21
24
|
{
|
|
22
25
|
placement: "top",
|
|
23
26
|
arrow: true,
|
|
24
|
-
title:
|
|
27
|
+
title: isPinned ? t("pinToggle.switchTitles.unpin") : t("pinToggle.switchTitles.pin"),
|
|
25
28
|
children: /* @__PURE__ */ jsx(
|
|
26
29
|
Switch,
|
|
27
30
|
{
|
|
@@ -29,7 +32,7 @@ const UserSettingsPinToggle = () => {
|
|
|
29
32
|
checked: isPinned,
|
|
30
33
|
onChange: () => toggleSidebarPinState(),
|
|
31
34
|
name: "pin",
|
|
32
|
-
inputProps: { "aria-label": "
|
|
35
|
+
inputProps: { "aria-label": t("pinToggle.ariaLabelTitle") }
|
|
33
36
|
}
|
|
34
37
|
)
|
|
35
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsPinToggle.esm.js","sources":["../../../src/components/General/UserSettingsPinToggle.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 ListItem from '@material-ui/core/ListItem';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Switch from '@material-ui/core/Switch';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { useSidebarPinState } from '@backstage/core-components';\n\n/** @public */\nexport const UserSettingsPinToggle = () => {\n const { isPinned, toggleSidebarPinState } = useSidebarPinState();\n\n return (\n <ListItem>\n <ListItemText\n primary
|
|
1
|
+
{"version":3,"file":"UserSettingsPinToggle.esm.js","sources":["../../../src/components/General/UserSettingsPinToggle.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 ListItem from '@material-ui/core/ListItem';\nimport ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';\nimport ListItemText from '@material-ui/core/ListItemText';\nimport Switch from '@material-ui/core/Switch';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport { useSidebarPinState } from '@backstage/core-components';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { userSettingsTranslationRef } from '../../translation';\n\n/** @public */\nexport const UserSettingsPinToggle = () => {\n const { isPinned, toggleSidebarPinState } = useSidebarPinState();\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n return (\n <ListItem>\n <ListItemText\n primary={t('pinToggle.title')}\n secondary={t('pinToggle.description')}\n />\n <ListItemSecondaryAction>\n <Tooltip\n placement=\"top\"\n arrow\n title={\n isPinned\n ? t('pinToggle.switchTitles.unpin')\n : t('pinToggle.switchTitles.pin')\n }\n >\n <Switch\n color=\"primary\"\n checked={isPinned}\n onChange={() => toggleSidebarPinState()}\n name=\"pin\"\n inputProps={{ 'aria-label': t('pinToggle.ariaLabelTitle') }}\n />\n </Tooltip>\n </ListItemSecondaryAction>\n </ListItem>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA0BO,MAAM,wBAAwB,MAAM;AACzC,EAAA,MAAM,EAAE,QAAA,EAAU,qBAAsB,EAAA,GAAI,kBAAmB,EAAA;AAC/D,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA;AAE1D,EAAA,4BACG,QACC,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,OAAA,EAAS,EAAE,iBAAiB,CAAA;AAAA,QAC5B,SAAA,EAAW,EAAE,uBAAuB;AAAA;AAAA,KACtC;AAAA,wBACC,uBACC,EAAA,EAAA,QAAA,kBAAA,GAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,SAAU,EAAA,KAAA;AAAA,QACV,KAAK,EAAA,IAAA;AAAA,QACL,OACE,QACI,GAAA,CAAA,CAAE,8BAA8B,CAAA,GAChC,EAAE,4BAA4B,CAAA;AAAA,QAGpC,QAAA,kBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,KAAM,EAAA,SAAA;AAAA,YACN,OAAS,EAAA,QAAA;AAAA,YACT,QAAA,EAAU,MAAM,qBAAsB,EAAA;AAAA,YACtC,IAAK,EAAA,KAAA;AAAA,YACL,UAAY,EAAA,EAAE,YAAc,EAAA,CAAA,CAAE,0BAA0B,CAAE;AAAA;AAAA;AAC5D;AAAA,KAEJ,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -3,11 +3,14 @@ import SettingsIcon from '@material-ui/icons/Settings';
|
|
|
3
3
|
import { settingsRouteRef } from '../plugin.esm.js';
|
|
4
4
|
import { SidebarItem } from '@backstage/core-components';
|
|
5
5
|
import { useRouteRef } from '@backstage/core-plugin-api';
|
|
6
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
7
|
+
import { userSettingsTranslationRef } from '../translation.esm.js';
|
|
6
8
|
|
|
7
9
|
const Settings = (props) => {
|
|
8
10
|
const routePath = useRouteRef(settingsRouteRef);
|
|
9
11
|
const Icon = props.icon ? props.icon : SettingsIcon;
|
|
10
|
-
|
|
12
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
13
|
+
return /* @__PURE__ */ jsx(SidebarItem, { text: t("sidebarTitle"), to: routePath(), icon: Icon });
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
export { Settings };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.esm.js","sources":["../../src/components/Settings.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 SettingsIcon from '@material-ui/icons/Settings';\nimport { settingsRouteRef } from '../plugin';\nimport { SidebarItem } from '@backstage/core-components';\nimport { useRouteRef, IconComponent } from '@backstage/core-plugin-api';\n\n/** @public */\nexport const Settings = (props: { icon?: IconComponent }) => {\n const routePath = useRouteRef(settingsRouteRef);\n const Icon = props.icon ? props.icon : SettingsIcon;\n return <SidebarItem text
|
|
1
|
+
{"version":3,"file":"Settings.esm.js","sources":["../../src/components/Settings.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 SettingsIcon from '@material-ui/icons/Settings';\nimport { settingsRouteRef } from '../plugin';\nimport { SidebarItem } from '@backstage/core-components';\nimport { useRouteRef, IconComponent } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { userSettingsTranslationRef } from '../translation';\n\n/** @public */\nexport const Settings = (props: { icon?: IconComponent }) => {\n const routePath = useRouteRef(settingsRouteRef);\n const Icon = props.icon ? props.icon : SettingsIcon;\n const { t } = useTranslationRef(userSettingsTranslationRef);\n return <SidebarItem text={t('sidebarTitle')} to={routePath()} icon={Icon} />;\n};\n"],"names":[],"mappings":";;;;;;;;AAwBa,MAAA,QAAA,GAAW,CAAC,KAAoC,KAAA;AAC3D,EAAM,MAAA,SAAA,GAAY,YAAY,gBAAgB,CAAA;AAC9C,EAAA,MAAM,IAAO,GAAA,KAAA,CAAM,IAAO,GAAA,KAAA,CAAM,IAAO,GAAA,YAAA;AACvC,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA;AAC1D,EAAO,uBAAA,GAAA,CAAC,WAAY,EAAA,EAAA,IAAA,EAAM,CAAE,CAAA,cAAc,GAAG,EAAI,EAAA,SAAA,EAAa,EAAA,IAAA,EAAM,IAAM,EAAA,CAAA;AAC5E;;;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useSidebarPinState, Page, Header, RoutedTabs } from '@backstage/core-components';
|
|
3
3
|
import { attachComponentData, useElementFilter } from '@backstage/core-plugin-api';
|
|
4
|
+
import { useTranslationRef } from '@backstage/frontend-plugin-api';
|
|
5
|
+
import { userSettingsTranslationRef } from '../../translation.esm.js';
|
|
4
6
|
|
|
5
7
|
const LAYOUT_DATA_KEY = "plugin.user-settings.settingsLayout";
|
|
6
8
|
const LAYOUT_ROUTE_DATA_KEY = "plugin.user-settings.settingsLayoutRoute";
|
|
@@ -10,6 +12,7 @@ attachComponentData(Route, "core.gatherMountPoints", true);
|
|
|
10
12
|
const SettingsLayout = (props) => {
|
|
11
13
|
const { title, children } = props;
|
|
12
14
|
const { isMobile } = useSidebarPinState();
|
|
15
|
+
const { t } = useTranslationRef(userSettingsTranslationRef);
|
|
13
16
|
const routes = useElementFilter(
|
|
14
17
|
children,
|
|
15
18
|
(elements) => elements.selectByComponentData({
|
|
@@ -18,7 +21,7 @@ const SettingsLayout = (props) => {
|
|
|
18
21
|
}).getElements().map((child) => child.props)
|
|
19
22
|
);
|
|
20
23
|
return /* @__PURE__ */ jsxs(Page, { themeId: "home", children: [
|
|
21
|
-
!isMobile && /* @__PURE__ */ jsx(Header, { title: title ?? "
|
|
24
|
+
!isMobile && /* @__PURE__ */ jsx(Header, { title: title ?? t("settingsLayout.title") }),
|
|
22
25
|
/* @__PURE__ */ jsx(RoutedTabs, { routes })
|
|
23
26
|
] });
|
|
24
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsLayout.esm.js","sources":["../../../src/components/SettingsLayout/SettingsLayout.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { ElementType, ReactNode } from 'react';\nimport { TabProps } from '@material-ui/core/Tab';\nimport {\n Header,\n Page,\n RoutedTabs,\n useSidebarPinState,\n} from '@backstage/core-components';\nimport {\n attachComponentData,\n useElementFilter,\n} from '@backstage/core-plugin-api';\n\n/** @public */\nexport type SettingsLayoutRouteProps = {\n path: string;\n title: string;\n children: JSX.Element;\n tabProps?: TabProps<ElementType, { component?: ElementType }>;\n};\n\nexport const LAYOUT_DATA_KEY = 'plugin.user-settings.settingsLayout';\nexport const LAYOUT_ROUTE_DATA_KEY = 'plugin.user-settings.settingsLayoutRoute';\n\nconst Route: (props: SettingsLayoutRouteProps) => null = () => null;\nattachComponentData(Route, LAYOUT_ROUTE_DATA_KEY, true);\n\n// This causes all mount points that are discovered within this route to use the path of the route itself\nattachComponentData(Route, 'core.gatherMountPoints', true);\n\n/** @public */\nexport type SettingsLayoutProps = {\n title?: string;\n subtitle?: string;\n children?: ReactNode;\n};\n\n/**\n * @public\n */\nexport const SettingsLayout = (props: SettingsLayoutProps) => {\n const { title, children } = props;\n const { isMobile } = useSidebarPinState();\n\n const routes = useElementFilter(children, elements =>\n elements\n .selectByComponentData({\n key: LAYOUT_ROUTE_DATA_KEY,\n withStrictError:\n 'Child of SettingsLayout must be an SettingsLayout.Route',\n })\n .getElements<SettingsLayoutRouteProps>()\n .map(child => child.props),\n );\n\n return (\n <Page themeId=\"home\">\n {!isMobile && <Header title={title ?? '
|
|
1
|
+
{"version":3,"file":"SettingsLayout.esm.js","sources":["../../../src/components/SettingsLayout/SettingsLayout.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { ElementType, ReactNode } from 'react';\nimport { TabProps } from '@material-ui/core/Tab';\nimport {\n Header,\n Page,\n RoutedTabs,\n useSidebarPinState,\n} from '@backstage/core-components';\nimport {\n attachComponentData,\n useElementFilter,\n} from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/frontend-plugin-api';\nimport { userSettingsTranslationRef } from '../../translation';\n\n/** @public */\nexport type SettingsLayoutRouteProps = {\n path: string;\n title: string;\n children: JSX.Element;\n tabProps?: TabProps<ElementType, { component?: ElementType }>;\n};\n\nexport const LAYOUT_DATA_KEY = 'plugin.user-settings.settingsLayout';\nexport const LAYOUT_ROUTE_DATA_KEY = 'plugin.user-settings.settingsLayoutRoute';\n\nconst Route: (props: SettingsLayoutRouteProps) => null = () => null;\nattachComponentData(Route, LAYOUT_ROUTE_DATA_KEY, true);\n\n// This causes all mount points that are discovered within this route to use the path of the route itself\nattachComponentData(Route, 'core.gatherMountPoints', true);\n\n/** @public */\nexport type SettingsLayoutProps = {\n title?: string;\n subtitle?: string;\n children?: ReactNode;\n};\n\n/**\n * @public\n */\nexport const SettingsLayout = (props: SettingsLayoutProps) => {\n const { title, children } = props;\n const { isMobile } = useSidebarPinState();\n const { t } = useTranslationRef(userSettingsTranslationRef);\n\n const routes = useElementFilter(children, elements =>\n elements\n .selectByComponentData({\n key: LAYOUT_ROUTE_DATA_KEY,\n withStrictError:\n 'Child of SettingsLayout must be an SettingsLayout.Route',\n })\n .getElements<SettingsLayoutRouteProps>()\n .map(child => child.props),\n );\n\n return (\n <Page themeId=\"home\">\n {!isMobile && <Header title={title ?? t('settingsLayout.title')} />}\n <RoutedTabs routes={routes} />\n </Page>\n );\n};\n\nattachComponentData(SettingsLayout, LAYOUT_DATA_KEY, true);\n\nSettingsLayout.Route = Route;\n"],"names":[],"mappings":";;;;;;AAuCO,MAAM,eAAkB,GAAA;AACxB,MAAM,qBAAwB,GAAA;AAErC,MAAM,QAAmD,MAAM,IAAA;AAC/D,mBAAoB,CAAA,KAAA,EAAO,uBAAuB,IAAI,CAAA;AAGtD,mBAAoB,CAAA,KAAA,EAAO,0BAA0B,IAAI,CAAA;AAY5C,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAM,MAAA,EAAE,KAAO,EAAA,QAAA,EAAa,GAAA,KAAA;AAC5B,EAAM,MAAA,EAAE,QAAS,EAAA,GAAI,kBAAmB,EAAA;AACxC,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,0BAA0B,CAAA;AAE1D,EAAA,MAAM,MAAS,GAAA,gBAAA;AAAA,IAAiB,QAAA;AAAA,IAAU,CAAA,QAAA,KACxC,SACG,qBAAsB,CAAA;AAAA,MACrB,GAAK,EAAA,qBAAA;AAAA,MACL,eACE,EAAA;AAAA,KACH,CACA,CAAA,WAAA,GACA,GAAI,CAAA,CAAA,KAAA,KAAS,MAAM,KAAK;AAAA,GAC7B;AAEA,EACE,uBAAA,IAAA,CAAC,IAAK,EAAA,EAAA,OAAA,EAAQ,MACX,EAAA,QAAA,EAAA;AAAA,IAAA,CAAC,4BAAa,GAAA,CAAA,MAAA,EAAA,EAAO,OAAO,KAAS,IAAA,CAAA,CAAE,sBAAsB,CAAG,EAAA,CAAA;AAAA,oBACjE,GAAA,CAAC,cAAW,MAAgB,EAAA;AAAA,GAC9B,EAAA,CAAA;AAEJ;AAEA,mBAAoB,CAAA,cAAA,EAAgB,iBAAiB,IAAI,CAAA;AAEzD,cAAA,CAAe,KAAQ,GAAA,KAAA;;;;"}
|