-
-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
103 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...EventsDetails.tsx/ProjectActionsEventsDetailsSource/ProjectActionsEventsDetailsSource.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { IObservableEvent } from 'interfaces/action'; | ||
import { ProjectActionsEventsDetailsSourceIncomingWebhook } from './ProjectActionsEventsDetailsSourceIncomingWebhook'; | ||
|
||
interface IProjectActionsEventsDetailsSourceProps { | ||
observableEvent: IObservableEvent; | ||
} | ||
|
||
export const ProjectActionsEventsDetailsSource = ({ | ||
observableEvent, | ||
}: IProjectActionsEventsDetailsSourceProps) => { | ||
const { source } = observableEvent; | ||
|
||
if (source === 'incoming-webhook') { | ||
return ( | ||
<ProjectActionsEventsDetailsSourceIncomingWebhook | ||
observableEvent={observableEvent} | ||
/> | ||
); | ||
} | ||
|
||
return null; | ||
}; |
75 changes: 75 additions & 0 deletions
75
...sx/ProjectActionsEventsDetailsSource/ProjectActionsEventsDetailsSourceIncomingWebhook.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { ExpandMore } from '@mui/icons-material'; | ||
import { | ||
Accordion, | ||
AccordionDetails, | ||
AccordionSummary, | ||
IconButton, | ||
styled, | ||
} from '@mui/material'; | ||
import { useIncomingWebhooks } from 'hooks/api/getters/useIncomingWebhooks/useIncomingWebhooks'; | ||
import { IObservableEvent } from 'interfaces/action'; | ||
import { Suspense, lazy, useMemo } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
const LazyReactJSONEditor = lazy( | ||
() => import('component/common/ReactJSONEditor/ReactJSONEditor'), | ||
); | ||
|
||
const StyledAccordion = styled(Accordion)(({ theme }) => ({ | ||
boxShadow: 'none', | ||
border: `1px solid ${theme.palette.divider}`, | ||
borderRadius: theme.shape.borderRadiusMedium, | ||
'&:before': { | ||
display: 'none', | ||
}, | ||
})); | ||
|
||
const StyledLink = styled(Link)(({ theme }) => ({ | ||
marginLeft: theme.spacing(1), | ||
})); | ||
|
||
interface IProjectActionsEventsDetailsSourceIncomingWebhookProps { | ||
observableEvent: IObservableEvent; | ||
} | ||
|
||
export const ProjectActionsEventsDetailsSourceIncomingWebhook = ({ | ||
observableEvent, | ||
}: IProjectActionsEventsDetailsSourceIncomingWebhookProps) => { | ||
const { incomingWebhooks } = useIncomingWebhooks(); | ||
|
||
const incomingWebhookName = useMemo(() => { | ||
const incomingWebhook = incomingWebhooks.find( | ||
(incomingWebhook) => | ||
incomingWebhook.id === observableEvent.sourceId, | ||
); | ||
|
||
return incomingWebhook?.name; | ||
}, [incomingWebhooks, observableEvent.sourceId]); | ||
|
||
return ( | ||
<StyledAccordion> | ||
<AccordionSummary | ||
expandIcon={ | ||
<IconButton> | ||
<ExpandMore titleAccess='Toggle' /> | ||
</IconButton> | ||
} | ||
> | ||
Incoming webhook: | ||
<StyledLink to='/integrations/incoming-webhooks'> | ||
{incomingWebhookName} | ||
</StyledLink> | ||
</AccordionSummary> | ||
<AccordionDetails> | ||
<Suspense fallback={null}> | ||
<LazyReactJSONEditor | ||
content={{ json: observableEvent.payload }} | ||
readOnly | ||
statusBar={false} | ||
editorStyle='sidePanel' | ||
/> | ||
</Suspense> | ||
</AccordionDetails> | ||
</StyledAccordion> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters