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

Remove metadata when updating studios or workspaces #1507

Merged
merged 1 commit into from
Feb 22, 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
3 changes: 2 additions & 1 deletion src/shared/containers/DataTableContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
} from '../organisms/DataPanel/DataPanel';
import { TResourceTableData } from '../molecules/MyDataTable/MyDataTable';
import { RootState } from '../../shared/store/reducers';
import { resourceWithoutMetadata } from '../../subapps/studioLegacy/containers/StudioContainer';

export type TableColumn = {
'@type': string;
Expand Down Expand Up @@ -290,7 +291,7 @@ const DataTableContainer: React.FC<DataTableProps> = ({
projectLabel,
encodeURIComponent(data['@id']),
latest._rev,
{ ...latest, ...data }
{ ...resourceWithoutMetadata(latest), ...resourceWithoutMetadata(data) }
);
}
const resource = await nexus.Resource.create(orgLabel, projectLabel, data);
Expand Down
8 changes: 7 additions & 1 deletion src/subapps/studioLegacy/containers/StudioContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ import useNotification, {
parseNexusError,
} from '../../../shared/hooks/useNotification';

// remove the metadata from the payload, delta do full update
// and not accept the metadata fields to be in the payload
export const resourceWithoutMetadata = (
studioResource: StudioResource | Resource
) => omitBy(studioResource, (_, key) => key.trim().startsWith('_'));

const resourcesWritePermissionsWrapper = (
child: React.ReactNode,
permissionPath: string
Expand Down Expand Up @@ -116,7 +122,7 @@ const StudioContainer: React.FunctionComponent = () => {
studioId,
studioResource._rev,
{
...omitBy(studioResource, (_, key) => key.trim().startsWith('_')),
...resourceWithoutMetadata(studioResource),
label,
description,
plugins,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from 'antd';
import TextArea from 'antd/lib/input/TextArea';
import useNotification from '../../../shared/hooks/useNotification';
import { resourceWithoutMetadata } from './StudioContainer';

type NexusSparqlError = {
reason: string;
Expand Down Expand Up @@ -123,7 +124,7 @@ const WorkspaceForm: React.FunctionComponent<WorkspaceFormProps> = ({
projectLabel,
encodeURIComponent(workspace['@id']),
workspace['_rev'],
newWorkspace
resourceWithoutMetadata(newWorkspace)
)
.then(result => {
if (onSuccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import STUDIO_CONTEXT from '../components/StudioContext';
import { createTableContext } from '../../../subapps/projects/utils/workFlowMetadataUtils';
import { ErrorComponent } from '../../../shared/components/ErrorComponent';
import '../studio.scss';
import { resourceWithoutMetadata } from './StudioContainer';

const DASHBOARD_TYPE = 'StudioDashboard';

Expand Down Expand Up @@ -488,18 +489,18 @@ const WorkspaceMenu: React.FC<WorkspaceMenuProps> = ({
data: TableResource | UnsavedTableResource
) => {
if (selectedDashboard) {
const resource = await nexus.Resource.get(
const resource = (await nexus.Resource.get(
orgLabel,
projectLabel,
encodeURIComponent(selectedDashboard['@id'])
);
)) as StudioResource;
await nexus.Resource.update(
orgLabel,
projectLabel,
encodeURIComponent(selectedDashboard['@id']),
selectedDashboard._rev,
{
...resource,
...resourceWithoutMetadata(resource),
description: data.description,
label: data['name'],
}
Expand Down
Loading