-
Notifications
You must be signed in to change notification settings - Fork 420
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
Refactor room edit modal #4408
Refactor room edit modal #4408
Conversation
indico/modules/rb/client/js/common/rooms/RoomEditNotifications.jsx
Outdated
Show resolved
Hide resolved
</FormSpy> | ||
<FormSpy subscription={{submitFailed: true}}> |
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.
I'd use a single FormSpy that subscribes to both submitSucceeded
and submitFailed
.
In principle you can probably avoid using FormSpy
altogether and just add it to the global subscription in the FinalForm and then get these two values from the fprops.
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.
I've had both approaches, ended up with this because using two FormSpy
's will result in an extra empty <>
to hold both Message
components (unless we merge them and use conditionals).
Adding it as a global subscription would be perfect, but wouldn't that make the whole form re-render when we only need it in a small part?
indico/modules/rb/client/js/common/rooms/RoomEditModal.module.scss
Outdated
Show resolved
Hide resolved
indico/modules/rb/client/js/common/rooms/edit/RoomEditOptions.jsx
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.
@plourenco I have tested the edit modal and observed these 2 things:
When we upload a picture and click on save (button just below picture), It sends a POST
and GET
to show the image. After that, when we delete the picture just after that, it sends a DELETE
and then GET
to get the image with the same query string when we saved the image which gives a 404 on network tab. Is it supposed to work that way?
Now, we have validation error on 3 fields continuously, I can't select the Building field. Maybe the position of the tooltip can be changed?
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.
why export default
is not written with the function itself as there is only one function in most of the files?
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.
Thanks for the PR! This task has been around for a while and it's a lot of messy work that needed to be improved!
I tested it locally and seems to run very smoothly! Along with the comment I mentioned yesterday in our MM channel about the existing photograph not showing the edit dialoge, I left a couple of smaller comments as well!
indico/modules/rb/client/js/common/rooms/RoomEditModal.module.scss
Outdated
Show resolved
Hide resolved
indico/modules/rb/client/js/common/rooms/edit/RoomEditOptions.jsx
Outdated
Show resolved
Hide resolved
indico/modules/rb/client/js/common/rooms/edit/RoomEditOptions.jsx
Outdated
Show resolved
Hide resolved
indico/modules/rb/client/js/common/rooms/edit/RoomEditOptions.jsx
Outdated
Show resolved
Hide resolved
I think this was a personal preference. But I'm changing the style since the latter is more straightforward. |
It seems like we are using Having the So what I did was not setting the
|
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.
LGTM
indico/modules/rb/client/js/common/rooms/edit/RoomEditOptions.jsx
Outdated
Show resolved
Hide resolved
@@ -7,952 +7,330 @@ | |||
|
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.
Shouldn't this file also go inside the edit/
subdir?
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.
I'm not sure, what do you think?
Since this is a core
file, connected to the RoomEditDetails
for me it made more sense to highlight it and move to the rooms
.
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.
hm you could always re-export it from edit/index.js so you can import RoomEditModal from './edit';
which I think is clearer (and that way anything for editing is in one place)
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.
I'm not sure if that is a better solution since the only thing I am importing and exporting is RoomEditModal
itself, it is an unnecessary barrel. Nonetheless, I moved it into the edit
.
<FormSpy subscription={{submitSucceeded: true}}> | ||
{({submitSucceeded}) => ( | ||
<Button onClick={onClose}> | ||
{submitSucceeded ? <Translate>Close</Translate> : <Translate>Cancel</Translate>} |
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.
Not sure if that does what you intend: The old submitState
was reset as soon as something changed in the form (so it went back from Close to Cancel if you started editing after saving) - I don't think this happens with submitSucceeded
.
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.
Yes, the only difference I saw was not resetting after a successful submission.
However, do you think it is worth changing this to the internal state (another re-render) just because of a button change after the first submit?
It could also seem reasonable for the button to say Close
if you already saved previously.
indico/modules/rb/client/js/common/rooms/edit/RoomEditOptions.jsx
Outdated
Show resolved
Hide resolved
272a7b0
to
94e873f
Compare
Really great job! I am just thinking about one thing. Right now, when you change between tabs the height of the modal changes according to the tab's content. Wouldn't it be nicer if we could have (if possible) fixed height and prevent those changes? |
Another thing that I just noticed. Not sure if we haven't noticed it so far, but when one uploads a new room photo, it is possible to upload for example a pdf. Backend of course will reject it, but as far as I know |
I agree, it is annoying. Even though the modal is already top-aligned, I'm not sure it is possible to prevent it from stretching vertically besides adding a fixed height. We were previously using a scrollable modal, but I don't like that approach.
This is a great suggestion, we can prevent this. |
ecf75ca
to
a8e9fb9
Compare
indico/modules/rb/client/js/common/rooms/edit/RoomEditModal.jsx
Outdated
Show resolved
Hide resolved
indico/modules/rb/client/js/common/rooms/edit/RoomEditModal.jsx
Outdated
Show resolved
Hide resolved
roomId: PropTypes.number, | ||
locationId: PropTypes.number, | ||
onClose: PropTypes.func.isRequired, | ||
afterCreation: PropTypes.func, |
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.
Isn't this a bool
?
Update the room edit modal to a tabbed layout. Also refactor the form into multiple sub-components from a single object.
Create an error per tab logic that will highlight the corresponding section. Move the components part of the edit modal into an edit folder.
Form will now handle validation at field level. Also, input names were changed to snake case.
Also adds missing validation to location and removes default null fields.
Also removed the withKeyAttribute method and minor refactored validators.
Replace the hideErrorPopup prop by the native semantic-ui trigger, that shows or disables depending on the focus/hover state. Create a field dependent validation for latitude and longitude.
Also, move the coordinates validation to the form level.
Also apply minor refactorings in the same component.
also reorder some imports
Even if they aren't submit errors. Also don't show the indicator for the currently-active tab.
2d3b43e
to
8711941
Compare
Also adds missing validation and moves the form rendering outside of a function wrapper.
8711941
to
e79fcd8
Compare
Closes #3958
Update the room edit modal to a tabbed layout. Also refactor the form
into multiple sub-components from a single object.
Under heavy development and refactoring with a couple of TODOs:
by showing the affected tab, or prevent switching if any error is triggered