@red-hat-developer-hub/backstage-plugin-global-header 0.2.0 → 1.0.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @red-hat-developer-hub/backstage-plugin-global-header
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 005fa36: Release 1.0.0
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import Alert from '@mui/material/Alert';
3
2
  import { MarkdownContent } from '@backstage/core-components';
3
+ import Alert from '@mui/material/Alert';
4
+ import { HeaderIcon } from './HeaderIcon/HeaderIcon.esm.js';
4
5
 
5
6
  const NotificationBanner = (props) => {
6
7
  const [dismissed, setDismissed] = React.useState(() => {
@@ -47,15 +48,19 @@ const NotificationBanner = (props) => {
47
48
  return /* @__PURE__ */ React.createElement(
48
49
  Alert,
49
50
  {
50
- icon: false,
51
+ color: "warning",
52
+ icon: props.icon ? /* @__PURE__ */ React.createElement(HeaderIcon, { icon: props.icon }) : false,
51
53
  onClose,
52
54
  sx: {
53
- color: props.textColor ?? "text.primary",
54
- backgroundColor: props.backgroundColor ?? "background.paper",
55
- border: props.border,
56
- borderRadius: props.borderRadius,
55
+ color: props.textColor,
56
+ backgroundColor: props.backgroundColor,
57
+ borderColor: props.borderColor,
58
+ borderStyle: "solid",
59
+ borderWidth: 2,
60
+ borderRadius: 0,
57
61
  justifyContent: "center",
58
- textAlign: "center"
62
+ textAlign: "center",
63
+ ...props.layout
59
64
  }
60
65
  },
61
66
  props.markdown ? /* @__PURE__ */ React.createElement(MarkdownContent, { content: props.title, dialect: "gfm" }) : props.title
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationBanner.esm.js","sources":["../../src/components/NotificationBanner.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 React from 'react';\nimport Alert from '@mui/material/Alert';\nimport { MarkdownContent } from '@backstage/core-components';\n\n// export type NotificationBannerColor = 'success' | 'info' | 'warning' | 'error';\n// export type NotificationBannerIcon = 'success' | 'info' | 'warning' | 'error';\n// export type NotificationBannerVariant = 'standard' | 'filled' | 'outlined';\n\n/**\n * @public\n */\nexport type NotificationBannerDismiss = 'none' | 'session' | 'localstorage';\n\n/**\n * @public\n */\nexport interface NotificationBannerProps {\n id?: string;\n title: string;\n markdown?: boolean;\n\n textColor?: string;\n backgroundColor?: string;\n border?: string;\n borderRadius?: string;\n\n // color?: NotificationBannerColor;\n // icon?: NotificationBannerIcon;\n // variant?: NotificationBannerVariant;\n\n dismiss?: NotificationBannerDismiss;\n}\n\nexport const NotificationBanner = (props: NotificationBannerProps) => {\n const [dismissed, setDismissed] = React.useState<boolean>(() => {\n if (props.dismiss === 'localstorage') {\n try {\n const dismissedString =\n localStorage.getItem('global-header/NotificationBanner') ?? '{}';\n const dismissedObject = JSON.parse(dismissedString);\n return dismissedObject[props.id ?? props.title] === 'dismissed';\n } catch (error) {\n // nothing\n return false;\n }\n } else {\n return false;\n }\n });\n\n const onClose = React.useMemo<(() => void) | undefined>(() => {\n if (!props.dismiss || props.dismiss === 'none') {\n return undefined;\n } else if (props.dismiss === 'session') {\n return () => setDismissed(true);\n } else if (props.dismiss === 'localstorage') {\n return () => {\n try {\n const dismissedString =\n localStorage.getItem('global-header/NotificationBanner') ?? '{}';\n const dismissedObject = JSON.parse(dismissedString);\n dismissedObject[props.id ?? props.title] = 'dismissed';\n localStorage.setItem(\n 'global-header/NotificationBanner',\n JSON.stringify(dismissedObject),\n );\n } catch (error) {\n // nothing\n }\n setDismissed(true);\n };\n }\n // eslint-disable-next-line no-console\n console.warn(\n `Unsupported dismiss option \"${props.dismiss}\", currently supported \"none\", \"session\" or \"localstorage\"!`,\n );\n return undefined;\n }, [props.id, props.title, props.dismiss]);\n\n if (dismissed || !props.title) {\n return null;\n }\n\n return (\n <Alert\n // color={props.color}\n // severity={props.icon}\n icon={false}\n // variant={props.variant}\n onClose={onClose}\n sx={{\n color: props.textColor ?? 'text.primary',\n backgroundColor: props.backgroundColor ?? 'background.paper',\n border: props.border,\n borderRadius: props.borderRadius,\n justifyContent: 'center',\n textAlign: 'center',\n }}\n >\n {props.markdown ? (\n <MarkdownContent content={props.title} dialect=\"gfm\" />\n ) : (\n props.title\n )}\n </Alert>\n );\n};\n"],"names":[],"mappings":";;;;AAiDa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAA,MAAM,CAAC,SAAW,EAAA,YAAY,CAAI,GAAA,KAAA,CAAM,SAAkB,MAAM;AAC9D,IAAI,IAAA,KAAA,CAAM,YAAY,cAAgB,EAAA;AACpC,MAAI,IAAA;AACF,QAAA,MAAM,eACJ,GAAA,YAAA,CAAa,OAAQ,CAAA,kCAAkC,CAAK,IAAA,IAAA;AAC9D,QAAM,MAAA,eAAA,GAAkB,IAAK,CAAA,KAAA,CAAM,eAAe,CAAA;AAClD,QAAA,OAAO,eAAgB,CAAA,KAAA,CAAM,EAAM,IAAA,KAAA,CAAM,KAAK,CAAM,KAAA,WAAA;AAAA,eAC7C,KAAO,EAAA;AAEd,QAAO,OAAA,KAAA;AAAA;AACT,KACK,MAAA;AACL,MAAO,OAAA,KAAA;AAAA;AACT,GACD,CAAA;AAED,EAAM,MAAA,OAAA,GAAU,KAAM,CAAA,OAAA,CAAkC,MAAM;AAC5D,IAAA,IAAI,CAAC,KAAA,CAAM,OAAW,IAAA,KAAA,CAAM,YAAY,MAAQ,EAAA;AAC9C,MAA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A;AAAA,QACd,cAAc,KAAM,CAAA,YAAA;AAAA,QACpB,cAAgB,EAAA,QAAA;AAAA,QAChB,SAAW,EAAA;AAAA;AACb,KAAA;AAAA,IAEC,KAAA,CAAM,QACL,mBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,EAAA,EAAA,OAAA,EAAS,MAAM,KAAO,EAAA,OAAA,EAAQ,KAAM,EAAA,CAAA,GAErD,KAAM,CAAA;AAAA,GAEV;AAEJ;;;;"}
1
+ {"version":3,"file":"NotificationBanner.esm.js","sources":["../../src/components/NotificationBanner.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 React from 'react';\n\nimport { MarkdownContent } from '@backstage/core-components';\n\nimport Alert from '@mui/material/Alert';\n\nimport { HeaderIcon } from './HeaderIcon/HeaderIcon';\n\n/**\n * @public\n */\nexport type NotificationBannerDismiss = 'none' | 'session' | 'localstorage';\n\n/**\n * @public\n */\nexport interface NotificationBannerProps {\n id?: string;\n title: string;\n markdown?: boolean;\n icon?: string;\n\n textColor?: string;\n backgroundColor?: string;\n borderColor?: string;\n layout?: React.CSSProperties;\n\n dismiss?: NotificationBannerDismiss;\n}\n\nexport const NotificationBanner = (props: NotificationBannerProps) => {\n const [dismissed, setDismissed] = React.useState<boolean>(() => {\n if (props.dismiss === 'localstorage') {\n try {\n const dismissedString =\n localStorage.getItem('global-header/NotificationBanner') ?? '{}';\n const dismissedObject = JSON.parse(dismissedString);\n return dismissedObject[props.id ?? props.title] === 'dismissed';\n } catch (error) {\n // nothing\n return false;\n }\n } else {\n return false;\n }\n });\n\n const onClose = React.useMemo<(() => void) | undefined>(() => {\n if (!props.dismiss || props.dismiss === 'none') {\n return undefined;\n } else if (props.dismiss === 'session') {\n return () => setDismissed(true);\n } else if (props.dismiss === 'localstorage') {\n return () => {\n try {\n const dismissedString =\n localStorage.getItem('global-header/NotificationBanner') ?? '{}';\n const dismissedObject = JSON.parse(dismissedString);\n dismissedObject[props.id ?? props.title] = 'dismissed';\n localStorage.setItem(\n 'global-header/NotificationBanner',\n JSON.stringify(dismissedObject),\n );\n } catch (error) {\n // nothing\n }\n setDismissed(true);\n };\n }\n // eslint-disable-next-line no-console\n console.warn(\n `Unsupported dismiss option \"${props.dismiss}\", currently supported \"none\", \"session\" or \"localstorage\"!`,\n );\n return undefined;\n }, [props.id, props.title, props.dismiss]);\n\n if (dismissed || !props.title) {\n return null;\n }\n\n return (\n <Alert\n color=\"warning\"\n icon={props.icon ? <HeaderIcon icon={props.icon} /> : false}\n onClose={onClose}\n sx={{\n color: props.textColor,\n backgroundColor: props.backgroundColor,\n borderColor: props.borderColor,\n borderStyle: 'solid',\n borderWidth: 2,\n borderRadius: 0,\n justifyContent: 'center',\n textAlign: 'center',\n ...props.layout,\n }}\n >\n {props.markdown ? (\n <MarkdownContent content={props.title} dialect=\"gfm\" />\n ) : (\n props.title\n )}\n </Alert>\n );\n};\n"],"names":[],"mappings":";;;;;AA8Ca,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAA,MAAM,CAAC,SAAW,EAAA,YAAY,CAAI,GAAA,KAAA,CAAM,SAAkB,MAAM;AAC9D,IAAI,IAAA,KAAA,CAAM,YAAY,cAAgB,EAAA;AACpC,MAAI,IAAA;AACF,QAAA,MAAM,eACJ,GAAA,YAAA,CAAa,OAAQ,CAAA,kCAAkC,CAAK,IAAA,IAAA;AAC9D,QAAM,MAAA,eAAA,GAAkB,IAAK,CAAA,KAAA,CAAM,eAAe,CAAA;AAClD,QAAA,OAAO,eAAgB,CAAA,KAAA,CAAM,EAAM,I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AA;AAC7B,IAAO,OAAA,IAAA;AAAA;AAGT,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAM,EAAA,SAAA;AAAA,MACN,IAAA,EAAM,MAAM,IAAO,mBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,IAAM,EAAA,KAAA,CAAM,MAAM,CAAK,GAAA,KAAA;AAAA,MACtD,OAAA;AAAA,MACA,EAAI,EAAA;AAAA,QACF,OAAO,KAAM,CAAA,SAAA;AAAA,QACb,iBAAiB,KAAM,CAAA,eAAA;AAAA,QACvB,aAAa,KAAM,CAAA,WAAA;AAAA,QACnB,WAAa,EAAA,OAAA;AAAA,QACb,WAAa,EAAA,CAAA;AAAA,QACb,YAAc,EAAA,CAAA;AAAA,QACd,cAAgB,EAAA,QAAA;AAAA,QAChB,SAAW,EAAA,QAAA;AAAA,QACX,GAAG,KAAM,CAAA;AAAA;AACX,KAAA;AAAA,IAEC,KAAA,CAAM,QACL,mBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,EAAA,EAAA,OAAA,EAAS,MAAM,KAAO,EAAA,OAAA,EAAQ,KAAM,EAAA,CAAA,GAErD,KAAM,CAAA;AAAA,GAEV;AAEJ;;;;"}
package/dist/index.d.ts CHANGED
@@ -13,10 +13,11 @@ interface NotificationBannerProps {
13
13
  id?: string;
14
14
  title: string;
15
15
  markdown?: boolean;
16
+ icon?: string;
16
17
  textColor?: string;
17
18
  backgroundColor?: string;
18
- border?: string;
19
- borderRadius?: string;
19
+ borderColor?: string;
20
+ layout?: React$1.CSSProperties;
20
21
  dismiss?: NotificationBannerDismiss;
21
22
  }
22
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@red-hat-developer-hub/backstage-plugin-global-header",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "main": "dist/index.esm.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -52,8 +52,6 @@
52
52
  "@mui/material": "5.16.13",
53
53
  "@mui/styled-engine": "5.16.13",
54
54
  "@scalprum/react-core": "0.9.3",
55
- "react-dom": "18.3.1",
56
- "react-router-dom": "^6.26.2",
57
55
  "react-use": "^17.5.0"
58
56
  },
59
57
  "peerDependencies": {
@@ -77,7 +75,7 @@
77
75
  "react-router-dom": "^6.0.0"
78
76
  },
79
77
  "keywords": [
80
- "support:tech-preview",
78
+ "support:production",
81
79
  "lifecycle:active",
82
80
  "backstage",
83
81
  "plugin"