Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 71ea84b

Browse files
committed
Remove metadata when updating studios or workspaces
Signed-off-by: Dinika Saxena <dinikasaxenas@gmail.com>
1 parent c7e4c8c commit 71ea84b

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/shared/containers/DataTableContainer.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
DataPanelEvent,
3838
} from '../organisms/DataPanel/DataPanel';
3939
import { TResourceTableData } from '../molecules/MyDataTable/MyDataTable';
40+
import { resourceWithoutMetadata } from '../../subapps/studioLegacy/containers/StudioContainer';
4041

4142
export type TableColumn = {
4243
'@type': string;
@@ -290,7 +291,7 @@ const DataTableContainer: React.FC<DataTableProps> = ({
290291
projectLabel,
291292
encodeURIComponent(data['@id']),
292293
latest._rev,
293-
{ ...latest, ...data }
294+
{ ...resourceWithoutMetadata(latest), ...resourceWithoutMetadata(data) }
294295
);
295296
}
296297
const resource = await nexus.Resource.create(orgLabel, projectLabel, data);

src/subapps/studioLegacy/containers/StudioContainer.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import useNotification, {
1616
parseNexusError,
1717
} from '../../../shared/hooks/useNotification';
1818

19+
export const resourceWithoutMetadata = (
20+
studioResource: StudioResource | Resource
21+
) => omitBy(studioResource, (_, key) => key.trim().startsWith('_'));
22+
1923
const resourcesWritePermissionsWrapper = (
2024
child: React.ReactNode,
2125
permissionPath: string
@@ -118,7 +122,7 @@ const StudioContainer: React.FunctionComponent = () => {
118122
{
119123
// remove the metadata from the payload, delta do full update
120124
// and not accept the metadata fields to be in the payload
121-
...omitBy(studioResource, (_, key) => key.trim().startsWith('_')),
125+
...resourceWithoutMetadata(studioResource),
122126
label,
123127
description,
124128
plugins,

src/subapps/studioLegacy/containers/WorkspaceFormContainer.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from 'antd';
2020
import TextArea from 'antd/lib/input/TextArea';
2121
import useNotification from '../../../shared/hooks/useNotification';
22+
import { resourceWithoutMetadata } from './StudioContainer';
2223

2324
type NexusSparqlError = {
2425
reason: string;
@@ -123,7 +124,7 @@ const WorkspaceForm: React.FunctionComponent<WorkspaceFormProps> = ({
123124
projectLabel,
124125
encodeURIComponent(workspace['@id']),
125126
workspace['_rev'],
126-
newWorkspace
127+
resourceWithoutMetadata(newWorkspace)
127128
)
128129
.then(result => {
129130
if (onSuccess) {

src/subapps/studioLegacy/containers/WorkspaceMenuContainer.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import PromisePool from '@supercharge/promise-pool';
1212
import { ItemType } from 'antd/lib/menu/hooks/useItems';
1313
import { useQuery } from 'react-query';
14-
import { find, orderBy } from 'lodash';
14+
import { find, omitBy, orderBy } from 'lodash';
1515
import useNotification from '../../../shared/hooks/useNotification';
1616
import EditTableForm from '../../../shared/components/EditTableForm';
1717
import DashboardEditorContainer from './DashBoardEditor/DashboardEditorContainer';
@@ -30,6 +30,7 @@ import STUDIO_CONTEXT from '../components/StudioContext';
3030
import { createTableContext } from '../../../subapps/projects/utils/workFlowMetadataUtils';
3131
import { ErrorComponent } from '../../../shared/components/ErrorComponent';
3232
import '../studio.less';
33+
import { resourceWithoutMetadata } from './StudioContainer';
3334

3435
const DASHBOARD_TYPE = 'StudioDashboard';
3536

@@ -484,18 +485,18 @@ const WorkspaceMenu: React.FC<WorkspaceMenuProps> = ({
484485
data: TableResource | UnsavedTableResource
485486
) => {
486487
if (selectedDashboard) {
487-
const resource = await nexus.Resource.get(
488+
const resource = (await nexus.Resource.get(
488489
orgLabel,
489490
projectLabel,
490491
encodeURIComponent(selectedDashboard['@id'])
491-
);
492+
)) as StudioResource;
492493
await nexus.Resource.update(
493494
orgLabel,
494495
projectLabel,
495496
encodeURIComponent(selectedDashboard['@id']),
496497
selectedDashboard._rev,
497498
{
498-
...resource,
499+
...resourceWithoutMetadata(resource),
499500
description: data.description,
500501
label: data['name'],
501502
}

0 commit comments

Comments
 (0)