@red-hat-developer-hub/backstage-plugin-quickstart 1.1.1 → 1.2.0
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 +11 -0
- package/config.d.ts +5 -0
- package/dist/components/QuickstartContent/QuickstartContent.esm.js +7 -1
- package/dist/components/QuickstartContent/QuickstartContent.esm.js.map +1 -1
- package/dist/components/QuickstartContent/QuickstartItemIcon.esm.js +9 -1
- package/dist/components/QuickstartContent/QuickstartItemIcon.esm.js.map +1 -1
- package/dist/components/QuickstartDrawer.esm.js +4 -1
- package/dist/components/QuickstartDrawer.esm.js.map +1 -1
- package/dist/utils/filterQuickstartItems.esm.js +9 -0
- package/dist/utils/filterQuickstartItems.esm.js.map +1 -0
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @red-hat-developer-hub/backstage-plugin-quickstart
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0e0f2f5: Backstage version bump to v1.41.2
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- f89f72f: Updated dependency `@mui/icons-material` to `5.18.0`.
|
|
12
|
+
Updated dependency `@mui/material` to `5.18.0`.
|
|
13
|
+
|
|
3
14
|
## 1.1.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/config.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ export interface Config {
|
|
|
29
29
|
* @visibility frontend
|
|
30
30
|
*/
|
|
31
31
|
title: string;
|
|
32
|
+
/**
|
|
33
|
+
* The roles associated with the quickstart.
|
|
34
|
+
* @visibility frontend
|
|
35
|
+
*/
|
|
36
|
+
roles?: Array<string>;
|
|
32
37
|
/**
|
|
33
38
|
* Optional icon for quickstart.
|
|
34
39
|
* @visibility frontend
|
|
@@ -33,7 +33,13 @@ const QuickstartContent = ({
|
|
|
33
33
|
setProgress: () => setProgress(index)
|
|
34
34
|
},
|
|
35
35
|
`${item.title}-${index}`
|
|
36
|
-
)) }) : /* @__PURE__ */ jsx(
|
|
36
|
+
)) }) : /* @__PURE__ */ jsx(
|
|
37
|
+
EmptyState,
|
|
38
|
+
{
|
|
39
|
+
title: "Quickstart content not available for your role.",
|
|
40
|
+
missing: "data"
|
|
41
|
+
}
|
|
42
|
+
)
|
|
37
43
|
}
|
|
38
44
|
);
|
|
39
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickstartContent.esm.js","sources":["../../../src/components/QuickstartContent/QuickstartContent.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 Box from '@mui/material/Box';\nimport List from '@mui/material/List';\nimport { QuickstartItem } from './QuickstartItem';\nimport { EmptyState } from '@backstage/core-components';\nimport { useState } from 'react';\nimport { QuickstartItemData } from '../../types';\n\ntype QuickstartContentProps = {\n quickstartItems: QuickstartItemData[];\n setProgress: (index: number) => void;\n itemCount: number;\n};\n\nexport const QuickstartContent = ({\n quickstartItems,\n setProgress,\n itemCount,\n}: QuickstartContentProps) => {\n const [openItems, setOpenItems] = useState<boolean[]>(\n new Array(itemCount).fill(false),\n );\n\n return (\n <Box\n sx={{\n paddingTop: theme => `${theme.spacing(3)}`,\n }}\n >\n {quickstartItems.length > 0 ? (\n <List disablePadding>\n {quickstartItems.map((item: QuickstartItemData, index: number) => (\n <QuickstartItem\n key={`${item.title}-${index}`}\n item={item}\n index={index}\n open={openItems[index]}\n handleOpen={() =>\n setOpenItems(oi => {\n return oi.map((val, valIndex) =>\n valIndex === index ? !val : false,\n );\n })\n }\n setProgress={() => setProgress(index)}\n />\n ))}\n </List>\n ) : (\n <EmptyState
|
|
1
|
+
{"version":3,"file":"QuickstartContent.esm.js","sources":["../../../src/components/QuickstartContent/QuickstartContent.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 Box from '@mui/material/Box';\nimport List from '@mui/material/List';\nimport { QuickstartItem } from './QuickstartItem';\nimport { EmptyState } from '@backstage/core-components';\nimport { useState } from 'react';\nimport { QuickstartItemData } from '../../types';\n\ntype QuickstartContentProps = {\n quickstartItems: QuickstartItemData[];\n setProgress: (index: number) => void;\n itemCount: number;\n};\n\nexport const QuickstartContent = ({\n quickstartItems,\n setProgress,\n itemCount,\n}: QuickstartContentProps) => {\n const [openItems, setOpenItems] = useState<boolean[]>(\n new Array(itemCount).fill(false),\n );\n\n return (\n <Box\n sx={{\n paddingTop: theme => `${theme.spacing(3)}`,\n }}\n >\n {quickstartItems.length > 0 ? (\n <List disablePadding>\n {quickstartItems.map((item: QuickstartItemData, index: number) => (\n <QuickstartItem\n key={`${item.title}-${index}`}\n item={item}\n index={index}\n open={openItems[index]}\n handleOpen={() =>\n setOpenItems(oi => {\n return oi.map((val, valIndex) =>\n valIndex === index ? !val : false,\n );\n })\n }\n setProgress={() => setProgress(index)}\n />\n ))}\n </List>\n ) : (\n <EmptyState\n title=\"Quickstart content not available for your role.\"\n missing=\"data\"\n />\n )}\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;A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10 @@ import AdminPanelSettingsOutlinedIcon from '@mui/icons-material/AdminPanelSettin
|
|
|
4
4
|
import VpnKeyOutlinedIcon from '@mui/icons-material/VpnKeyOutlined';
|
|
5
5
|
import FileCopyOutlinedIcon from '@mui/icons-material/FileCopyOutlined';
|
|
6
6
|
import PowerOutlinedIcon from '@mui/icons-material/PowerOutlined';
|
|
7
|
+
import LoginIcon from '@mui/icons-material/Login';
|
|
8
|
+
import CategoryOutlinedIcon from '@mui/icons-material/CategoryOutlined';
|
|
9
|
+
import ControlPointOutlinedIcon from '@mui/icons-material/ControlPointOutlined';
|
|
10
|
+
import SchoolOutlinedIcon from '@mui/icons-material/SchoolOutlined';
|
|
7
11
|
import { useApp } from '@backstage/core-plugin-api';
|
|
8
12
|
import Box from '@mui/material/Box';
|
|
9
13
|
|
|
@@ -11,7 +15,11 @@ const commonIcons = {
|
|
|
11
15
|
Admin: /* @__PURE__ */ jsx(AdminPanelSettingsOutlinedIcon, {}),
|
|
12
16
|
Rbac: /* @__PURE__ */ jsx(VpnKeyOutlinedIcon, {}),
|
|
13
17
|
Git: /* @__PURE__ */ jsx(FileCopyOutlinedIcon, {}),
|
|
14
|
-
Plugins: /* @__PURE__ */ jsx(PowerOutlinedIcon, {})
|
|
18
|
+
Plugins: /* @__PURE__ */ jsx(PowerOutlinedIcon, {}),
|
|
19
|
+
Import: /* @__PURE__ */ jsx(LoginIcon, {}),
|
|
20
|
+
Catalog: /* @__PURE__ */ jsx(CategoryOutlinedIcon, {}),
|
|
21
|
+
SelfService: /* @__PURE__ */ jsx(ControlPointOutlinedIcon, {}),
|
|
22
|
+
Learning: /* @__PURE__ */ jsx(SchoolOutlinedIcon, {})
|
|
15
23
|
};
|
|
16
24
|
const QuickstartItemIcon = ({ icon, sx }) => {
|
|
17
25
|
const app = useApp();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickstartItemIcon.esm.js","sources":["../../../src/components/QuickstartContent/QuickstartItemIcon.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 MuiIcon from '@mui/material/Icon';\nimport AdminPanelSettingsOutlinedIcon from '@mui/icons-material/AdminPanelSettingsOutlined';\nimport VpnKeyOutlinedIcon from '@mui/icons-material/VpnKeyOutlined';\nimport FileCopyOutlinedIcon from '@mui/icons-material/FileCopyOutlined';\nimport PowerOutlinedIcon from '@mui/icons-material/PowerOutlined';\nimport { SxProps, Theme } from '@mui/material/styles';\nimport { useApp } from '@backstage/core-plugin-api';\nimport Box from '@mui/material/Box';\n\nexport interface QuickstartItemIconProps {\n icon?: string;\n sx?: SxProps<Theme>;\n}\n\nconst commonIcons: {\n [k: string]: React.ReactNode;\n} = {\n Admin: <AdminPanelSettingsOutlinedIcon />,\n Rbac: <VpnKeyOutlinedIcon />,\n Git: <FileCopyOutlinedIcon />,\n Plugins: <PowerOutlinedIcon />,\n};\n\nexport const QuickstartItemIcon = ({ icon, sx }: QuickstartItemIconProps) => {\n const app = useApp();\n if (!icon) {\n return null;\n }\n\n const SystemIcon = app.getSystemIcon(icon);\n if (SystemIcon) {\n return (\n <Box sx={{ display: 'flex', alignItems: 'center', ...sx }}>\n <SystemIcon fontSize=\"medium\" />\n </Box>\n );\n }\n\n if (icon.startsWith('<svg')) {\n const svgDataUri = `data:image/svg+xml;base64,${btoa(icon)}`;\n return (\n <MuiIcon fontSize=\"medium\" sx={sx}>\n <img src={svgDataUri} alt=\"\" />\n </MuiIcon>\n );\n }\n\n if (\n icon.startsWith('https://') ||\n icon.startsWith('http://') ||\n icon.startsWith('/')\n ) {\n return (\n <MuiIcon\n fontSize=\"medium\"\n baseClassName=\"material-icons-outlined\"\n sx={sx}\n >\n <img src={icon} alt=\"\" height=\"100%\" width=\"100%\" />\n </MuiIcon>\n );\n }\n\n return (\n <MuiIcon fontSize=\"medium\" baseClassName=\"material-icons-outlined\" sx={sx}>\n {commonIcons[icon] || icon}\n </MuiIcon>\n );\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QuickstartItemIcon.esm.js","sources":["../../../src/components/QuickstartContent/QuickstartItemIcon.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 MuiIcon from '@mui/material/Icon';\nimport AdminPanelSettingsOutlinedIcon from '@mui/icons-material/AdminPanelSettingsOutlined';\nimport VpnKeyOutlinedIcon from '@mui/icons-material/VpnKeyOutlined';\nimport FileCopyOutlinedIcon from '@mui/icons-material/FileCopyOutlined';\nimport PowerOutlinedIcon from '@mui/icons-material/PowerOutlined';\nimport LoginIcon from '@mui/icons-material/Login';\nimport CategoryOutlinedIcon from '@mui/icons-material/CategoryOutlined';\nimport ControlPointOutlinedIcon from '@mui/icons-material/ControlPointOutlined';\nimport SchoolOutlinedIcon from '@mui/icons-material/SchoolOutlined';\nimport { SxProps, Theme } from '@mui/material/styles';\nimport { useApp } from '@backstage/core-plugin-api';\nimport Box from '@mui/material/Box';\n\nexport interface QuickstartItemIconProps {\n icon?: string;\n sx?: SxProps<Theme>;\n}\n\nconst commonIcons: {\n [k: string]: React.ReactNode;\n} = {\n Admin: <AdminPanelSettingsOutlinedIcon />,\n Rbac: <VpnKeyOutlinedIcon />,\n Git: <FileCopyOutlinedIcon />,\n Plugins: <PowerOutlinedIcon />,\n Import: <LoginIcon />,\n Catalog: <CategoryOutlinedIcon />,\n SelfService: <ControlPointOutlinedIcon />,\n Learning: <SchoolOutlinedIcon />,\n};\n\nexport const QuickstartItemIcon = ({ icon, sx }: QuickstartItemIconProps) => {\n const app = useApp();\n if (!icon) {\n return null;\n }\n\n const SystemIcon = app.getSystemIcon(icon);\n if (SystemIcon) {\n return (\n <Box sx={{ display: 'flex', alignItems: 'center', ...sx }}>\n <SystemIcon fontSize=\"medium\" />\n </Box>\n );\n }\n\n if (icon.startsWith('<svg')) {\n const svgDataUri = `data:image/svg+xml;base64,${btoa(icon)}`;\n return (\n <MuiIcon fontSize=\"medium\" sx={sx}>\n <img src={svgDataUri} alt=\"\" />\n </MuiIcon>\n );\n }\n\n if (\n icon.startsWith('https://') ||\n icon.startsWith('http://') ||\n icon.startsWith('/')\n ) {\n return (\n <MuiIcon\n fontSize=\"medium\"\n baseClassName=\"material-icons-outlined\"\n sx={sx}\n >\n <img src={icon} alt=\"\" height=\"100%\" width=\"100%\" />\n </MuiIcon>\n );\n }\n\n return (\n <MuiIcon fontSize=\"medium\" baseClassName=\"material-icons-outlined\" sx={sx}>\n {commonIcons[icon] || icon}\n </MuiIcon>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAkCA,MAAM,WAEF,GAAA;AAAA,EACF,KAAA,sBAAQ,8BAA+B,EAAA,EAAA,CAAA;AAAA,EACvC,IAAA,sBAAO,kBAAmB,EAAA,EAAA,CAAA;AAAA,EAC1B,GAAA,sBAAM,oBAAqB,EAAA,EAAA,CAAA;AAAA,EAC3B,OAAA,sBAAU,iBAAkB,EAAA,EAAA,CAAA;AAAA,EAC5B,MAAA,sBAAS,SAAU,EAAA,EAAA,CAAA;AAAA,EACnB,OAAA,sBAAU,oBAAqB,EAAA,EAAA,CAAA;AAAA,EAC/B,WAAA,sBAAc,wBAAyB,EAAA,EAAA,CAAA;AAAA,E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AAA,MAAA,EAAO,MAAO,EAAA,KAAA,EAAM,MAAO,EAAA;AAAA;AAAA,KACpD;AAAA;AAIJ,EACE,uBAAA,GAAA,CAAC,OAAQ,EAAA,EAAA,QAAA,EAAS,QAAS,EAAA,aAAA,EAAc,2BAA0B,EAChE,EAAA,QAAA,EAAA,WAAA,CAAY,IAAI,CAAA,IAAK,IACxB,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -3,12 +3,15 @@ import Drawer from '@mui/material/Drawer';
|
|
|
3
3
|
import { useApiHolder, configApiRef } from '@backstage/core-plugin-api';
|
|
4
4
|
import { Quickstart } from './Quickstart.esm.js';
|
|
5
5
|
import { useQuickstartDrawerContext } from '../hooks/useQuickstartDrawerContext.esm.js';
|
|
6
|
+
import { filterQuickstartItemsByRole } from '../utils/filterQuickstartItems.esm.js';
|
|
6
7
|
|
|
7
8
|
const QuickstartDrawer = () => {
|
|
8
9
|
const { isDrawerOpen, closeDrawer, drawerWidth } = useQuickstartDrawerContext();
|
|
9
10
|
const apiHolder = useApiHolder();
|
|
10
11
|
const config = apiHolder.get(configApiRef);
|
|
11
12
|
const quickstartItems = config?.has("app.quickstart") ? config.get("app.quickstart") : [];
|
|
13
|
+
const userRole = "developer";
|
|
14
|
+
const filteredItems = filterQuickstartItemsByRole(quickstartItems, userRole);
|
|
12
15
|
return /* @__PURE__ */ jsx(
|
|
13
16
|
Drawer,
|
|
14
17
|
{
|
|
@@ -33,7 +36,7 @@ const QuickstartDrawer = () => {
|
|
|
33
36
|
children: /* @__PURE__ */ jsx(
|
|
34
37
|
Quickstart,
|
|
35
38
|
{
|
|
36
|
-
quickstartItems,
|
|
39
|
+
quickstartItems: filteredItems,
|
|
37
40
|
handleDrawerClose: closeDrawer
|
|
38
41
|
}
|
|
39
42
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickstartDrawer.esm.js","sources":["../../src/components/QuickstartDrawer.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 Drawer from '@mui/material/Drawer';\nimport { ThemeConfig } from '@red-hat-developer-hub/backstage-plugin-theme';\nimport { configApiRef, useApiHolder } from '@backstage/core-plugin-api';\nimport { Quickstart } from './Quickstart';\nimport { useQuickstartDrawerContext } from '../hooks/useQuickstartDrawerContext';\nimport { QuickstartItemData } from '../types';\n\nexport const QuickstartDrawer = () => {\n const { isDrawerOpen, closeDrawer, drawerWidth } =\n useQuickstartDrawerContext();\n\n const apiHolder = useApiHolder();\n const config = apiHolder.get(configApiRef);\n const quickstartItems: QuickstartItemData[] = config?.has('app.quickstart')\n ? config.get('app.quickstart')\n : [];\n return (\n <Drawer\n sx={{\n '& .v5-MuiDrawer-paper': {\n width: drawerWidth,\n boxSizing: 'border-box',\n backgroundColor: theme =>\n `${\n (theme as ThemeConfig).palette?.rhdh?.general\n .sidebarBackgroundColor\n }`,\n justifyContent: 'space-between',\n },\n // Only apply header offset when global header exists\n 'body:has(#global-header) &': {\n '& .v5-MuiDrawer-paper': {\n top: '64px !important',\n height: 'calc(100vh - 64px) !important',\n },\n },\n }}\n variant=\"persistent\"\n anchor=\"right\"\n open={isDrawerOpen}\n >\n <Quickstart\n quickstartItems={
|
|
1
|
+
{"version":3,"file":"QuickstartDrawer.esm.js","sources":["../../src/components/QuickstartDrawer.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 Drawer from '@mui/material/Drawer';\nimport { ThemeConfig } from '@red-hat-developer-hub/backstage-plugin-theme';\nimport { configApiRef, useApiHolder } from '@backstage/core-plugin-api';\nimport { Quickstart } from './Quickstart';\nimport { useQuickstartDrawerContext } from '../hooks/useQuickstartDrawerContext';\nimport { QuickstartItemData } from '../types';\nimport { filterQuickstartItemsByRole } from '../utils';\n\nexport const QuickstartDrawer = () => {\n const { isDrawerOpen, closeDrawer, drawerWidth } =\n useQuickstartDrawerContext();\n\n const apiHolder = useApiHolder();\n const config = apiHolder.get(configApiRef);\n const quickstartItems: QuickstartItemData[] = config?.has('app.quickstart')\n ? config.get('app.quickstart')\n : [];\n\n // This will be dynamically determined based on the logged-in user\n const userRole = 'developer'; // switch to 'admin', 'developer', or other roles for testing purposes\n\n const filteredItems = filterQuickstartItemsByRole(quickstartItems, userRole);\n\n return (\n <Drawer\n sx={{\n '& .v5-MuiDrawer-paper': {\n width: drawerWidth,\n boxSizing: 'border-box',\n backgroundColor: theme =>\n `${\n (theme as ThemeConfig).palette?.rhdh?.general\n .sidebarBackgroundColor\n }`,\n justifyContent: 'space-between',\n },\n // Only apply header offset when global header exists\n 'body:has(#global-header) &': {\n '& .v5-MuiDrawer-paper': {\n top: '64px !important',\n height: 'calc(100vh - 64px) !important',\n },\n },\n }}\n variant=\"persistent\"\n anchor=\"right\"\n open={isDrawerOpen}\n >\n <Quickstart\n quickstartItems={filteredItems}\n handleDrawerClose={closeDrawer}\n />\n </Drawer>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAwBO,MAAM,mBAAmB,MAAM;AACpC,EAAA,MAAM,EAAE,YAAA,EAAc,WAAa,EAAA,WAAA,KACjC,0BAA2B,EAAA;AAE7B,EAAA,MAAM,YAAY,YAAa,EAAA;AAC/B,EAAM,MAAA,MAAA,GAAS,SAAU,CAAA,GAAA,CAAI,YAAY,CAAA;AACzC,EAAM,MAAA,eAAA,GAAwC,QAAQ,GAAI,CAAA,gBAAgB,IACtE,MAAO,CAAA,GAAA,CAAI,gBAAgB,CAAA,GAC3B,EAAC;AAGL,EAAA,MAAM,QAAW,GAAA,WAAA;AAEjB,EAAM,MAAA,aAAA,GAAgB,2BAA4B,CAAA,eAAA,EAAiB,QAAQ,CAAA;AAE3E,EACE,uBAAA,GAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,uBAAyB,EAAA;AAAA,UACvB,KAAO,EAAA,WAAA;AAAA,UACP,SAAW,EAAA,YAAA;AAAA,UACX,iBAAiB,CACf,KAAA,KAAA,CAAA,EACG,MAAsB,OAAS,EAAA,IAAA,EAAM,QACnC,sBACL,CAAA,CAAA;AAAA,UACF,cAAgB,EAAA;AAAA,SAClB;AAAA;AAAA,QAEA,4BAA8B,EAAA;AAAA,UAC5B,uBAAyB,EAAA;AAAA,YACvB,GAAK,EAAA,iBAAA;AAAA,YACL,MAAQ,EAAA;AAAA;AACV;AACF,OACF;AAAA,MACA,OAAQ,EAAA,YAAA;AAAA,MACR,MAAO,EAAA,OAAA;AAAA,MACP,IAAM,EAAA,YAAA;AAAA,MAEN,QAAA,kBAAA,GAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,eAAiB,EAAA,aAAA;AAAA,UACjB,iBAAmB,EAAA;AAAA;AAAA;AACrB;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const filterQuickstartItemsByRole = (items, userRole) => {
|
|
2
|
+
return items.filter((item) => {
|
|
3
|
+
const roles = item.roles?.length ? item.roles : ["admin"];
|
|
4
|
+
return roles.includes(userRole);
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { filterQuickstartItemsByRole };
|
|
9
|
+
//# sourceMappingURL=filterQuickstartItems.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterQuickstartItems.esm.js","sources":["../../src/utils/filterQuickstartItems.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\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 { QuickstartItemData } from '../types';\n\nexport const filterQuickstartItemsByRole = (\n items: QuickstartItemData[],\n userRole: string,\n): QuickstartItemData[] => {\n return items.filter(item => {\n // If roles is undefined or empty, default to 'admin'\n const roles = item.roles?.length ? item.roles : ['admin'];\n return roles.includes(userRole);\n });\n};\n"],"names":[],"mappings":"AAkBa,MAAA,2BAAA,GAA8B,CACzC,KAAA,EACA,QACyB,KAAA;AACzB,EAAO,OAAA,KAAA,CAAM,OAAO,CAAQ,IAAA,KAAA;AAE1B,IAAA,MAAM,QAAQ,IAAK,CAAA,KAAA,EAAO,SAAS,IAAK,CAAA,KAAA,GAAQ,CAAC,OAAO,CAAA;AACxD,IAAO,OAAA,KAAA,CAAM,SAAS,QAAQ,CAAA;AAAA,GAC/B,CAAA;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@red-hat-developer-hub/backstage-plugin-quickstart",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.esm.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"postpack": "backstage-cli package postpack"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@backstage/core-components": "^0.17.
|
|
36
|
-
"@backstage/core-plugin-api": "^1.10.
|
|
37
|
-
"@backstage/theme": "^0.6.
|
|
38
|
-
"@mui/icons-material": "5.
|
|
39
|
-
"@mui/material": "5.
|
|
35
|
+
"@backstage/core-components": "^0.17.4",
|
|
36
|
+
"@backstage/core-plugin-api": "^1.10.9",
|
|
37
|
+
"@backstage/theme": "^0.6.7",
|
|
38
|
+
"@mui/icons-material": "5.18.0",
|
|
39
|
+
"@mui/material": "5.18.0",
|
|
40
40
|
"@red-hat-developer-hub/backstage-plugin-theme": "^0.9.0",
|
|
41
41
|
"react-use": "^17.2.4"
|
|
42
42
|
},
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"react": "^16.13.1 || ^17.0.0 || ^18.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@backstage/cli": "^0.
|
|
48
|
-
"@backstage/core-app-api": "^1.
|
|
49
|
-
"@backstage/dev-utils": "^1.1.
|
|
50
|
-
"@backstage/test-utils": "^1.7.
|
|
47
|
+
"@backstage/cli": "^0.33.1",
|
|
48
|
+
"@backstage/core-app-api": "^1.18.0",
|
|
49
|
+
"@backstage/dev-utils": "^1.1.12",
|
|
50
|
+
"@backstage/test-utils": "^1.7.10",
|
|
51
51
|
"@testing-library/jest-dom": "^6.0.0",
|
|
52
52
|
"@testing-library/react": "^14.0.0",
|
|
53
53
|
"@testing-library/user-event": "^14.0.0",
|