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

Added preset renaming #148

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Added preset renaming #148

wants to merge 1 commit into from

Conversation

FyWolf
Copy link

@FyWolf FyWolf commented Nov 25, 2024

  • Added new "rename" modal and button to presets
    image
    image

  • Modified preset modlist modifications icon to match server page modlist icon
    image

@FyWolf FyWolf changed the base branch from master to dev November 27, 2024 10:31
@fugasjunior
Copy link
Owner

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}")
Copy link
Owner

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:

  1. Change this endpoint to @PatchMapping("/rename/{id}")
  2. 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();
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants