Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4912 // Show validation error when updating resources #1536

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/shared/components/IDResolution/ResponseViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ type Props = {
data: any;
header?: string;
showHeader?: boolean;
collapsed?: boolean;
style?: React.CSSProperties;
};

const ResponseViewer = ({ data, showHeader = false, header = '' }: Props) => {
const ResponseViewer = ({
data,
showHeader = false,
header = '',
collapsed = false,
style = {},
}: Props) => {
return (
<ReactJson
collapsed
collapsed={collapsed}
name={showHeader ? header : undefined}
src={data as object}
indentWidth={3}
iconStyle="square"
enableClipboard={false}
displayObjectSize={false}
displayDataTypes={false}
style={{ maxWidth: 'inherit', width: '600px' }}
style={{ maxWidth: 'inherit', width: '600px', ...style }}
/>
);
};
Expand Down
104 changes: 62 additions & 42 deletions src/shared/containers/ResourceViewContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import VideoPluginContainer from './VideoPluginContainer/VideoPluginContainer';
import { useMutation } from 'react-query';

export const DEFAULT_ACTIVE_TAB_KEY = '#JSON';
import ResponseViewer from '../../shared/components/IDResolution/ResponseViewer';

export type PluginMapping = {
[pluginKey: string]: object;
Expand Down Expand Up @@ -707,48 +708,67 @@ const ResourceViewContainer: FC<{

<Spin spinning={busy}>
{!!error ? (
<Alert
message={
error.wasUpdated ? 'Resource updated with errors' : 'Error'
}
showIcon
closable
style={{ marginTop: 40 }}
type="error"
description={
<>
<Typography.Paragraph
ellipsis={{ rows: 2, expandable: true }}
>
{error.message}
</Typography.Paragraph>
{error.rejections && (
<Collapse bordered={false} ghost>
<Collapse.Panel key={1} header="More detail...">
<>
<ul>
{error.rejections.map((el, ix) => (
<li key={ix}>{el.reason}</li>
))}
</ul>

<p>
For further information please refer to the API
documentation,{' '}
<a
target="_blank"
href="https://bluebrainnexus.io/docs/delta/api"
>
https://bluebrainnexus.io/docs/delta/api
</a>
</p>
</>
</Collapse.Panel>
</Collapse>
)}
</>
}
/>
<>
<Alert
message={
error.wasUpdated ? 'Resource updated with errors' : 'Error'
}
showIcon
closable
style={{ marginTop: 40 }}
type="error"
description={
<>
<Typography.Paragraph
ellipsis={{ rows: 2, expandable: true }}
>
{error.message}
</Typography.Paragraph>
{error.rejections && (
<Collapse bordered={false} ghost>
<Collapse.Panel key={1} header="More detail...">
<>
<ul>
{error.rejections.map((el, ix) => (
<li key={ix}>{el.reason}</li>
))}
</ul>

<p>
For further information please refer to the API
documentation,{' '}
<a
target="_blank"
href="https://bluebrainnexus.io/docs/delta/api"
>
https://bluebrainnexus.io/docs/delta/api
</a>
</p>
</>
</Collapse.Panel>
</Collapse>
)}
</>
}
/>
<div
style={{
display: 'flex',
justifyContent: 'center',
marginTop: '28px',
}}
>
<ResponseViewer
data={error}
showHeader={false}
style={{
width: '1000px',
background: 'white',
padding: '10px',
}}
/>
</div>
</>
) : (
<>
{resource && (
Expand Down
3 changes: 1 addition & 2 deletions src/subapps/studioLegacy/containers/StudioContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import * as React from 'react';
import { Resource } from '@bbp/nexus-sdk';
import { useNexusContext, AccessControl } from '@bbp/react-nexus';
import { Empty, message } from 'antd';
import { omitBy } from 'lodash';
import { useHistory } from 'react-router';

import { omitBy } from 'lodash';
import EditStudio from '../components/EditStudio';
import StudioHeader from '../components/StudioHeader';
import StudioReactContext from '../contexts/StudioContext';
Expand Down
Loading