Merge pull request #4681 from joaomilho/allow-trigger-button-without-pagerduty-key

Improve PagerDuty plugins
This commit is contained in:
Patrik Oldsberg
2021-03-02 19:15:21 +01:00
committed by GitHub
15 changed files with 375 additions and 181 deletions
@@ -132,12 +132,13 @@ describe('SplunkOnCallCard', () => {
),
).toBeInTheDocument();
});
it('opens the dialog when trigger button is clicked', async () => {
mockSplunkOnCallApi.getUsers = jest
.fn()
.mockImplementationOnce(async () => [MOCKED_USER]);
const { getByText, queryByTestId, getByTestId, getByRole } = render(
const { getByText, queryByTestId, getByRole } = render(
wrapInTestApp(
<ApiProvider apis={apis}>
<SplunkOnCallCard entity={entity} />
@@ -146,7 +147,7 @@ describe('SplunkOnCallCard', () => {
);
await waitFor(() => !queryByTestId('progress'));
expect(getByText('Create Incident')).toBeInTheDocument();
const triggerButton = getByTestId('trigger-button');
const triggerButton = getByText('Create Incident');
await act(async () => {
fireEvent.click(triggerButton);
});
@@ -21,11 +21,10 @@ import {
MissingAnnotationEmptyState,
configApiRef,
EmptyState,
IconLinkVerticalProps,
} from '@backstage/core';
import { Entity } from '@backstage/catalog-model';
import {
Button,
makeStyles,
Card,
CardHeader,
Divider,
@@ -42,22 +41,6 @@ import { TriggerDialog } from './TriggerDialog';
import { MissingApiKeyOrApiIdError } from './Errors/MissingApiKeyOrApiIdError';
import { User } from './types';
const useStyles = makeStyles({
triggerAlarm: {
paddingTop: 0,
paddingBottom: 0,
fontSize: '0.7rem',
textTransform: 'uppercase',
fontWeight: 600,
letterSpacing: 1.2,
lineHeight: 1.5,
'&:hover, &:focus, &.focus': {
backgroundColor: 'transparent',
textDecoration: 'none',
},
},
});
export const SPLUNK_ON_CALL_TEAM = 'splunk.com/on-call-team';
export const MissingTeamAnnotation = () => (
@@ -82,7 +65,6 @@ type Props = {
};
export const SplunkOnCallCard = ({ entity }: Props) => {
const classes = useStyles();
const config = useApi(configApiRef);
const api = useApi(splunkOnCallApiRef);
const [showDialog, setShowDialog] = useState<boolean>(false);
@@ -159,19 +141,11 @@ export const SplunkOnCallCard = ({ entity }: Props) => {
);
};
const triggerLink = {
const triggerLink: IconLinkVerticalProps = {
label: 'Create Incident',
action: (
<Button
data-testid="trigger-button"
color="secondary"
onClick={handleDialog}
className={classes.triggerAlarm}
>
Create Incident
</Button>
),
icon: <AlarmAddIcon onClick={handleDialog} />,
onClick: handleDialog,
color: 'secondary',
icon: <AlarmAddIcon />,
};
return (