-
Notifications
You must be signed in to change notification settings - Fork 17
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
Added preset renaming #148
base: dev
Are you sure you want to change the base?
Conversation
Great job with this! I'm wondering whether it would be possible to move the rename button next to the preset name in the table? It might make it more obvious that this button only changes the preset name. |
@@ -89,6 +90,24 @@ public ResponseEntity<PresetResponseDto> updatePreset( | |||
return ResponseEntity.ok(modPresetMapper.mapToModPresetDto(modPreset)); | |||
} | |||
|
|||
@PutMapping("/rename/{id}") |
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 believe PATCH would be more accurate as just a one attribute is being changed. PUT would be appropriate when the whole preset would be replaced, including the mods.
I'd go for either of these solutions:
- Change this endpoint to
@PatchMapping("/rename/{id}")
- Reuse the existing endpoint
@PutMapping("/{id}")
and also send the mods in the body when renaming the preset.
I'd personally prefer option 2), but I'm fine with either one.
|
||
await renameModPreset(presetId, request); | ||
toast.success(`Preset '${presetName}' successfully renamed`); | ||
window.location.reload(); |
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.
Using window.location.reload()
is not ideal to re-render the changes. Instead, you should modify the state of the component, in this case the presets
state.
Something like this should work:
const newPresets = [...presets]; // create a copy of the original state
const renamedPreset = newPresets.find(preset => preset.id === presetId); // find the renamed preset by ID
renamedPreset.name = presetName; // edit the preset name
setPresets(newPresets); // set the new state with renamed preset
This should automatically re-render the component with the new state.
Added new "rename" modal and button to presets
Modified preset modlist modifications icon to match server page modlist icon