-
Notifications
You must be signed in to change notification settings - Fork 4
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
Port forward: ui fixes and better error handling #56
Changes from 5 commits
7f1aef4
2c2e6d1
9a5a702
cf575cb
acc8aa1
f81f37b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,13 +165,25 @@ watchEffect(() => { | |
}) | ||
|
||
function close() { | ||
if ( | ||
error.value.notificationTitle === t('error.cannot_edit_port_forward') || | ||
error.value.notificationTitle === t('error.cannot_create_port_forward') | ||
) { | ||
error.value.notificationTitle = '' | ||
error.value.notificationDescription = '' | ||
} | ||
validationErrorBag.value.clear() | ||
restrictIPValidationErrors.value = [] | ||
|
||
resetForm() | ||
emit('close') | ||
} | ||
|
||
onMounted(() => { | ||
fetchOptions() | ||
firewallConfig.fetch() | ||
if (firewallConfig.loading || firewallConfig.error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain this condition? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Considering how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Now it's clear, thanks |
||
firewallConfig.fetch() | ||
} | ||
}) | ||
|
||
function resetRestrictIPValidationErrors() { | ||
|
@@ -286,13 +298,17 @@ async function createOrEditPortForward() { | |
" | ||
> | ||
<NeInlineNotification | ||
v-if="error.notificationTitle" | ||
:title="error.notificationTitle" | ||
:description="error.notificationDescription" | ||
v-if="error.notificationTitle || firewallConfig.error" | ||
:title="firewallConfig.error ? t('error.cannot_retrieve_zones') : error.notificationTitle" | ||
:description=" | ||
firewallConfig.error | ||
? t(getAxiosErrorMessage(firewallConfig.error)) | ||
: error.notificationDescription | ||
" | ||
class="mb-6" | ||
kind="error" | ||
/> | ||
<NeSkeleton v-if="loading || firewallConfig.loading" :lines="10" /> | ||
<NeSkeleton v-if="loading || firewallConfig.loading || firewallConfig.error" :lines="10" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We usually don't show a skeleton if an error is displayed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, this is true but doing it this way could also cause a scenario where the user can interact with the form even if the firewallConfig fetch did not go as planned... How should we handle this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If an error occurs while retrieving drawer data we usually display only the error and hide the form There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, now if there's an error while fetching the firewall config the form does not show. I've also removed the condition from the skeleton. |
||
<div v-else class="flex flex-col gap-y-6"> | ||
<NeToggle :label="t('standalone.port_forward.status')" v-model="enabled" /> | ||
<NeTextInput | ||
|
@@ -327,13 +343,6 @@ async function createOrEditPortForward() { | |
></template | ||
> | ||
</NeTextInput> | ||
<NeCombobox | ||
:label="t('standalone.port_forward.destination_zone')" | ||
:placeholder="t('standalone.port_forward.choose_zone')" | ||
:options="supportedDestinationZones" | ||
:selected-label="t('standalone.port_forward.any_zone')" | ||
v-model="destinationZone" | ||
/> | ||
<NeTextInput | ||
:label="t('standalone.port_forward.destination_port')" | ||
v-model="destinationPort" | ||
|
@@ -353,12 +362,18 @@ async function createOrEditPortForward() { | |
</NeButton> | ||
</div> | ||
<template v-if="showAdvancedSettings"> | ||
<NeCombobox | ||
:label="t('standalone.port_forward.destination_zone')" | ||
:placeholder="t('standalone.port_forward.choose_zone')" | ||
:options="supportedDestinationZones" | ||
:selected-label="t('standalone.port_forward.any_zone')" | ||
v-model="destinationZone" | ||
/> | ||
<NeCombobox | ||
:label="t('standalone.port_forward.wan_ip')" | ||
:options="wanInterfaces" | ||
v-model="wan" | ||
/> | ||
|
||
<NeMultiTextInput | ||
:title="t('standalone.port_forward.restrict_access_to')" | ||
:optional="true" | ||
|
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.
Is this condition needed?
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.
Not strictly needed, but if the error is given by a failed request of the form's options then clearing it could be confusing if the user reopens it again (they would see no error notification, but the options still aren't available), whereas for edit/create request errors it makes sense because the item gets cleared on exit. Maybe at this point we should simply refetch the options every time the drawer is opened, in case of an error?
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.
Yes, if the drawer need some data we usually fetch it every time it opens, so we can get updated data. If the code doesn't currently work this way we can postpone these changes to another PR, it's not an essential feature at the moment.
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.
Ok, I've updated the drawer so that it refetches the data every time it is shown, now it should be ok. I've also removed the aforementioned condition because of this change.