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

App Provided Non Model View -View Without an associated API #3736

Merged
merged 36 commits into from
May 30, 2023

Conversation

timizuoebideri1
Copy link
Contributor

@timizuoebideri1 timizuoebideri1 commented May 11, 2023

Closes: #3712

What's Changed

Screenshot 2023-05-16 at 2 30 49 PM

  • Added a View Component to the 'example_plugin' plugin.
  • Updated the 'build_ui.py' file to retrieve all Apps routes (urlspatterns) and create a react router representation of these routes, which will then be registered in nautobot-ui.

Limitation

It is currently not able to convert nested App urls.

TODO

  • Explanation of Change(s)
  • Added change log fragment(s) (for more information see the documentation)
  • Attached Screenshots, Payload Example
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)
  • Example Plugin Updates (when adding/changing features)
  • Outline Remaining Work, Constraints from Design

examples/example_plugin/example_plugin/ui/NonModelView.jsx Outdated Show resolved Hide resolved
examples/example_plugin/example_plugin/ui/NonModelView.jsx Outdated Show resolved Hide resolved
examples/example_plugin/example_plugin/ui/index.js Outdated Show resolved Hide resolved
nautobot/ui/src/components/Apps.js Outdated Show resolved Hide resolved
nautobot/ui/src/utils/nav.js Outdated Show resolved Hide resolved
nautobot/ui/src/utils/nav.js Outdated Show resolved Hide resolved
nautobot/ui/src/utils/string.js Outdated Show resolved Hide resolved
nautobot/ui/src/utils/utils.js Outdated Show resolved Hide resolved
nautobot/ui/src/views/generic/ObjectList.js Outdated Show resolved Hide resolved
@bryanculver bryanculver linked an issue May 15, 2023 that may be closed by this pull request
nautobot/core/management/commands/build_ui.py Outdated Show resolved Hide resolved
nautobot/ui/src/utils/api.js Outdated Show resolved Hide resolved
nautobot/ui/src/utils/api.js Outdated Show resolved Hide resolved
nautobot/ui/src/utils/api.js Outdated Show resolved Hide resolved
nautobot/ui/src/utils/api.js Outdated Show resolved Hide resolved
nautobot/ui/src/utils/api.js Outdated Show resolved Hide resolved
@timizuoebideri1 timizuoebideri1 marked this pull request as ready for review May 16, 2023 12:44
Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
nautobot/core/management/commands/build_ui.py Outdated Show resolved Hide resolved
nautobot/core/management/commands/build_ui.py Outdated Show resolved Hide resolved
nautobot/core/management/commands/build_ui.py Outdated Show resolved Hide resolved
nautobot/core/management/commands/build_ui.py Outdated Show resolved Hide resolved
nautobot/ui/src/utils/app-import.js Outdated Show resolved Hide resolved
Copy link
Member

@bryanculver bryanculver left a comment

Choose a reason for hiding this comment

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

I think this is almost perfect but I think we should at least seed an empty app_routes for the tests instead of a try-catch.

@bryanculver bryanculver self-requested a review May 24, 2023 15:06
timizuoebideri1 and others added 3 commits May 24, 2023 19:30
Co-authored-by: Bryan Culver <31187+bryanculver@users.noreply.github.com>
Copy link
Member

@bryanculver bryanculver left a comment

Choose a reason for hiding this comment

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

:shipit: as soon as tests pass

Comment on lines 292 to 297
- name: "Setup base app_imports for mock"
working-directory: ./nautobot/ui
run: "echo 'export const NautobotApps = {}; export default NautobotApps;' > src/app_imports.js"
- name: "Setup base app_routes.json for test"
working-directory: ./nautobot/ui
run: "echo '{}' > src/app_routes.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these steps that a developer needs to do before running invoke unittest-ui locally? If so let's make sure we have that well documented.

Are these steps that a user needs to do when installing Nautobot from pypi? Same concern.

Copy link
Member

Choose a reason for hiding this comment

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

@glennmatthews What if instead we added said file in the repo bit .gitignore and ignored all changes?

So:

echo "{}" > nautobot/ui/src/app_routes.json
git add -f nautobot/ui/src/app_routes.json

Copy link
Contributor

Choose a reason for hiding this comment

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

That's probably fine, I think?

Copy link
Member

Choose a reason for hiding this comment

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

Womp womp...

Editing .gitignore will only ignore files so they will not be added to the git repository. However files that are tracked already will not be ignored.

Testing locally it still picked up future changes to the file. I'll update the PR to create the file if it doesn't exist.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion about how we do this, just want to make sure that if it's something a developer needs to do, they are informed about it. :-)

Copy link
Member

Choose a reason for hiding this comment

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

They shouldn't have to do that anymore. Exception handling FTW!

Comment on lines +6 to +9
let app_routes = {};
try {
app_routes = require("../app_routes.json");
} catch {}
Copy link
Member

Choose a reason for hiding this comment

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

Because JavaScript I can't do:

try {
    const app_routes = require("../app_routes.json");
} catch {
    const app_routes = {};
}

@glennmatthews glennmatthews merged commit a47f9f6 into next May 30, 2023
19 checks passed
@glennmatthews glennmatthews deleted the u/timizuoebideri1-3712-app-non-model-view branch May 30, 2023 12:53
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.

UI 2.0: App Provided Non-Model View
3 participants