Skip to content

Commit

Permalink
Disable Rename button in RenameProfileModal when renaming is in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
VilppeRiskidev committed Nov 10, 2024
1 parent 9644d4b commit 7934ac4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/profiles-modals/RenameProfileModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ProfilesMixin from "../../components/mixins/ProfilesMixin.vue";
export default class RenameProfileModal extends ProfilesMixin {
@Ref() readonly nameInput: HTMLInputElement | undefined;
private newProfileName: string = '';
private renamingInProgress: boolean = false;
@Watch('$store.state.profile.activeProfile')
activeProfileChanged(newProfile: Profile, oldProfile: Profile|null) {
Expand Down Expand Up @@ -41,12 +42,14 @@ export default class RenameProfileModal extends ProfilesMixin {
}
closeModal() {
this.renamingInProgress = false;
this.newProfileName = this.$store.state.profile.activeProfile.getProfileName();
this.$store.commit('closeRenameProfileModal');
}
async performRename() {
try {
this.renamingInProgress = true;
await this.$store.dispatch('profiles/renameProfile', {newName: this.newProfileName});
} catch (e) {
const err = R2Error.fromThrownValue(e, 'Error whilst renaming profile');
Expand Down Expand Up @@ -85,7 +88,7 @@ export default class RenameProfileModal extends ProfilesMixin {
</template>
<template v-slot:footer>
<button class="button is-danger" v-if="doesProfileExist(newProfileName)" disabled>Rename</button>
<button class="button is-info" @click="performRename(newProfileName)" v-else>Rename</button>
<button class="button is-info" @click="performRename(newProfileName)" :disabled="renamingInProgress" v-else>Rename</button>
</template>

</ModalCard>
Expand Down

0 comments on commit 7934ac4

Please sign in to comment.