diff --git a/.changeset/perfect-goats-mate.md b/.changeset/perfect-goats-mate.md
new file mode 100644
index 0000000000..6ad2884d08
--- /dev/null
+++ b/.changeset/perfect-goats-mate.md
@@ -0,0 +1,5 @@
+---
+'@backstage/core-components': minor
+---
+
+The SupportButton component will now be hidden if no support config is specified in app-config
diff --git a/packages/core-components/report.api.md b/packages/core-components/report.api.md
index b9414eb897..c3f7cf9a6a 100644
--- a/packages/core-components/report.api.md
+++ b/packages/core-components/report.api.md
@@ -1331,7 +1331,9 @@ export type SubvalueCellClassKey = 'value' | 'subvalue';
// Warning: (ae-missing-release-tag) "SupportButton" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
-export function SupportButton(props: SupportButtonProps): React_2.JSX.Element;
+export function SupportButton(
+ props: SupportButtonProps,
+): React_2.JSX.Element | null;
// Warning: (ae-missing-release-tag) "SupportButtonClassKey" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
diff --git a/packages/core-components/src/components/SupportButton/SupportButton.test.tsx b/packages/core-components/src/components/SupportButton/SupportButton.test.tsx
index 9ed8fb8401..4036884130 100644
--- a/packages/core-components/src/components/SupportButton/SupportButton.test.tsx
+++ b/packages/core-components/src/components/SupportButton/SupportButton.test.tsx
@@ -41,34 +41,50 @@ const configApi = mockApis.config({
},
});
+const noSupportConfigApi = mockApis.config({
+ data: {
+ app: {},
+ },
+});
+
const SUPPORT_BUTTON_ID = 'support-button';
const POPOVER_ID = 'support-button-popover';
describe('', () => {
it('renders without exploding', async () => {
- await renderInTestApp();
+ await renderInTestApp(
+
+
+ ,
+ );
await expect(
screen.findByTestId(SUPPORT_BUTTON_ID),
).resolves.toBeInTheDocument();
});
it('supports passing a title', async () => {
- await renderInTestApp();
+ await renderInTestApp(
+
+
+ ,
+ );
fireEvent.click(screen.getByTestId(SUPPORT_BUTTON_ID));
expect(screen.getByText('Custom title')).toBeInTheDocument();
});
it('supports passing link items through props', async () => {
await renderInTestApp(
- ,
+
+
+ ,
);
const supportButton = screen.getByTestId(SUPPORT_BUTTON_ID);
@@ -97,7 +113,11 @@ describe('', () => {
});
it('shows popover on click', async () => {
- await renderInTestApp();
+ await renderInTestApp(
+
+
+ ,
+ );
await expect(
screen.findByTestId(SUPPORT_BUTTON_ID),
@@ -108,4 +128,14 @@ describe('', () => {
await expect(screen.findByTestId(POPOVER_ID)).resolves.toBeInTheDocument();
});
+
+ it('hides button if config is missing', async () => {
+ await renderInTestApp(
+
+
+ ,
+ );
+
+ await expect(screen.findByTestId(SUPPORT_BUTTON_ID)).rejects.toThrow();
+ });
});
diff --git a/packages/core-components/src/components/SupportButton/SupportButton.tsx b/packages/core-components/src/components/SupportButton/SupportButton.tsx
index 9e51e23119..c3a6e283b6 100644
--- a/packages/core-components/src/components/SupportButton/SupportButton.tsx
+++ b/packages/core-components/src/components/SupportButton/SupportButton.tsx
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import { useApp } from '@backstage/core-plugin-api';
+import { configApiRef, useApi, useApp } from '@backstage/core-plugin-api';
import Box from '@material-ui/core/Box';
import Button from '@material-ui/core/Button';
import DialogActions from '@material-ui/core/DialogActions';
@@ -94,6 +94,7 @@ export function SupportButton(props: SupportButtonProps) {
const [popoverOpen, setPopoverOpen] = useState(false);
const [anchorEl, setAnchorEl] = useState(null);
const classes = useStyles();
+ const supportConfig = useApi(configApiRef).getOptionalConfig('app.support');
const isSmallScreen = useMediaQuery(theme =>
theme.breakpoints.down('sm'),
);
@@ -107,6 +108,10 @@ export function SupportButton(props: SupportButtonProps) {
setPopoverOpen(false);
};
+ if (!supportConfig) {
+ return null;
+ }
+
return (
<>