Skip to content

Commit

Permalink
[frontend] fix crash page atomic testing after deleting a payload
Browse files Browse the repository at this point in the history
  • Loading branch information
savacano28 committed Jun 28, 2024
1 parent 827af72 commit 88263cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion openbas-front/src/actions/Schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ const getInjectWithParsedInjectorContractContent = (i) => {
...i,
inject_injector_contract: {
...i.inject_injector_contract,
injector_contract_content_parsed: JSON.parse(i.inject_injector_contract.injector_contract_content),
injector_contract_content_parsed: i.inject_injector_contract?.injector_contract_content
? JSON.parse(i.inject_injector_contract.injector_contract_content)
: null,
},
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const InjectList: FunctionComponent<Props> = ({
value: (injectDto: InjectResultDTO) => {
if (injectDto.inject_injector_contract) {
return (
<InjectorContract variant="list" label={tPick(injectDto.inject_injector_contract.injector_contract_labels)} />
<InjectorContract variant="list" label={tPick(injectDto.inject_injector_contract?.injector_contract_labels)} />
);
}
return <InjectorContract variant="list" label={t('Deleted')} deleted={true} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ const AtomicTesting = () => {
: injectResultDto.inject_type
}
/>
<Tooltip title={tPick(injectResultDto.inject_injector_contract.injector_contract_labels)}>
<Tooltip title={tPick(injectResultDto.inject_injector_contract?.injector_contract_labels)}>
<div style={{
marginLeft: 10,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{tPick(injectResultDto.inject_injector_contract.injector_contract_labels)}
{tPick(injectResultDto.inject_injector_contract?.injector_contract_labels)}
</div>
</Tooltip>
</div>
Expand Down Expand Up @@ -151,7 +151,7 @@ const AtomicTesting = () => {
{t('Platforms')}
</Typography>
<div style={{ display: 'flex' }}>
{injectResultDto.inject_injector_contract.injector_contract_platforms?.map((platform: string) => (
{injectResultDto.inject_injector_contract?.injector_contract_platforms?.map((platform: string) => (
<div key={platform} style={{ display: 'flex', marginRight: 15 }}>
<PlatformIcon width={20} platform={platform} marginRight={5} />
{platform}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const AtomicTestingDetail: FunctionComponent<Props> = () => {
{t('Type')}
</Typography>
<Typography variant="body1" gutterBottom>
{tPick(injectResultDto.inject_injector_contract.injector_contract_labels)}
{tPick(injectResultDto.inject_injector_contract?.injector_contract_labels)}
</Typography>
</div>
<div>
Expand Down

0 comments on commit 88263cb

Please sign in to comment.