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

Port forward: ui fixes and better error handling #56

Merged
merged 6 commits into from
Oct 11, 2023

Conversation

kevincela
Copy link
Collaborator

  • add error handling for fetching firewall config inside CreateOrEditPortForwardDrawer
  • move destination zone combobox inside advanced settings in CreateOrEditPortForwardDrawer
  • replace empty cards in PortForward page with NeEmptyState
  • clear errors when exiting CreateOrEditPortForwardDrawer

- move destination zone combobox inside of advanced settings
- handle firewall config error in port forward drawer
- avoid fetching firewall config if data is already loaded
- clear error on close only on add/edit request errors
@kevincela kevincela requested a review from andre8244 October 11, 2023 08:55
@@ -165,13 +165,25 @@ watchEffect(() => {
})

function close() {
if (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this condition needed?

Copy link
Collaborator Author

@kevincela kevincela Oct 11, 2023

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?

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

class="mb-6"
kind="error"
/>
<NeSkeleton v-if="loading || firewallConfig.loading" :lines="10" />
<NeSkeleton v-if="loading || firewallConfig.loading || firewallConfig.error" :lines="10" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually don't show a skeleton if an error is displayed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

If an error occurs while retrieving drawer data we usually display only the error and hide the form

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

resetForm()
emit('close')
}

onMounted(() => {
fetchOptions()
firewallConfig.fetch()
if (firewallConfig.loading || firewallConfig.error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this condition?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering how useFirewallStore is a global store and is used in different pages other than the port forward one, I thought it wouldn't make much sense to refetch its items when they already loaded, hence why i've included this condition. If you think this may cause issues I can remove it though!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering how useFirewallStore is a global store and is used in different pages other than the port forward one, I thought it wouldn't make much sense to refetch its items when they already loaded, hence why i've included this condition. If you think this may cause issues I can remove it though!

Now it's clear, thanks

- refetch items every time the drawer is shown, instead of onmounted
- clear errors every time the drawer is closed
- remove firewallconfig fetch error from skeleton
- avoid showing form if there is a firewallconfig fetch error
@kevincela kevincela requested a review from andre8244 October 11, 2023 11:09
@andre8244 andre8244 merged commit 101830e into NethServer:main Oct 11, 2023
3 checks passed
@kevincela kevincela deleted the port-forward-page-fixes branch October 17, 2023 13:24
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