@red-hat-developer-hub/backstage-plugin-quickstart 1.0.0 → 1.1.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 +14 -0
- package/app-config.dynamic.yaml +4 -0
- package/dist/components/Quickstart.esm.js +45 -33
- package/dist/components/Quickstart.esm.js.map +1 -1
- package/dist/components/QuickstartButton/QuickstartButton.esm.js +78 -0
- package/dist/components/QuickstartButton/QuickstartButton.esm.js.map +1 -0
- package/dist/components/QuickstartDrawer.esm.js +7 -0
- package/dist/components/QuickstartDrawer.esm.js.map +1 -1
- package/dist/components/QuickstartDrawerProvider.esm.js +32 -19
- package/dist/components/QuickstartDrawerProvider.esm.js.map +1 -1
- package/dist/index.d.ts +29 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +11 -1
- package/dist/plugin.esm.js.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/useLocalStorageState.esm.js +0 -28
- package/dist/hooks/useLocalStorageState.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @red-hat-developer-hub/backstage-plugin-quickstart
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c449b8: Fix to set quickstart-open local-storage key to true on first user visit.
|
|
8
|
+
|
|
9
|
+
## 1.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 7eb9524: - Add QuickstartButton to use context and remove localstorage logic for opening/closing of drawer.
|
|
14
|
+
- Add a custom class `.quickstart-drawer-open` on document.body that can be used to adjust styles across the app.
|
|
15
|
+
- Update QuickstartDrawer styles to handle header height.
|
|
16
|
+
|
|
3
17
|
## 1.0.0
|
|
4
18
|
|
|
5
19
|
### Major Changes
|
package/app-config.dynamic.yaml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs,
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Box from '@mui/material/Box';
|
|
3
3
|
import { QuickstartHeader } from './QuickstartHeader.esm.js';
|
|
4
4
|
import Divider from '@mui/material/Divider';
|
|
@@ -26,38 +26,50 @@ const Quickstart = ({
|
|
|
26
26
|
setProgress(calculatedProgress);
|
|
27
27
|
localStorage.setItem("progressState", calculatedProgress.toString());
|
|
28
28
|
}, [quickstartItems, itemCount, calculateProgress]);
|
|
29
|
-
return /* @__PURE__ */ jsxs(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
29
|
+
return /* @__PURE__ */ jsxs(
|
|
30
|
+
Box,
|
|
31
|
+
{
|
|
32
|
+
sx: {
|
|
33
|
+
height: "100%",
|
|
34
|
+
display: "flex",
|
|
35
|
+
flexDirection: "column"
|
|
36
|
+
},
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ jsxs(
|
|
39
|
+
Box,
|
|
40
|
+
{
|
|
41
|
+
sx: {
|
|
42
|
+
flex: 1,
|
|
43
|
+
padding: (theme) => theme.spacing(3),
|
|
44
|
+
overflowY: "auto"
|
|
45
|
+
},
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(QuickstartHeader, {}),
|
|
48
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
49
|
+
/* @__PURE__ */ jsx(
|
|
50
|
+
QuickstartContent,
|
|
51
|
+
{
|
|
52
|
+
quickstartItems,
|
|
53
|
+
itemCount,
|
|
54
|
+
setProgress: () => {
|
|
55
|
+
const newProgress = calculateProgress();
|
|
56
|
+
setProgress(newProgress);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
QuickstartFooter,
|
|
65
|
+
{
|
|
66
|
+
handleDrawerClose,
|
|
67
|
+
progress
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
);
|
|
61
73
|
};
|
|
62
74
|
|
|
63
75
|
export { Quickstart };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quickstart.esm.js","sources":["../../src/components/Quickstart.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 { QuickstartHeader } from './QuickstartHeader';\nimport Divider from '@mui/material/Divider';\nimport { QuickstartContent } from './QuickstartContent/QuickstartContent';\nimport { QuickstartFooter } from './QuickstartFooter';\nimport { useEffect, useState, useCallback } from 'react';\nimport { QuickstartItemData } from '../types';\n\ntype QuickstartProps = {\n quickstartItems: QuickstartItemData[];\n handleDrawerClose: () => void;\n};\n\nexport const Quickstart = ({\n quickstartItems,\n handleDrawerClose,\n}: QuickstartProps) => {\n const itemCount = quickstartItems.length;\n const [progress, setProgress] = useState<number>(0);\n\n const calculateProgress = useCallback(() => {\n const completedCount = quickstartItems.filter((item, index) => {\n const itemKey = `${item.title}-${index}`;\n const stepState = localStorage.getItem(itemKey);\n return stepState === 'true';\n }).length;\n\n const percentage = (completedCount / itemCount) * 100;\n return Math.round(percentage * 100) / 100;\n }, [quickstartItems, itemCount]);\n\n useEffect(() => {\n const calculatedProgress = calculateProgress();\n setProgress(calculatedProgress);\n localStorage.setItem('progressState', calculatedProgress.toString());\n }, [quickstartItems, itemCount, calculateProgress]);\n\n return (\n
|
|
1
|
+
{"version":3,"file":"Quickstart.esm.js","sources":["../../src/components/Quickstart.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 { QuickstartHeader } from './QuickstartHeader';\nimport Divider from '@mui/material/Divider';\nimport { QuickstartContent } from './QuickstartContent/QuickstartContent';\nimport { QuickstartFooter } from './QuickstartFooter';\nimport { useEffect, useState, useCallback } from 'react';\nimport { QuickstartItemData } from '../types';\n\ntype QuickstartProps = {\n quickstartItems: QuickstartItemData[];\n handleDrawerClose: () => void;\n};\n\nexport const Quickstart = ({\n quickstartItems,\n handleDrawerClose,\n}: QuickstartProps) => {\n const itemCount = quickstartItems.length;\n const [progress, setProgress] = useState<number>(0);\n\n const calculateProgress = useCallback(() => {\n const completedCount = quickstartItems.filter((item, index) => {\n const itemKey = `${item.title}-${index}`;\n const stepState = localStorage.getItem(itemKey);\n return stepState === 'true';\n }).length;\n\n const percentage = (completedCount / itemCount) * 100;\n return Math.round(percentage * 100) / 100;\n }, [quickstartItems, itemCount]);\n\n useEffect(() => {\n const calculatedProgress = calculateProgress();\n setProgress(calculatedProgress);\n localStorage.setItem('progressState', calculatedProgress.toString());\n }, [quickstartItems, itemCount, calculateProgress]);\n\n return (\n <Box\n sx={{\n height: '100%',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <Box\n sx={{\n flex: 1,\n padding: theme => theme.spacing(3),\n overflowY: 'auto',\n }}\n >\n <QuickstartHeader />\n <Divider />\n <QuickstartContent\n quickstartItems={quickstartItems}\n itemCount={itemCount}\n setProgress={() => {\n const newProgress = calculateProgress();\n setProgress(newProgress);\n }}\n />\n </Box>\n <QuickstartFooter\n handleDrawerClose={handleDrawerClose}\n progress={progress}\n />\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA6BO,MAAM,aAAa,CAAC;AAAA,EACzB,eAAA;AAAA,EACA;AACF,CAAuB,KAAA;AACrB,EAAA,MAAM,YAAY,eAAgB,CAAA,MAAA;AAClC,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,SAAiB,CAAC,CAAA;AAElD,EAAM,MAAA,iBAAA,GAAoB,YAAY,MAAM;AAC1C,IAAA,MAAM,cAAiB,GAAA,eAAA,CAAgB,MAAO,CAAA,CAAC,MAAM,KAAU,KAAA;AAC7D,MAAA,MAAM,OAAU,GAAA,CAAA,EAAG,IAAK,CAAA,KAAK,IAAI,KAAK,CAAA,CAAA;AACtC,MAAM,MAAA,SAAA,GAAY,YAAa,CAAA,OAAA,CAAQ,OAAO,CAAA;AAC9C,MAAA,OAAO,SAAc,KAAA,MAAA;AAAA,KACtB,CAAE,CAAA,MAAA;AAEH,IAAM,MAAA,UAAA,GAAc,iBAAiB,SAAa,GAAA,GAAA;AAClD,IAAA,OAAO,IAAK,CAAA,KAAA,CAAM,UAAa,GAAA,GAAG,CAAI,GAAA,GAAA;AAAA,GACrC,EAAA,CAAC,eAAiB,EAAA,SAAS,CAAC,CAAA;AAE/B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,qBA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|
+
import Box from '@mui/material/Box';
|
|
5
|
+
import Typography from '@mui/material/Typography';
|
|
6
|
+
import { useTheme } from '@mui/material/styles';
|
|
7
|
+
import WavingHandIcon from '@mui/icons-material/WavingHandOutlined';
|
|
8
|
+
import { useQuickstartPermission } from '../../hooks/useQuickstartPermission.esm.js';
|
|
9
|
+
import { useQuickstartDrawerContext } from '../../hooks/useQuickstartDrawerContext.esm.js';
|
|
10
|
+
|
|
11
|
+
const QuickstartButton = ({
|
|
12
|
+
title = "Quick start",
|
|
13
|
+
style,
|
|
14
|
+
onClick = () => {
|
|
15
|
+
}
|
|
16
|
+
}) => {
|
|
17
|
+
const isAllowed = useQuickstartPermission();
|
|
18
|
+
const { toggleDrawer } = useQuickstartDrawerContext();
|
|
19
|
+
const theme = useTheme();
|
|
20
|
+
const handleClick = useCallback(() => {
|
|
21
|
+
toggleDrawer();
|
|
22
|
+
onClick();
|
|
23
|
+
}, [toggleDrawer, onClick]);
|
|
24
|
+
return isAllowed ? /* @__PURE__ */ jsx(
|
|
25
|
+
MenuItem,
|
|
26
|
+
{
|
|
27
|
+
sx: {
|
|
28
|
+
width: "100%",
|
|
29
|
+
color: "inherit",
|
|
30
|
+
...style
|
|
31
|
+
},
|
|
32
|
+
"data-testid": "quickstart-button",
|
|
33
|
+
onClick: handleClick,
|
|
34
|
+
children: /* @__PURE__ */ jsx(
|
|
35
|
+
Box,
|
|
36
|
+
{
|
|
37
|
+
sx: {
|
|
38
|
+
display: "flex",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
justifyContent: "space-between",
|
|
41
|
+
margin: "8px 0",
|
|
42
|
+
color: "inherit",
|
|
43
|
+
width: "100%"
|
|
44
|
+
},
|
|
45
|
+
children: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
|
|
46
|
+
/* @__PURE__ */ jsx(
|
|
47
|
+
WavingHandIcon,
|
|
48
|
+
{
|
|
49
|
+
sx: {
|
|
50
|
+
fontSize: 20,
|
|
51
|
+
marginRight: "0.5rem",
|
|
52
|
+
flexShrink: 0,
|
|
53
|
+
display: "flex",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
color: theme.palette.mode === "dark" ? theme.palette.text.primary : theme.palette.text.disabled
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsx(
|
|
60
|
+
Box,
|
|
61
|
+
{
|
|
62
|
+
sx: {
|
|
63
|
+
display: "flex",
|
|
64
|
+
flexDirection: "column",
|
|
65
|
+
justifyContent: "center"
|
|
66
|
+
},
|
|
67
|
+
children: /* @__PURE__ */ jsx(Typography, { variant: "body2", color: theme.palette.text.primary, children: title })
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
] })
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
) : null;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { QuickstartButton };
|
|
78
|
+
//# sourceMappingURL=QuickstartButton.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuickstartButton.esm.js","sources":["../../../src/components/QuickstartButton/QuickstartButton.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 { CSSProperties, useCallback } from 'react';\nimport MenuItem from '@mui/material/MenuItem';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport { useTheme } from '@mui/material/styles';\nimport WavingHandIcon from '@mui/icons-material/WavingHandOutlined';\nimport { useQuickstartPermission } from '../../hooks/useQuickstartPermission';\nimport { useQuickstartDrawerContext } from '../../hooks/useQuickstartDrawerContext';\n\n/**\n * Props for the QuickstartButton component\n * @public\n */\nexport interface QuickstartButtonProps {\n /**\n * The title text to display in the button\n * @defaultValue 'Quick start'\n */\n title?: string;\n /**\n * Custom CSS styles to apply to the button\n */\n style?: CSSProperties;\n /**\n * Optional callback function to execute when the button is clicked\n */\n onClick?: () => void;\n}\n\n/**\n * @public\n */\nexport const QuickstartButton = ({\n title = 'Quick start',\n style,\n onClick = () => {},\n}: QuickstartButtonProps) => {\n const isAllowed = useQuickstartPermission();\n const { toggleDrawer } = useQuickstartDrawerContext();\n const theme = useTheme();\n\n const handleClick = useCallback(() => {\n toggleDrawer();\n onClick();\n }, [toggleDrawer, onClick]);\n\n return isAllowed ? (\n <MenuItem\n sx={{\n width: '100%',\n color: 'inherit',\n ...style,\n }}\n data-testid=\"quickstart-button\"\n onClick={handleClick}\n >\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n margin: '8px 0',\n color: 'inherit',\n width: '100%',\n }}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <WavingHandIcon\n sx={{\n fontSize: 20,\n marginRight: '0.5rem',\n flexShrink: 0,\n display: 'flex',\n alignItems: 'center',\n color:\n theme.palette.mode === 'dark'\n ? theme.palette.text.primary\n : theme.palette.text.disabled,\n }}\n />\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'column',\n justifyContent: 'center',\n }}\n >\n <Typography variant=\"body2\" color={theme.palette.text.primary}>\n {title}\n </Typography>\n </Box>\n </Box>\n </Box>\n </MenuItem>\n ) : null;\n};\n"],"names":[],"mappings":";;;;;;;;;;AAgDO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,KAAQ,GAAA,aAAA;AAAA,EACR,KAAA;AAAA,EACA,UAAU,MAAM;AAAA;AAClB,CAA6B,KAAA;AAC3B,EAAA,MAAM,YAAY,uBAAwB,EAAA;AAC1C,EAAM,MAAA,EAAE,YAAa,EAAA,GAAI,0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A,GAAA;AAAA,cAAC,GAAA;AAAA,cAAA;AAAA,gBACC,EAAI,EAAA;AAAA,kBACF,OAAS,EAAA,MAAA;AAAA,kBACT,aAAe,EAAA,QAAA;AAAA,kBACf,cAAgB,EAAA;AAAA,iBAClB;AAAA,gBAEA,QAAA,kBAAA,GAAA,CAAC,cAAW,OAAQ,EAAA,OAAA,EAAQ,OAAO,KAAM,CAAA,OAAA,CAAQ,IAAK,CAAA,OAAA,EACnD,QACH,EAAA,KAAA,EAAA;AAAA;AAAA;AACF,WACF,EAAA;AAAA;AAAA;AACF;AAAA,GAEA,GAAA,IAAA;AACN;;;;"}
|
|
@@ -18,6 +18,13 @@ const QuickstartDrawer = () => {
|
|
|
18
18
|
boxSizing: "border-box",
|
|
19
19
|
backgroundColor: (theme) => `${theme.palette?.rhdh?.general.sidebarBackgroundColor}`,
|
|
20
20
|
justifyContent: "space-between"
|
|
21
|
+
},
|
|
22
|
+
// Only apply header offset when global header exists
|
|
23
|
+
"body:has(#global-header) &": {
|
|
24
|
+
"& .v5-MuiDrawer-paper": {
|
|
25
|
+
top: "64px !important",
|
|
26
|
+
height: "calc(100vh - 64px) !important"
|
|
27
|
+
}
|
|
21
28
|
}
|
|
22
29
|
},
|
|
23
30
|
variant: "persistent",
|
|
@@ -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 }}\n variant=\"persistent\"\n anchor=\"right\"\n open={isDrawerOpen}\n >\n <Quickstart\n quickstartItems={quickstartItems}\n handleDrawerClose={closeDrawer}\n />\n </Drawer>\n );\n};\n"],"names":[],"mappings":";;;;;;AAuBO,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;AACL,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;
|
|
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={quickstartItems}\n handleDrawerClose={closeDrawer}\n />\n </Drawer>\n );\n};\n"],"names":[],"mappings":";;;;;;AAuBO,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;AACL,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,eAAA;AAAA,UACA,iBAAmB,EAAA;AAAA;AAAA;AACrB;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -5,21 +5,32 @@ import CloseIcon from '@mui/icons-material/Close';
|
|
|
5
5
|
import IconButton from '@mui/material/IconButton';
|
|
6
6
|
import { QuickstartDrawerContext } from './QuickstartDrawerContext.esm.js';
|
|
7
7
|
import { QuickstartDrawer } from './QuickstartDrawer.esm.js';
|
|
8
|
-
import Box from '@mui/material/Box';
|
|
9
8
|
import { useQuickstartPermission } from '../hooks/useQuickstartPermission.esm.js';
|
|
10
|
-
import { useLocalStorageState } from '../hooks/useLocalStorageState.esm.js';
|
|
11
9
|
|
|
12
10
|
const QuickstartDrawerProvider = ({ children }) => {
|
|
13
11
|
const isAllowed = useQuickstartPermission();
|
|
14
|
-
const [isDrawerOpen, setIsDrawerOpen] =
|
|
15
|
-
"quickstart-drawer-open",
|
|
16
|
-
false,
|
|
17
|
-
isAllowed
|
|
18
|
-
);
|
|
12
|
+
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
|
19
13
|
const [showNotification, setShowNotification] = useState(false);
|
|
20
14
|
const [hasShownNotification, setHasShownNotification] = useState(false);
|
|
21
15
|
const [drawerWidth, setDrawerWidth] = useState(500);
|
|
22
16
|
useEffect(() => {
|
|
17
|
+
if (isDrawerOpen) {
|
|
18
|
+
document.body.classList.add("quickstart-drawer-open");
|
|
19
|
+
document.body.style.setProperty(
|
|
20
|
+
"--quickstart-drawer-width",
|
|
21
|
+
`${drawerWidth}px`
|
|
22
|
+
);
|
|
23
|
+
} else {
|
|
24
|
+
document.body.classList.remove("quickstart-drawer-open");
|
|
25
|
+
document.body.style.removeProperty("--quickstart-drawer-width");
|
|
26
|
+
}
|
|
27
|
+
return () => {
|
|
28
|
+
document.body.classList.remove("quickstart-drawer-open");
|
|
29
|
+
document.body.style.removeProperty("--quickstart-drawer-width");
|
|
30
|
+
};
|
|
31
|
+
}, [isDrawerOpen, drawerWidth]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
const wasOpen = localStorage.getItem("quickstart-open");
|
|
23
34
|
const hasVisited = localStorage.getItem("quickstart-visited");
|
|
24
35
|
const notificationShown = localStorage.getItem(
|
|
25
36
|
"quickstart-notification-shown"
|
|
@@ -28,11 +39,17 @@ const QuickstartDrawerProvider = ({ children }) => {
|
|
|
28
39
|
if (!hasVisited) {
|
|
29
40
|
setIsDrawerOpen(true);
|
|
30
41
|
localStorage.setItem("quickstart-visited", "true");
|
|
42
|
+
localStorage.setItem("quickstart-open", "true");
|
|
43
|
+
} else if (wasOpen === "true") {
|
|
44
|
+
setIsDrawerOpen(true);
|
|
31
45
|
}
|
|
32
46
|
}
|
|
33
47
|
setHasShownNotification(notificationShown === "true");
|
|
34
|
-
}, [isAllowed
|
|
35
|
-
const openDrawer = () =>
|
|
48
|
+
}, [isAllowed]);
|
|
49
|
+
const openDrawer = () => {
|
|
50
|
+
setIsDrawerOpen(true);
|
|
51
|
+
localStorage.setItem("quickstart-open", "true");
|
|
52
|
+
};
|
|
36
53
|
const closeDrawer = () => {
|
|
37
54
|
setIsDrawerOpen(false);
|
|
38
55
|
if (!hasShownNotification) {
|
|
@@ -40,8 +57,12 @@ const QuickstartDrawerProvider = ({ children }) => {
|
|
|
40
57
|
setHasShownNotification(true);
|
|
41
58
|
localStorage.setItem("quickstart-notification-shown", "true");
|
|
42
59
|
}
|
|
60
|
+
localStorage.setItem("quickstart-open", "false");
|
|
61
|
+
};
|
|
62
|
+
const toggleDrawer = () => {
|
|
63
|
+
setIsDrawerOpen(!isDrawerOpen);
|
|
64
|
+
localStorage.setItem("quickstart-open", (!isDrawerOpen).toString());
|
|
43
65
|
};
|
|
44
|
-
const toggleDrawer = () => setIsDrawerOpen(!isDrawerOpen);
|
|
45
66
|
const handleNotificationClose = () => setShowNotification(false);
|
|
46
67
|
return /* @__PURE__ */ jsxs(
|
|
47
68
|
QuickstartDrawerContext.Provider,
|
|
@@ -55,15 +76,7 @@ const QuickstartDrawerProvider = ({ children }) => {
|
|
|
55
76
|
drawerWidth
|
|
56
77
|
},
|
|
57
78
|
children: [
|
|
58
|
-
|
|
59
|
-
Box,
|
|
60
|
-
{
|
|
61
|
-
sx: {
|
|
62
|
-
...!isDrawerOpen ? { marginRight: "0px" } : { marginRight: `${drawerWidth}px` }
|
|
63
|
-
},
|
|
64
|
-
children
|
|
65
|
-
}
|
|
66
|
-
),
|
|
79
|
+
children,
|
|
67
80
|
/* @__PURE__ */ jsx(QuickstartDrawer, {}),
|
|
68
81
|
/* @__PURE__ */ jsx(
|
|
69
82
|
Snackbar,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickstartDrawerProvider.esm.js","sources":["../../src/components/QuickstartDrawerProvider.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 { useEffect, PropsWithChildren, useState } from 'react';\nimport Snackbar from '@mui/material/Snackbar';\nimport CloseIcon from '@mui/icons-material/Close';\nimport IconButton from '@mui/material/IconButton';\nimport { QuickstartDrawerContext } from './QuickstartDrawerContext';\nimport { QuickstartDrawer } from './QuickstartDrawer';\nimport
|
|
1
|
+
{"version":3,"file":"QuickstartDrawerProvider.esm.js","sources":["../../src/components/QuickstartDrawerProvider.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 { useEffect, PropsWithChildren, useState } from 'react';\nimport Snackbar from '@mui/material/Snackbar';\nimport CloseIcon from '@mui/icons-material/Close';\nimport IconButton from '@mui/material/IconButton';\nimport { QuickstartDrawerContext } from './QuickstartDrawerContext';\nimport { QuickstartDrawer } from './QuickstartDrawer';\nimport { useQuickstartPermission } from '../hooks/useQuickstartPermission';\n\nexport const QuickstartDrawerProvider = ({ children }: PropsWithChildren) => {\n const isAllowed = useQuickstartPermission();\n const [isDrawerOpen, setIsDrawerOpen] = useState<boolean>(false);\n const [showNotification, setShowNotification] = useState(false);\n const [hasShownNotification, setHasShownNotification] = useState(false);\n const [drawerWidth, setDrawerWidth] = useState<number>(500);\n\n // Single useEffect - sets class on document.body\n useEffect(() => {\n if (isDrawerOpen) {\n document.body.classList.add('quickstart-drawer-open');\n document.body.style.setProperty(\n '--quickstart-drawer-width',\n `${drawerWidth}px`,\n );\n } else {\n document.body.classList.remove('quickstart-drawer-open');\n document.body.style.removeProperty('--quickstart-drawer-width');\n }\n\n return () => {\n document.body.classList.remove('quickstart-drawer-open');\n document.body.style.removeProperty('--quickstart-drawer-width');\n };\n }, [isDrawerOpen, drawerWidth]);\n\n useEffect(() => {\n const wasOpen = localStorage.getItem('quickstart-open');\n const hasVisited = localStorage.getItem('quickstart-visited');\n const notificationShown = localStorage.getItem(\n 'quickstart-notification-shown',\n );\n\n if (isAllowed) {\n if (!hasVisited) {\n setIsDrawerOpen(true);\n localStorage.setItem('quickstart-visited', 'true');\n localStorage.setItem('quickstart-open', 'true');\n } else if (wasOpen === 'true') {\n setIsDrawerOpen(true);\n }\n }\n\n setHasShownNotification(notificationShown === 'true');\n }, [isAllowed]);\n\n const openDrawer = () => {\n setIsDrawerOpen(true);\n localStorage.setItem('quickstart-open', 'true');\n };\n\n const closeDrawer = () => {\n setIsDrawerOpen(false);\n if (!hasShownNotification) {\n setShowNotification(true);\n setHasShownNotification(true);\n localStorage.setItem('quickstart-notification-shown', 'true');\n }\n localStorage.setItem('quickstart-open', 'false');\n };\n\n const toggleDrawer = () => {\n setIsDrawerOpen(!isDrawerOpen);\n localStorage.setItem('quickstart-open', (!isDrawerOpen).toString());\n };\n\n const handleNotificationClose = () => setShowNotification(false);\n\n return (\n <QuickstartDrawerContext.Provider\n value={{\n isDrawerOpen,\n openDrawer,\n closeDrawer,\n toggleDrawer,\n setDrawerWidth,\n drawerWidth,\n }}\n >\n {children}\n <QuickstartDrawer />\n <Snackbar\n sx={{ top: '80px !important' }}\n open={showNotification}\n autoHideDuration={10000}\n onClose={handleNotificationClose}\n anchorOrigin={{ vertical: 'top', horizontal: 'right' }}\n message=\"Need help? Visit the Quick Start Guide by clicking on this (?) icon in the header!\"\n action={\n <IconButton\n size=\"small\"\n aria-label=\"close\"\n color=\"inherit\"\n onClick={handleNotificationClose}\n >\n <CloseIcon fontSize=\"small\" />\n </IconButton>\n }\n />\n </QuickstartDrawerContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAwBO,MAAM,wBAA2B,GAAA,CAAC,EAAE,QAAA,EAAkC,KAAA;AAC3E,EAAA,MAAM,YAAY,uBAAwB,EAAA;AAC1C,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAkB,KAAK,CAAA;AAC/D,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAS,KAAK,CAAA;AAC9D,EAAA,MAAM,CAAC,oBAAA,EAAsB,uBAAuB,CAAA,GAAI,SAAS,KAAK,CAAA;AACtE,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAiB,GAAG,CAAA;AAG1D,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,YAAc,EAAA;AAChB,MAAS,QAAA,CAAA,IAAA,CAAK,SAAU,CAAA,GAAA,CAAI,wBAAwB,CAAA;AACpD,MAAA,QAAA,CAAS,KAAK,KAAM,CAAA,WAAA;AAAA,QAClB,2BAAA;AAAA,QACA,GAAG,WAAW,CAAA,EAAA;AAAA,OAChB;AAAA,KACK,MAAA;AACL,MAAS,QAAA,CAAA,IAAA,CAAK,SAAU,CAAA,MAAA,CAAO,wBAAwB,CAAA;AACvD,MAAS,QAAA,CAAA,IAAA,CAAK,KAAM,CAAA,cAAA,CAAe,2BAA2B,CAAA;AAAA;AAGhE,IAAA,OAAO,MAAM;AACX,MAAS,QAAA,CAAA,IAAA,CAAK,SAAU,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
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
3
|
-
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { CSSProperties, PropsWithChildren } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Props for the QuickstartButton component
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
interface QuickstartButtonProps {
|
|
10
|
+
/**
|
|
11
|
+
* The title text to display in the button
|
|
12
|
+
* @defaultValue 'Quick start'
|
|
13
|
+
*/
|
|
14
|
+
title?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Custom CSS styles to apply to the button
|
|
17
|
+
*/
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
/**
|
|
20
|
+
* Optional callback function to execute when the button is clicked
|
|
21
|
+
*/
|
|
22
|
+
onClick?: () => void;
|
|
23
|
+
}
|
|
4
24
|
|
|
5
25
|
/**
|
|
6
26
|
* Quick start plugin
|
|
@@ -14,6 +34,12 @@ declare const quickstartPlugin: _backstage_core_plugin_api.BackstagePlugin<{}, {
|
|
|
14
34
|
* @public
|
|
15
35
|
*/
|
|
16
36
|
declare const QuickstartDrawerProvider: React.ComponentType<PropsWithChildren>;
|
|
37
|
+
/**
|
|
38
|
+
* Quick start button for global header help dropdown
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
declare const QuickstartButton: React.ComponentType<QuickstartButtonProps>;
|
|
17
43
|
|
|
18
44
|
/**
|
|
19
45
|
* Type for QuickstartDrawerContext
|
|
@@ -54,5 +80,5 @@ interface QuickstartDrawerContextType {
|
|
|
54
80
|
*/
|
|
55
81
|
declare const useQuickstartDrawerContext: () => QuickstartDrawerContextType;
|
|
56
82
|
|
|
57
|
-
export { QuickstartDrawerProvider, quickstartPlugin, useQuickstartDrawerContext };
|
|
58
|
-
export type { QuickstartDrawerContextType };
|
|
83
|
+
export { QuickstartButton, QuickstartDrawerProvider, quickstartPlugin, useQuickstartDrawerContext };
|
|
84
|
+
export type { QuickstartButtonProps, QuickstartDrawerContextType };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { unstable_ClassNameGenerator } from '@mui/material/className';
|
|
2
|
-
export { QuickstartDrawerProvider, quickstartPlugin } from './plugin.esm.js';
|
|
2
|
+
export { QuickstartButton, QuickstartDrawerProvider, quickstartPlugin } from './plugin.esm.js';
|
|
3
3
|
export { useQuickstartDrawerContext } from './hooks/useQuickstartDrawerContext.esm.js';
|
|
4
4
|
|
|
5
5
|
unstable_ClassNameGenerator.configure((componentName) => {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/index.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 { unstable_ClassNameGenerator as ClassNameGenerator } from '@mui/material/className';\n\nClassNameGenerator.configure(componentName => {\n return componentName.startsWith('v5-')\n ? componentName\n : `v5-${componentName}`;\n});\n\nexport
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/index.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 { unstable_ClassNameGenerator as ClassNameGenerator } from '@mui/material/className';\n\nClassNameGenerator.configure(componentName => {\n return componentName.startsWith('v5-')\n ? componentName\n : `v5-${componentName}`;\n});\n\nexport * from './plugin';\n\nexport { useQuickstartDrawerContext } from './hooks/useQuickstartDrawerContext';\nexport type { QuickstartDrawerContextType } from './components/QuickstartDrawerContext';\n"],"names":["ClassNameGenerator"],"mappings":";;;;AAkBAA,2BAAA,CAAmB,UAAU,CAAiB,aAAA,KAAA;AAC5C,EAAA,OAAO,cAAc,UAAW,CAAA,KAAK,CACjC,GAAA,aAAA,GACA,MAAM,aAAa,CAAA,CAAA;AACzB,CAAC,CAAA"}
|
package/dist/plugin.esm.js
CHANGED
|
@@ -13,6 +13,16 @@ const QuickstartDrawerProvider = quickstartPlugin.provide(
|
|
|
13
13
|
}
|
|
14
14
|
})
|
|
15
15
|
);
|
|
16
|
+
const QuickstartButton = quickstartPlugin.provide(
|
|
17
|
+
createComponentExtension({
|
|
18
|
+
name: "QuickstartButton",
|
|
19
|
+
component: {
|
|
20
|
+
lazy: () => import('./components/QuickstartButton/QuickstartButton.esm.js').then(
|
|
21
|
+
(m) => m.QuickstartButton
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
);
|
|
16
26
|
|
|
17
|
-
export { QuickstartDrawerProvider, quickstartPlugin };
|
|
27
|
+
export { QuickstartButton, QuickstartDrawerProvider, quickstartPlugin };
|
|
18
28
|
//# sourceMappingURL=plugin.esm.js.map
|
package/dist/plugin.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.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 {\n createComponentExtension,\n createPlugin,\n} from '@backstage/core-plugin-api';\nimport { PropsWithChildren } from 'react';\n\n/**\n * Quick start plugin\n *\n * @public\n */\nexport const quickstartPlugin = createPlugin({\n id: 'quickstart',\n});\n\n/**\n * Quick start drawer provider\n *\n * @public\n */\nexport const QuickstartDrawerProvider: React.ComponentType<PropsWithChildren> =\n quickstartPlugin.provide(\n createComponentExtension({\n name: 'QuickstartDrawerProvider',\n component: {\n lazy: () =>\n import('./components/QuickstartDrawerProvider').then(\n m => m.QuickstartDrawerProvider,\n ),\n },\n }),\n );\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.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 {\n createComponentExtension,\n createPlugin,\n} from '@backstage/core-plugin-api';\nimport { PropsWithChildren } from 'react';\nimport { QuickstartButtonProps } from './components/QuickstartButton/QuickstartButton';\n\nexport type { QuickstartButtonProps } from './components/QuickstartButton/QuickstartButton';\n\n/**\n * Quick start plugin\n *\n * @public\n */\nexport const quickstartPlugin = createPlugin({\n id: 'quickstart',\n});\n\n/**\n * Quick start drawer provider\n *\n * @public\n */\nexport const QuickstartDrawerProvider: React.ComponentType<PropsWithChildren> =\n quickstartPlugin.provide(\n createComponentExtension({\n name: 'QuickstartDrawerProvider',\n component: {\n lazy: () =>\n import('./components/QuickstartDrawerProvider').then(\n m => m.QuickstartDrawerProvider,\n ),\n },\n }),\n );\n\n/**\n * Quick start button for global header help dropdown\n *\n * @public\n */\nexport const QuickstartButton: React.ComponentType<QuickstartButtonProps> =\n quickstartPlugin.provide(\n createComponentExtension({\n name: 'QuickstartButton',\n component: {\n lazy: () =>\n import('./components/QuickstartButton/QuickstartButton').then(\n m => m.QuickstartButton,\n ),\n },\n }),\n );\n"],"names":[],"mappings":";;AA8BO,MAAM,mBAAmB,YAAa,CAAA;AAAA,EAC3C,EAAI,EAAA;AACN,CAAC;AAOM,MAAM,2BACX,gBAAiB,CAAA,OAAA;AAAA,EACf,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,0BAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,8CAAuC,CAAE,CAAA,IAAA;AAAA,QAC9C,OAAK,CAAE,CAAA;AAAA;AACT;AACJ,GACD;AACH;AAOK,MAAM,mBACX,gBAAiB,CAAA,OAAA;AAAA,EACf,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,kBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAM,EAAA,MACJ,OAAO,uDAAgD,CAAE,CAAA,IAAA;AAAA,QACvD,OAAK,CAAE,CAAA;AAAA;AACT;AACJ,GACD;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
function useLocalStorageState(key, defaultValue, isAllowed) {
|
|
4
|
-
const readValue = useCallback(() => {
|
|
5
|
-
try {
|
|
6
|
-
const stored = localStorage.getItem(key);
|
|
7
|
-
return isAllowed && stored !== null ? JSON.parse(stored) : defaultValue;
|
|
8
|
-
} catch {
|
|
9
|
-
return defaultValue;
|
|
10
|
-
}
|
|
11
|
-
}, [defaultValue, isAllowed, key]);
|
|
12
|
-
const [value, setValue] = useState(readValue);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
const interval = setInterval(() => {
|
|
15
|
-
const local = readValue();
|
|
16
|
-
setValue((prev) => prev !== local ? local : prev);
|
|
17
|
-
}, 500);
|
|
18
|
-
return () => clearInterval(interval);
|
|
19
|
-
}, [readValue]);
|
|
20
|
-
const updateValue = (newValue) => {
|
|
21
|
-
setValue(newValue);
|
|
22
|
-
localStorage.setItem(key, JSON.stringify(newValue));
|
|
23
|
-
};
|
|
24
|
-
return [value, updateValue];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { useLocalStorageState };
|
|
28
|
-
//# sourceMappingURL=useLocalStorageState.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorageState.esm.js","sources":["../../src/hooks/useLocalStorageState.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 { useCallback, useEffect, useState } from 'react';\n\nexport function useLocalStorageState<T extends string | number | boolean>(\n key: string,\n defaultValue: T,\n isAllowed: boolean,\n): [T, (value: T) => void] {\n const readValue = useCallback((): T => {\n try {\n const stored = localStorage.getItem(key);\n return isAllowed && stored !== null ? JSON.parse(stored) : defaultValue;\n } catch {\n return defaultValue;\n }\n }, [defaultValue, isAllowed, key]);\n\n const [value, setValue] = useState<T>(readValue);\n\n useEffect(() => {\n const interval = setInterval(() => {\n const local = readValue();\n setValue(prev => (prev !== local ? local : prev));\n }, 500);\n return () => clearInterval(interval);\n }, [readValue]);\n\n const updateValue = (newValue: T) => {\n setValue(newValue);\n localStorage.setItem(key, JSON.stringify(newValue));\n };\n\n return [value, updateValue];\n}\n"],"names":[],"mappings":";;AAkBgB,SAAA,oBAAA,CACd,GACA,EAAA,YAAA,EACA,SACyB,EAAA;AACzB,EAAM,MAAA,SAAA,GAAY,YAAY,MAAS;AACrC,IAAI,IAAA;AACF,MAAM,MAAA,MAAA,GAAS,YAAa,CAAA,OAAA,CAAQ,GAAG,CAAA;AACvC,MAAA,OAAO,aAAa,MAAW,KAAA,IAAA,GAAO,IAAK,CAAA,KAAA,CAAM,MAAM,CAAI,GAAA,YAAA;AAAA,KACrD,CAAA,MAAA;AACN,MAAO,OAAA,YAAA;AAAA;AACT,GACC,EAAA,CAAC,YAAc,EAAA,SAAA,EAAW,GAAG,CAAC,CAAA;AAEjC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAY,SAAS,CAAA;AAE/C,EAAA,SAAA,CAAU,MAAM;AACd,IAAM,MAAA,QAAA,GAAW,YAAY,MAAM;AACjC,MAAA,MAAM,QAAQ,SAAU,EAAA;AACxB,MAAA,QAAA,CAAS,CAAS,IAAA,KAAA,IAAA,KAAS,KAAQ,GAAA,KAAA,GAAQ,IAAK,CAAA;AAAA,OAC/C,GAAG,CAAA;AACN,IAAO,OAAA,MAAM,cAAc,QAAQ,CAAA;AAAA,GACrC,EAAG,CAAC,SAAS,CAAC,CAAA;AAEd,EAAM,MAAA,WAAA,GAAc,CAAC,QAAgB,KAAA;AACnC,IAAA,QAAA,CAAS,QAAQ,CAAA;AACjB,IAAA,YAAA,CAAa,OAAQ,CAAA,GAAA,EAAK,IAAK,CAAA,SAAA,CAAU,QAAQ,CAAC,CAAA;AAAA,GACpD;AAEA,EAAO,OAAA,CAAC,OAAO,WAAW,CAAA;AAC5B;;;;"}
|