@backstage-community/plugin-shortcuts 0.17.0 → 0.17.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
@@ -1,5 +1,11 @@
1
1
  # @backstage-community/plugin-shortcuts
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a82af01: Fixed bug in Shortcuts where 'Use Current Page' did not preserve query parameters.
8
+
3
9
  ## 0.17.0
4
10
 
5
11
  ### Minor Changes
@@ -28,7 +28,7 @@ const AddShortcut = ({
28
28
  }) => {
29
29
  const classes = useStyles();
30
30
  const alertApi = useApi(alertApiRef);
31
- const { pathname } = useLocation();
31
+ const { pathname, search } = useLocation();
32
32
  const [formValues, setFormValues] = useState();
33
33
  const open = Boolean(anchorEl);
34
34
  const analytics = useAnalytics();
@@ -51,7 +51,7 @@ const AddShortcut = ({
51
51
  onClose();
52
52
  };
53
53
  const handlePaste = () => {
54
- setFormValues({ url: pathname, title: document.title });
54
+ setFormValues({ url: `${pathname}${search}`, title: document.title });
55
55
  };
56
56
  const handleClose = () => {
57
57
  setFormValues(void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"AddShortcut.esm.js","sources":["../src/AddShortcut.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 { useLocation } from 'react-router-dom';\nimport { SubmitHandler } from 'react-hook-form';\nimport Button from '@material-ui/core/Button';\nimport Card from '@material-ui/core/Card';\nimport CardHeader from '@material-ui/core/CardHeader';\nimport Popover from '@material-ui/core/Popover';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ShortcutForm } from './ShortcutForm';\nimport { FormValues, Shortcut } from './types';\nimport { ShortcutApi } from './api';\nimport { alertApiRef, useApi, useAnalytics } from '@backstage/core-plugin-api';\n\nconst useStyles = makeStyles(theme => ({\n card: {\n maxWidth: 400,\n },\n header: {\n marginBottom: theme.spacing(1),\n },\n button: {\n marginTop: theme.spacing(1),\n },\n}));\n\ntype Props = {\n onClose: () => void;\n anchorEl?: Element;\n api: ShortcutApi;\n\n allowExternalLinks?: boolean;\n};\n\nexport const AddShortcut = ({\n onClose,\n anchorEl,\n api,\n allowExternalLinks,\n}: Props) => {\n const classes = useStyles();\n const alertApi = useApi(alertApiRef);\n const { pathname } = useLocation();\n const [formValues, setFormValues] = useState<FormValues>();\n const open = Boolean(anchorEl);\n const analytics = useAnalytics();\n\n const handleSave: SubmitHandler<FormValues> = async ({ url, title }) => {\n analytics.captureEvent('click', `Clicked 'Save' in AddShortcut`);\n const shortcut: Omit<Shortcut, 'id'> = { url, title };\n\n try {\n await api.add(shortcut);\n alertApi.post({\n message: `Added shortcut '${title}' to your sidebar`,\n severity: 'success',\n display: 'transient',\n });\n } catch (error) {\n alertApi.post({\n message: `Could not add shortcut: ${error.message}`,\n severity: 'error',\n });\n }\n\n onClose();\n };\n\n const handlePaste = () => {\n setFormValues({ url: pathname, title: document.title });\n };\n\n const handleClose = () => {\n setFormValues(undefined);\n onClose();\n };\n\n return (\n <Popover\n open={open}\n anchorEl={anchorEl}\n TransitionProps={{ onExit: handleClose }}\n onClose={onClose}\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <Card className={classes.card}>\n <CardHeader\n className={classes.header}\n title=\"Add Shortcut\"\n titleTypographyProps={{ variant: 'subtitle2' }}\n action={\n <Button\n className={classes.button}\n variant=\"text\"\n size=\"small\"\n color=\"primary\"\n onClick={handlePaste}\n >\n Use current page\n </Button>\n }\n />\n <ShortcutForm\n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BACV,QAAA,EAAA;AAAA;AAAA;AAED;AAAA,SAEJ;AAAA,wBACA,GAAA;AAAA,UAAC,YAAA;AAAA,UAAA;AAAA,YACC,OAAS,EAAA,WAAA;AAAA,YACT,MAAQ,EAAA,UAAA;AAAA,YACR,UAAA;AAAA,YACA;AAAA;AAAA;AACF,OACF,EAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"AddShortcut.esm.js","sources":["../src/AddShortcut.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 { useLocation } from 'react-router-dom';\nimport { SubmitHandler } from 'react-hook-form';\nimport Button from '@material-ui/core/Button';\nimport Card from '@material-ui/core/Card';\nimport CardHeader from '@material-ui/core/CardHeader';\nimport Popover from '@material-ui/core/Popover';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { ShortcutForm } from './ShortcutForm';\nimport { FormValues, Shortcut } from './types';\nimport { ShortcutApi } from './api';\nimport { alertApiRef, useApi, useAnalytics } from '@backstage/core-plugin-api';\n\nconst useStyles = makeStyles(theme => ({\n card: {\n maxWidth: 400,\n },\n header: {\n marginBottom: theme.spacing(1),\n },\n button: {\n marginTop: theme.spacing(1),\n },\n}));\n\ntype Props = {\n onClose: () => void;\n anchorEl?: Element;\n api: ShortcutApi;\n\n allowExternalLinks?: boolean;\n};\n\nexport const AddShortcut = ({\n onClose,\n anchorEl,\n api,\n allowExternalLinks,\n}: Props) => {\n const classes = useStyles();\n const alertApi = useApi(alertApiRef);\n const { pathname, search } = useLocation();\n const [formValues, setFormValues] = useState<FormValues>();\n const open = Boolean(anchorEl);\n const analytics = useAnalytics();\n\n const handleSave: SubmitHandler<FormValues> = async ({ url, title }) => {\n analytics.captureEvent('click', `Clicked 'Save' in AddShortcut`);\n const shortcut: Omit<Shortcut, 'id'> = { url, title };\n\n try {\n await api.add(shortcut);\n alertApi.post({\n message: `Added shortcut '${title}' to your sidebar`,\n severity: 'success',\n display: 'transient',\n });\n } catch (error) {\n alertApi.post({\n message: `Could not add shortcut: ${error.message}`,\n severity: 'error',\n });\n }\n\n onClose();\n };\n\n const handlePaste = () => {\n setFormValues({ url: `${pathname}${search}`, title: document.title });\n };\n\n const handleClose = () => {\n setFormValues(undefined);\n onClose();\n };\n\n return (\n <Popover\n open={open}\n anchorEl={anchorEl}\n TransitionProps={{ onExit: handleClose }}\n onClose={onClose}\n anchorOrigin={{\n vertical: 'top',\n horizontal: 'right',\n }}\n >\n <Card className={classes.card}>\n <CardHeader\n className={classes.header}\n title=\"Add Shortcut\"\n titleTypographyProps={{ variant: 'subtitle2' }}\n action={\n <Button\n className={classes.button}\n variant=\"text\"\n size=\"small\"\n color=\"primary\"\n onClick={handlePaste}\n >\n Use current page\n </Button>\n }\n />\n <ShortcutForm\n onClose={handleClose}\n onSave={handleSave}\n formValues={formValues}\n allowExternalLinks={allowExternalLinks}\n />\n </Card>\n </Popover>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA6BA,MAAM,SAAA,GAAY,WAAW,CAAU,KAAA,MAAA;AAAA,EACrC,IAAM,EAAA;AAAA,IACJ,QAAU,EAAA;AAAA,GACZ;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,YAAA,EAAc,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA,GAC/B;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,SAAA,EAAW,KAAM,CAAA,OAAA,CAAQ,CAAC;AAAA;AAE9B,CAAE,CAAA,CAAA;AAUK,MAAM,cAAc,CAAC;AAAA,EAC1B,OAAA;AAAA,EACA,QA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Ac,KAAS,CAAA,CAAA;AACvB,IAAQ,OAAA,EAAA;AAAA,GACV;AAEA,EACE,uBAAA,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,QAAA;AAAA,MACA,eAAA,EAAiB,EAAE,MAAA,EAAQ,WAAY,EAAA;AAAA,MACvC,OAAA;AAAA,MACA,YAAc,EAAA;AAAA,QACZ,QAAU,EAAA,KAAA;AAAA,QACV,UAAY,EAAA;AAAA,OACd;AAAA,MAEA,QAAC,kBAAA,IAAA,CAAA,IAAA,EAAA,EAAK,SAAW,EAAA,OAAA,CAAQ,IACvB,EAAA,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACC,WAAW,OAAQ,CAAA,MAAA;AAAA,YACnB,KAAM,EAAA,cAAA;AAAA,YACN,oBAAA,EAAsB,EAAE,OAAA,EAAS,WAAY,EAAA;AAAA,YAC7C,MACE,kBAAA,GAAA;AAAA,cAAC,MAAA;AAAA,cAAA;AAAA,gBACC,WAAW,OAAQ,CAAA,MAAA;AAAA,gBACnB,OAAQ,EAAA,MAAA;AAAA,gBACR,IAAK,EAAA,OAAA;AAAA,gBACL,KAAM,EAAA,SAAA;AAAA,gBACN,OAAS,EAAA,WAAA;AAAA,gBACV,QAAA,EAAA;AAAA;AAAA;AAED;AAAA,SAEJ;AAAA,wBACA,GAAA;AAAA,UAAC,YAAA;AAAA,UAAA;AAAA,YACC,OAAS,EAAA,WAAA;AAAA,YACT,MAAQ,EAAA,UAAA;AAAA,YACR,UAAA;AAAA,YACA;AAAA;AAAA;AACF,OACF,EAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage-community/plugin-shortcuts",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "A Backstage plugin that provides a shortcuts feature to the sidebar",
5
5
  "backstage": {
6
6
  "role": "frontend-plugin",