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

chore: remove useEffects #707

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

chore: remove useEffects #707

wants to merge 5 commits into from

Conversation

gatici
Copy link
Contributor

@gatici gatici commented Jan 15, 2025

Description

This PR reduces the usage of useEffect in the NMS.
useEffect is removed from 4 different places and useQuery is used.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that validate the behaviour of the software.
  • I validated that new and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

@gatici gatici requested a review from a team as a code owner January 15, 2025 14:33
Copy link
Contributor

@patriciareinoso patriciareinoso left a comment

Choose a reason for hiding this comment

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

I get the following error when building the NMS (it was not there before) :

ReferenceError: location is not defined
    at s (.next/server/app/page.js:1:3006)
Error fetching Swagger specs: TypeError: Failed to parse URL from swagger/doc.json
    at <unknown> (.next/server/chunks/638.js:2:6875)
    at K (.next/server/chunks/638.js:2:13357)
    at <unknown> (.next/server/chunks/638.js:2:16319)
    at async (.next/server/app/(api)/api/page.js:1:3678) {
  [cause]: TypeError: Invalid URL
      at <unknown> (.next/server/chunks/638.js:2:6875)
      at K (.next/server/chunks/638.js:2:13357)
      at <unknown> (.next/server/chunks/638.js:2:16319)
      at async (.next/server/app/(api)/api/page.js:1:3678) {
    code: 'ERR_INVALID_URL',
    input: 'swagger/doc.json'
  }
}

The access to the swagger page seems fine onces it's running. I think it tries to access to the page during building when it does not exist yet because it comes from the webconsole, and the webconsole is not there yet?

@patriciareinoso
Copy link
Contributor

If the UPF and gnbs are missing where creating a new NS, the error message is no longer shown:
image

components/SubscriberModal.tsx Outdated Show resolved Hide resolved
components/SubscriberModal.tsx Outdated Show resolved Hide resolved
components/NetworkSliceModal.tsx Show resolved Hide resolved
@patriciareinoso
Copy link
Contributor

If there a no NS or DG created the DG field in Create Subscriber Modal is missing the caption:
image

@patriciareinoso
Copy link
Contributor

patriciareinoso commented Jan 16, 2025

I am running into a issue when editing the subscribers:

  1. Create a NS
  2. Add a second DG to the that NS
  3. Add a subscriber attached to the NS and a DG.
  4. Edit the subscriber to change the DG.
    -> you need to refresh the page to show the Subscriber.
    This happens as well if I change the NS of the subscriber but its does not happen if I edit the text fields.

If I have 2 subscribers and I edit one of them to change the DG, only the one I edited disappears from the list.

@patriciareinoso
Copy link
Contributor

If I delete a subscriber there are many error logs in the console
image
image

@gatici
Copy link
Contributor Author

gatici commented Jan 17, 2025

I get the following error when building the NMS (it was not there before) :

ReferenceError: location is not defined
    at s (.next/server/app/page.js:1:3006)
Error fetching Swagger specs: TypeError: Failed to parse URL from swagger/doc.json
    at <unknown> (.next/server/chunks/638.js:2:6875)
    at K (.next/server/chunks/638.js:2:13357)
    at <unknown> (.next/server/chunks/638.js:2:16319)
    at async (.next/server/app/(api)/api/page.js:1:3678) {
  [cause]: TypeError: Invalid URL
      at <unknown> (.next/server/chunks/638.js:2:6875)
      at K (.next/server/chunks/638.js:2:13357)
      at <unknown> (.next/server/chunks/638.js:2:16319)
      at async (.next/server/app/(api)/api/page.js:1:3678) {
    code: 'ERR_INVALID_URL',
    input: 'swagger/doc.json'
  }
}

The access to the swagger page seems fine onces it's running. I think it tries to access to the page during building when it does not exist yet because it comes from the webconsole, and the webconsole is not there yet?

There is way to run this command only in the server side. But it did not work for me. At the moment, I only can suppress it. I am still looking for a reasonable solution. Reverting this file can also be an option.

@gatici
Copy link
Contributor Author

gatici commented Jan 17, 2025

If the UPF and gnbs are missing where creating a new NS, the error message is no longer shown: image

The messages are shown again.

Signed-off-by: gatici <gulsum.atici@canonical.com>
Signed-off-by: gatici <gulsum.atici@canonical.com>
Signed-off-by: gatici <gulsum.atici@canonical.com>
Signed-off-by: gatici <gulsum.atici@canonical.com>
Signed-off-by: gatici <gulsum.atici@canonical.com>
@gatici gatici force-pushed the remove-use-effects branch from ef90d28 to 9a7f8d1 Compare January 17, 2025 14:19
@gatici
Copy link
Contributor Author

gatici commented Jan 17, 2025

If I delete a subscriber there are many error logs in the console image image

I do not see any error in the NMS container logs. If you still see it, Iet me know.

@gatici
Copy link
Contributor Author

gatici commented Jan 20, 2025

I am running into a issue when editing the subscribers:

1. Create a NS

2. Add a second DG to the that NS

3. Add a subscriber attached to the NS and a DG.

4. Edit the subscriber to change the DG.
   -> you need to refresh the page to show the Subscriber.
   This happens as well if I change the NS of the subscriber but its does not happen if I edit the text fields.

If I have 2 subscribers and I edit one of them to change the DG, only the one I edited disappears from the list.

I tested the subscriber edition using official image and the following scenario is not possible. Please see #711.

  1. Create a NS
  2. Add a second DG to the that NS
  3. Add a subscriber attached to the NS and a DG.

@gatici gatici marked this pull request as draft January 20, 2025 11:58
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.

3 participants