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

Fix not being able to save dataset settings #7903

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented Jun 26, 2024

Likely due to the frontend changes of #7697, the dataset settings got messed up. The reason is, that the current state of the component does not have the state field savedDataSourceOnServer, but it is referenced in a diffiing operation of the datasource schema. See

didDatasourceChange(dataSource: Record<string, any>) {
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'Readonly<MutableAPIDataSource> |... Remove this comment to see the full error message
return _.size(diffObjects(dataSource, this.state.savedDataSourceOnServer)) > 0;
}

The diffing is used to decide whether the frontend should send an update of the datasource schema to the backend. But in the current version of the master, the diff check always fails as the state field savedDataSourceOnServer is always undefined (it does not exist in the state). My fix re-added this field to the state (by renaming the unused dataSource to savedDataSourceOnServer) and adds a default empty object to the diff, to avoid such an error in any case. Moreover, the type of savedDataSourceOnServer says it can be undefined / null thus the additional optional empty object is needed for the diff.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • Check whether you can do changes in the dataset settings of one dataset on the master (e.g.: https://master.webknossos.xyz/datasets/sample_organization/ROI2017_wkw/edit) this should not work.
  • Do the same on the dev instance for this branch. This should now work.
  • Open the dev tools, in dataset_settings_view.tsx in submit in line 365 set a break point. Do not edit the datasource settings and hit submit. The debugging should show, that now update is set to the server. Alternatively, just record the sent requests to the server. Only when the datasource settings were modified, an update should be sent to the server.

Issues:

  • Not issue exists for this

(Please delete unneeded items, merge only when none are left open)

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and I didn't found problems during testing.

@MichaelBuessemeyer MichaelBuessemeyer merged commit 5101e65 into master Jun 26, 2024
2 checks passed
@MichaelBuessemeyer MichaelBuessemeyer deleted the fix-dataset-settings branch June 26, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants