@backstage/plugin-catalog 1.33.0 → 1.33.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
CHANGED
|
@@ -38,8 +38,8 @@ function EntityTabsList(props) {
|
|
|
38
38
|
const styles = useStyles();
|
|
39
39
|
const { t } = useTranslationRef(catalogTranslationRef);
|
|
40
40
|
const { tabs: items, selectedIndex = 0, showIcons, groupDefinitions } = props;
|
|
41
|
-
const groups = useMemo(
|
|
42
|
-
|
|
41
|
+
const groups = useMemo(() => {
|
|
42
|
+
const byKey = items.reduce((result, tab) => {
|
|
43
43
|
const group = tab.group ? groupDefinitions[tab.group] : void 0;
|
|
44
44
|
const groupOrId = group && tab.group ? tab.group : tab.id;
|
|
45
45
|
result[groupOrId] = result[groupOrId] ?? {
|
|
@@ -48,9 +48,23 @@ function EntityTabsList(props) {
|
|
|
48
48
|
};
|
|
49
49
|
result[groupOrId].items.push(tab);
|
|
50
50
|
return result;
|
|
51
|
-
}, {})
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
}, {});
|
|
52
|
+
const groupOrder = Object.keys(groupDefinitions);
|
|
53
|
+
return Object.entries(byKey).sort(([a], [b]) => {
|
|
54
|
+
const ai = groupOrder.indexOf(a);
|
|
55
|
+
const bi = groupOrder.indexOf(b);
|
|
56
|
+
if (ai !== -1 && bi !== -1) {
|
|
57
|
+
return ai - bi;
|
|
58
|
+
}
|
|
59
|
+
if (ai !== -1) {
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
if (bi !== -1) {
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
return 0;
|
|
66
|
+
});
|
|
67
|
+
}, [items, groupDefinitions]);
|
|
54
68
|
const selectedItem = items[selectedIndex];
|
|
55
69
|
return /* @__PURE__ */ jsx(Box, { className: styles.tabsWrapper, children: /* @__PURE__ */ jsx(
|
|
56
70
|
Tabs,
|
|
@@ -62,7 +76,7 @@ function EntityTabsList(props) {
|
|
|
62
76
|
scrollButtons: "auto",
|
|
63
77
|
"aria-label": t("entityTabs.tabsAriaLabel"),
|
|
64
78
|
value: selectedItem?.group ?? selectedItem?.id,
|
|
65
|
-
children:
|
|
79
|
+
children: groups.map(([id, tabGroup]) => /* @__PURE__ */ jsx(
|
|
66
80
|
EntityTabsGroup,
|
|
67
81
|
{
|
|
68
82
|
"data-testid": `header-tab-${id}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityTabsList.esm.js","sources":["../../../../src/alpha/components/EntityTabs/EntityTabsList.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 { ReactElement, useMemo } from 'react';\nimport Box from '@material-ui/core/Box';\nimport Tabs from '@material-ui/core/Tabs';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { EntityContentGroupDefinitions } from '@backstage/plugin-catalog-react/alpha';\n\nimport { EntityTabsGroup } from './EntityTabsGroup';\nimport { catalogTranslationRef } from '../../translation';\n\n/** @public */\nexport type HeaderTabsClassKey =\n | 'tabsWrapper'\n | 'defaultTab'\n | 'selected'\n | 'tabRoot';\n\nconst useStyles = makeStyles(\n theme => ({\n tabsWrapper: {\n gridArea: 'pageSubheader',\n backgroundColor: theme.palette.background.paper,\n paddingLeft: theme.spacing(3),\n minWidth: 0,\n },\n defaultTab: {\n ...theme.typography.caption,\n padding: theme.spacing(3, 3),\n textTransform: 'uppercase',\n fontWeight: theme.typography.fontWeightBold,\n color: theme.palette.text.secondary,\n },\n selected: {\n color: theme.palette.text.primary,\n },\n tabRoot: {\n '&:hover': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n },\n }),\n { name: 'BackstageHeaderTabs' },\n);\n\ntype Tab = {\n id: string;\n label: string;\n path: string;\n group?: string;\n icon?: string | ReactElement;\n};\n\ntype TabGroup = {\n group?: {\n title: string;\n icon?: string | ReactElement;\n };\n items: Array<Omit<Tab, 'group'>>;\n};\n\ntype EntityTabsListProps = {\n tabs: Tab[];\n groupDefinitions: EntityContentGroupDefinitions;\n showIcons?: boolean;\n selectedIndex?: number;\n};\n\nexport function EntityTabsList(props: EntityTabsListProps) {\n const styles = useStyles();\n const { t } = useTranslationRef(catalogTranslationRef);\n\n const { tabs: items, selectedIndex = 0, showIcons, groupDefinitions } = props;\n\n const groups = useMemo(\n
|
|
1
|
+
{"version":3,"file":"EntityTabsList.esm.js","sources":["../../../../src/alpha/components/EntityTabs/EntityTabsList.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 { ReactElement, useMemo } from 'react';\nimport Box from '@material-ui/core/Box';\nimport Tabs from '@material-ui/core/Tabs';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { EntityContentGroupDefinitions } from '@backstage/plugin-catalog-react/alpha';\n\nimport { EntityTabsGroup } from './EntityTabsGroup';\nimport { catalogTranslationRef } from '../../translation';\n\n/** @public */\nexport type HeaderTabsClassKey =\n | 'tabsWrapper'\n | 'defaultTab'\n | 'selected'\n | 'tabRoot';\n\nconst useStyles = makeStyles(\n theme => ({\n tabsWrapper: {\n gridArea: 'pageSubheader',\n backgroundColor: theme.palette.background.paper,\n paddingLeft: theme.spacing(3),\n minWidth: 0,\n },\n defaultTab: {\n ...theme.typography.caption,\n padding: theme.spacing(3, 3),\n textTransform: 'uppercase',\n fontWeight: theme.typography.fontWeightBold,\n color: theme.palette.text.secondary,\n },\n selected: {\n color: theme.palette.text.primary,\n },\n tabRoot: {\n '&:hover': {\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n },\n },\n }),\n { name: 'BackstageHeaderTabs' },\n);\n\ntype Tab = {\n id: string;\n label: string;\n path: string;\n group?: string;\n icon?: string | ReactElement;\n};\n\ntype TabGroup = {\n group?: {\n title: string;\n icon?: string | ReactElement;\n };\n items: Array<Omit<Tab, 'group'>>;\n};\n\ntype EntityTabsListProps = {\n tabs: Tab[];\n groupDefinitions: EntityContentGroupDefinitions;\n showIcons?: boolean;\n selectedIndex?: number;\n};\n\nexport function EntityTabsList(props: EntityTabsListProps) {\n const styles = useStyles();\n const { t } = useTranslationRef(catalogTranslationRef);\n\n const { tabs: items, selectedIndex = 0, showIcons, groupDefinitions } = props;\n\n const groups = useMemo(() => {\n const byKey = items.reduce((result, tab) => {\n const group = tab.group ? groupDefinitions[tab.group] : undefined;\n const groupOrId = group && tab.group ? tab.group : tab.id;\n result[groupOrId] = result[groupOrId] ?? {\n group,\n items: [],\n };\n result[groupOrId].items.push(tab);\n return result;\n }, {} as Record<string, TabGroup>);\n\n const groupOrder = Object.keys(groupDefinitions);\n return Object.entries(byKey).sort(([a], [b]) => {\n const ai = groupOrder.indexOf(a);\n const bi = groupOrder.indexOf(b);\n if (ai !== -1 && bi !== -1) {\n return ai - bi;\n }\n if (ai !== -1) {\n return -1;\n }\n if (bi !== -1) {\n return 1;\n }\n return 0;\n });\n }, [items, groupDefinitions]);\n\n const selectedItem = items[selectedIndex];\n return (\n <Box className={styles.tabsWrapper}>\n <Tabs\n selectionFollowsFocus\n indicatorColor=\"primary\"\n textColor=\"inherit\"\n variant=\"scrollable\"\n scrollButtons=\"auto\"\n aria-label={t('entityTabs.tabsAriaLabel')}\n value={selectedItem?.group ?? selectedItem?.id}\n >\n {groups.map(([id, tabGroup]) => (\n <EntityTabsGroup\n data-testid={`header-tab-${id}`}\n className={styles.defaultTab}\n classes={{ selected: styles.selected, root: styles.tabRoot }}\n key={id}\n label={tabGroup.group?.title}\n icon={tabGroup.group?.icon}\n value={id}\n items={tabGroup.items}\n highlightedButton={selectedItem?.id}\n showIcons={showIcons}\n />\n ))}\n </Tabs>\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAiCA,MAAM,SAAA,GAAY,UAAA;AAAA,EAChB,CAAA,KAAA,MAAU;AAAA,IACR,WAAA,EAAa;AAAA,MACX,QAAA,EAAU,eAAA;AAAA,MACV,eAAA,EAAiB,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW,KAAA;AAAA,MAC1C,WAAA,EAAa,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA;AAAA,MAC5B,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,UAAA,EAAY;AAAA,MACV,GAAG,MAAM,UAAA,CAAW,OAAA;AAAA,MACpB,OAAA,EAAS,KAAA,CAAM,OAAA,CAAQ,CAAA,EAAG,CAAC,CAAA;AAAA,MAC3B,aAAA,EAAe,WAAA;AAAA,MACf,UAAA,EAAY,MAAM,UAAA,CAAW,cAAA;AAAA,MAC7B,KAAA,EAAO,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK;AAAA,KAC5B;AAAA,IACA,QAAA,EAAU;AAAA,MACR,KAAA,EAAO,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK;AAAA,KAC5B;AAAA,IACA,OAAA,EAAS;AAAA,MACP,SAAA,EAAW;AAAA,QACT,eAAA,EAAiB,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW,OAAA;AAAA,QAC1C,KAAA,EAAO,KAAA,CAAM,O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AAAA,UACP,OAAO,QAAA,CAAS,KAAA;AAAA,UAChB,mBAAmB,YAAA,EAAc,EAAA;AAAA,UACjC;AAAA,SAAA;AAAA,QANK;AAAA,OAQR;AAAA;AAAA,GACH,EACF,CAAA;AAEJ;;;;"}
|
package/dist/package.json.esm.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog",
|
|
3
|
-
"version": "1.33.
|
|
3
|
+
"version": "1.33.1",
|
|
4
4
|
"description": "The Backstage plugin for browsing the Backstage catalog",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin",
|
|
@@ -76,14 +76,14 @@
|
|
|
76
76
|
"@backstage/core-components": "^0.18.7",
|
|
77
77
|
"@backstage/core-plugin-api": "^1.12.3",
|
|
78
78
|
"@backstage/errors": "^1.2.7",
|
|
79
|
-
"@backstage/frontend-plugin-api": "^0.14.
|
|
79
|
+
"@backstage/frontend-plugin-api": "^0.14.1",
|
|
80
80
|
"@backstage/integration-react": "^1.2.15",
|
|
81
81
|
"@backstage/plugin-catalog-common": "^1.1.8",
|
|
82
82
|
"@backstage/plugin-catalog-react": "^2.0.0",
|
|
83
83
|
"@backstage/plugin-permission-react": "^0.4.40",
|
|
84
84
|
"@backstage/plugin-scaffolder-common": "^1.7.6",
|
|
85
85
|
"@backstage/plugin-search-common": "^1.2.22",
|
|
86
|
-
"@backstage/plugin-search-react": "^1.10.
|
|
86
|
+
"@backstage/plugin-search-react": "^1.10.4",
|
|
87
87
|
"@backstage/plugin-techdocs-common": "^0.1.1",
|
|
88
88
|
"@backstage/plugin-techdocs-react": "^1.3.8",
|
|
89
89
|
"@backstage/types": "^1.2.2",
|