-
Notifications
You must be signed in to change notification settings - Fork 24
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
Ensure unique volume layer names when changing names in frontend #6289
Conversation
- refactor layer name validation functions
…que-annotation-layer-names
frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts
Outdated
Show resolved
Hide resolved
const validateAndUpdateValue = () => { | ||
if (this.validateFields()) { | ||
this.props.onChange(this.state.value); | ||
this.setState({ | ||
isEditing: false, | ||
}); | ||
} | ||
}; | ||
if (this.props.trimValue) { | ||
this.setState( | ||
(prevState) => ({ value: prevState.value.trim() }), | ||
// afterwards validate | ||
validateAndUpdateValue, | ||
); | ||
} else { | ||
validateAndUpdateValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I avoid having a volume layer name with trailing white spaces. Previous Layer1
and Layer1
was possible and not counted as a name duplication. This is fixed by setting the prop trimValue
in the EditableTextLabel
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my round of rather high-level suggestions. My hope is to be able to simplify the code and make it easier to understand for future readers. Let me know whether this makes sense to you. Happy to jump on a call :)
Also, my impression was that not only forward slashes should be forbidden, but more characters. Since the internal discussion about that was not clear, I asked again. It would be great if you could incorporate the result of that discussion once it converged.
frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/components/editable_text_label.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/components/editable_text_label.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Daniel,
thanks for the review. I applied all your feedback and adjusted the validation of invalid characters so that URI encoding does not change them.
I had two ideas on how to approach this. The first is the "brute force" method: I remove invalid chars from the new layer name until the URI encoded version matches the original version. While doing so I track the invalid chars that are then shown to the user as invalid. This method should be 100% correct.
The second method uses a regex that removes all save uri characters that will not be encoded in uris according to (this post)[https://perishablepress.com/stop-using-unsafe-characters-in-urls/#character-encoding-chart]. The left over chars are invalid ones.
The second version is shorter and easier to understand, while I am not 100% sure whether the uri safe chars from the post are correct. But I would personally prefer the second version.
You can compare both versions in commit e281c4a
frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/components/editable_text_label.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for applying the feedback, the code already looks better and is easier to understand, agreed! 👍 There are a couple of functional issues left, please see my comments.
frontend/javascripts/oxalis/view/left-border-tabs/modals/add_volume_layer_modal.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/left-border-tabs/modals/add_volume_layer_modal.tsx
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/left-border-tabs/modals/add_volume_layer_modal.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/components/editable_text_label.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/left-border-tabs/modals/add_volume_layer_modal.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniel-wer Thanks a lot for the quick review yesterday. And thanks for already finding the bugs in the code and providing a solution 🙏.
Sorry, for not testing before pinging you. I did not have the time for it.
frontend/javascripts/oxalis/view/left-border-tabs/modals/add_volume_layer_modal.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great fixes, everything works as advertised 👍
Sorry, for not testing before pinging you. I did not have the time for it.
No worries :)
frontend/javascripts/oxalis/view/left-border-tabs/modals/add_volume_layer_modal.tsx
Outdated
Show resolved
Hide resolved
frontend/javascripts/oxalis/view/left-border-tabs/modals/add_volume_layer_modal.tsx
Outdated
Show resolved
Hide resolved
…type * 'master' of github.com:scalableminds/webknossos: Ensure unique volume layer names when changing names in frontend (#6289) X-Auth Tokens everywhere (in datastore & tracingstore) (#6312) add mapping name param for rawcuboid (#6311) Fix zooming out for datasets with very large scale (#6304) Release 22.07.0 (#6307) added Sahil's publication to list
This PR makes it impossible for the user to set layer names of volume annotation layers that already exist. The reason is to prevent duplicate names. The prevention is done when changing a name of a layer and when adding a new volume annotation layer. This pr does not change the names of existing volume layers but it marks them red if there are duplicates and asks the user to rename the layer with duplicated names.
URL of deployed dev instance (used for testing):
Steps to test:
I suggest testing this locally as the first step required is not (easily) possible on a dev branch.
/
in its name./
should say that this character is not allowed and it should also be marked red./
should also result in an error toast./
. This should then work./
and then trying to confirm should result in an error toast.Issues:
(Please delete unneeded items, merge only when none are left open)