Network UI: add external uri path hint (#27659)

This commit is contained in:
Michael Geers 2026-02-25 14:35:14 +01:00 • committed by GitHub
parent 70734fb954
commit aebbca195c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 22 additions and 2 deletions

View file

@ -16,6 +16,9 @@
<slot />
</div>
<div v-if="error" class="invalid-feedback d-block">{{ error }}</div>
<div v-if="warning" class="form-text text-warning mt-1" role="status">
{{ warning }}
</div>
<div class="form-text evcc-gray">
<div v-if="example" class="hyphenate">
{{ $t("config.form.example") }}: {{ example }}
@ -47,6 +50,7 @@ export default {
optional: Boolean,
deprecated: Boolean,
error: String,
warning: String,
danger: String,
example: String,
docsLink: String,

View file

@ -43,6 +43,7 @@
id="networkExternalUrl"
:label="$t('config.network.labelExternalUrl')"
:help="$t('config.network.descriptionExternalUrl')"
:warning="urlPathWarning(values.externalUrl)"
example="https://evcc.example.org"
optional
>
@ -83,6 +84,16 @@ export default {
components: { FormRow, JsonModal },
emits: ["changed"],
methods: {
urlPathWarning(url) {
try {
if (new URL(url).pathname > "/") {
return this.$t("config.network.warningUrlPath");
}
} catch {
// ignore
}
return null;
},
transformWriteValues(values) {
const payload = { ...values };
delete payload.internalUrl;

View file

@ -568,7 +568,8 @@
"labelHost": "mDNS-Hostname",
"labelInternalUrl": "Interne URL",
"labelPort": "Port",
"title": "Netzwerk"
"title": "Netzwerk",
"warningUrlPath": "Die URL benötigt normalerweise keinen Pfad. Bist du dir sicher?"
},
"ocpp": {
"connectedChargers": "Verbundene Wallboxen",

View file

@ -568,7 +568,8 @@
"labelHost": "mDNS Hostname",
"labelInternalUrl": "Internal URL",
"labelPort": "Port",
"title": "Network"
"title": "Network",
"warningUrlPath": "The URL usually doesn't need a path. Are you sure this is correct?"
},
"ocpp": {
"connectedChargers": "Connected chargers",

View file

@ -102,7 +102,10 @@ test.describe("network modal", async () => {
await expectModalVisible(modal);
const portValue = await modal.getByLabel("Port").inputValue();
await modal.getByLabel("External URL").fill(NETWORK_EXTERNAL_URL + "/somepath");
await expect(modal.getByRole("status")).toContainText("doesn't need a path");
await modal.getByLabel("External URL").fill(NETWORK_EXTERNAL_URL);
await expect(modal.getByRole("status")).not.toBeVisible();
await modal.getByLabel("mDNS Hostname").fill(NETWORK_HOST);
await modal.getByRole("button", { name: "Save" }).click();