fix: avoid sending the same name in the file/folder rename modal (#5806)

This commit is contained in:
Ariel Leyva
2026-03-06 09:26:54 -05:00
committed by GitHub
parent 177c7cfcce
commit d7b00ce5f6

View File

@@ -6,7 +6,7 @@
<div class="card-content"> <div class="card-content">
<p> <p>
{{ $t("prompts.renameMessage") }} <code>{{ oldName() }}</code {{ $t("prompts.renameMessage") }} <code>{{ oldName }}</code
>: >:
</p> </p>
<input <input
@@ -33,6 +33,7 @@
type="submit" type="submit"
:aria-label="$t('buttons.rename')" :aria-label="$t('buttons.rename')"
:title="$t('buttons.rename')" :title="$t('buttons.rename')"
:disabled="name === '' || name === oldName"
> >
{{ $t("buttons.rename") }} {{ $t("buttons.rename") }}
</button> </button>
@@ -56,7 +57,7 @@ export default {
}; };
}, },
created() { created() {
this.name = this.oldName(); this.name = this.oldName;
}, },
inject: ["$showError"], inject: ["$showError"],
computed: { computed: {
@@ -67,25 +68,28 @@ export default {
"isListing", "isListing",
]), ]),
...mapWritableState(useFileStore, ["reload", "preselect"]), ...mapWritableState(useFileStore, ["reload", "preselect"]),
}, oldName() {
methods: {
...mapActions(useLayoutStore, ["closeHovers"]),
cancel: function () {
this.closeHovers();
},
oldName: function () {
if (!this.isListing) { if (!this.isListing) {
return this.req.name; return this.req.name;
} }
if (this.selectedCount === 0 || this.selectedCount > 1) { if (this.selectedCount === 0 || this.selectedCount > 1) {
// This shouldn't happen. // This shouldn't happen.
return; return "";
} }
return this.req.items[this.selected[0]].name; return this.req.items[this.selected[0]].name;
}, },
},
methods: {
...mapActions(useLayoutStore, ["closeHovers"]),
cancel: function () {
this.closeHovers();
},
submit: async function () { submit: async function () {
if (this.name === "" || this.name === this.oldName) {
return;
}
let oldLink = ""; let oldLink = "";
let newLink = ""; let newLink = "";