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
Get tests passing for UI 2.0 #3632
Get tests passing for UI 2.0 #3632
Conversation
# def get_serializer_context(self): | ||
# ctx = super().get_serializer_context() | ||
# ctx["request"] = None | ||
# try: | ||
# depth = int(self.request.query_params.get("depth", 0)) | ||
# except ValueError: | ||
# depth = 0 # Ignore non-numeric parameters and keep default 0 depth | ||
# ctx["depth"] = depth |
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.
Likely to be replaced with changes in #3500
@@ -36,7 +36,7 @@ def settings(request): | |||
|
|||
return { | |||
"settings": django_settings, | |||
"base_template": "base_react.html" if request.COOKIES.get("newui", False) else "base_django.html", | |||
"root_template": "base_react.html" if request.COOKIES.get("newui", False) else "base_django.html", |
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.
#3615 Introduced a bug on some views that were using the base_template
context. Missed because we didn't have passing tests, which this should fix!!!
nautobot/core/testing/views.py
Outdated
elif hasattr(self.model, "get_absolute_url"): | ||
elif ( | ||
hasattr(self.model, "get_absolute_url") and instance1.get_absolute_url() is not None | ||
): # TODO fix RelationshipAssociation |
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.
RelationshipAssociation Doesn't play well with this test case so may need some tests overloaded since this and like DynamicGroupMembers
don't make sense to have their own list vies.
sep = "" | ||
if action != "": | ||
sep = "_" if not api else "-" |
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.
Many of our routes right now do not end in _detail
or _retrieve
. For now, this works and we can choose to clean up our routes whenever instead of scope-creaping this.
# TODO: we shouldn't be importing a private-named function from another module. Should it be renamed? | ||
from nautobot.extras.templatetags.plugins import _get_registered_content | ||
|
||
temp_fake_context = { | ||
"object": instance, | ||
"request": request, | ||
"settings": {}, | ||
"csrf_token": "", | ||
"perms": {}, | ||
} | ||
|
||
plugin_tabs = _get_registered_content(instance, "detail_tabs", temp_fake_context, return_html=False) |
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.
When get to a polished implementation for plugin views we will likely overhaul this.
nautobot/core/views/mixins.py
Outdated
and obj.present_in_database | ||
and obj.pk | ||
and hasattr(obj, "get_absolute_url") | ||
and obj.get_absolute_url() is not None |
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.
Handle error now
* create list templete * create add form view templete * refactor and create NautobotInput Component * move sites/ to dcim/sites/ * move react back one folder * move react back one folder * new changes * new changes * get model fields * copy react files from plugin into nautobot frontend * fix menu * Work in progress on table * json api * Add get table fields * fix table header * Use absolte path * slugify python * Field groups * Account for status and tags * add react to example plugin * push all code * nautobot.2319 React UI components update * add docker-compose.nodejs.yml to run an nginx reverse proxy for nautobot and nodejs * remove unused ui prototype * update to work with nextjs * Revert "remove unused ui prototype" This reverts commit 7bccab7. * make react work? * add object detail view * remove comment * remove comments * add links to object detail view * fix region * Implement basic module federation for webpack - Publishes `nautobot` module as `remoteEntry.js` - Implemented webpack `config-overrides.js` using `react-app-rewired` as a dev dependency * remove nextjs ui * remove plugin file copy * optimize dev docker environment * Update react app build output paths Output js to static/reactjs Output css to static/reactcss * use global router * add postbuild script to move files to nautobot * add navmenu headers * convert prototype to nextjs * fix some imports * update to use cross site api calls * remove nginx config * update nautobot dev server to use uwsgi instead of runserver * consolidate frontend pages, update django routing for react * add plugin full width html fragment support * fix detail page layout * add plugin routes * expose django's login/logout routes * YEET * Fixing some lints and bugs. - Removed bad import in router - Fixed linting errors for unused imports - Fixed URL route on table item - Improved Docker compose file to mount node_modules as a separate volume * fix permissions issue on docker-compose in linux * fix linux docker nodejs permissions (really) * Make detail view generic * stashing * add paginator for list view * yolo * fix nautobot brand image, add some better looking icons * stashing * stashing * replace react views with base.html that's derived from the react app's index.html * Something broke but this is progress * CustomViews and Plugin Components * fix bug in detail view when json key name starts with underscore * basic management command to generate ui * tweaks * Tweaks and update * fixes and starts * update dockerfile to match next * update poetry lockfile * linting and minor bug fixes * clean up imports * fix bug * added nginx container in nodejs.yml and made nodejs serve up /static/js/bundle.js (#3057) Co-authored-by: Hanlin Miao <hanlinmiao@Hanlins-MBP-2.home> * fix runserver database exhaustion with nginx * increase keepalive timeout on nginx connection * Revert "increase keepalive timeout on nginx connection" This reverts commit d3aabdd. * increase keepalive timeout on nginx connection * clean up api for plugin react components * add web_url to all valid serializers * remove debug logging * add login view * fix js error * Implemented generic create view for React app. - Requires the nested serialization changes. - Implemented nested serialization using `?depth=` - Revert nested serializer and `brief=True` pattern - Replace it with `depth=?` arguments to views and rendering forms from JSON schema using `drf-react-template-framework` - Commented out all `brief=` and associated code - Updated `RegionSerializer` to have `parent` field fallback to default. * First pass at #3204 (#3252) * Some low-hanging fruit fixes to get us closer back to next * next-ui-2.0 cleanup and commenting (#3285) * Remove unused code added to example_plugin * Add a bunch of TODO comments * More TODO comments * Black * Flake8 * Markdownlint * Pylint * Removing some more stuff that's not needed at present * Revert a few things back to baseline * One more deletion * Fixes to example_plugin and example_plugin_with_view_override * Update comments and address a couple of TODOs * More TODO updates * web_url fixup * Added a `nautobot-server build_ui` command (#3306) - This command does the following from the `nautobot/ui` directory - Generates the `app_imports.js` file from any installed plugins - Runs `npm install` when `--npm-install` is passed - Runs `npm run build` - This command is now also called by `nautobot-server post_upgrade`, which calls it with `--npm-install` - Updated the `config-overrides.js` to not hash JS or CSS files so that their raw filename can be stored in static files and referenced using `{% static %}` (e.g. `{% static 'js/main.js %}`) without having to overload the `base.html` template for the web UI - Updated `nautobot/core/templates/base.html` to link directly to the static files for JS and CSS that get pulled in from the UI build environment by `nautobot-server collectstatic` - Parameterized the API key needed for now to read from `NAUTOBOT_API_TOKEN` environment variable - `app_imports.js` now renders with relative paths vs. absolute paths making commits that happen compatible across Docker-local and production use-cases. - Restored the `/plugins/` route and the `InstalledPlugins.jsx` module - The `build` command runs `npm` silently by default to hide the debug/warn/error messages unless `-v 2` or `-v 3` are passed. - There is some `console.log` output that is now not displayed unless `NAUTOBOT_DEBUG` environment variable is set. The `build_ui` command will also set this if verbosity is desired. - Implemented a new `invoke version` task to align versions of core with UI apps. - Will bump both `pyproject.toml` and `package.json` to keep them in sync. - If no argument is provided, displays the versions instead. - Also added `NAUTOBOT_UI_DIR` into `nautobot.core.settings` so that it can be easily reused - Moved `nautobot_ui` to `nautobot/ui` - `nautobot/ui` is now included in the package build - Added a basic README file back to `nautobot/ui` - Renamed all UI references of "plugin" to "app" After using `build_ui` it's possible to serve the entire application using Django now without requiring `node`. Of course for development `node` will still be desirable due to live rendering. * setState for islogged in * Revert "setState for islogged in" This reverts commit 596d9c1. * remove ourrunserver reference in docker compose (#3366) * UI 2.0 remove nginx container (#3367) * Initial removal of react-bootstrap and addition of nautobot-ui * Clean up devDependencies * Simplify tasks.py * Updates from feedback * Add node_modules ignore * move 'api/' ui related urls under 'api/ui/' (#3385) * move 'api/' ui related urls under 'api/ui/' * flake8 * address PR feedback * exclude get-menu api endpoint from OpenAPI schema and add documentation for UI-related API endpoints * flake8 * mdlint * elaborate UI-related endpoints documentation * update mkdocs.yml --------- Co-authored-by: Hanlin Miao <hanlinmiao@Hanlins-MBP-2.home> * Logged in state for nautobot-ui (#3356) * Update from fix nautobot/nautobot-ui#9 * Black * Hadolint * More hadolint * UI docker dev environment tweaks (#3408) * Don't copy node_modules and UI build when rebuilding docker image * Capture npm output and print it in case of failures * Create docker volume for node_modules, change container startup, update docs * nautobot-ui is public now; can use node:18-slim * Add TODO comments * Add unittest for all react components (#3404) * Add test for component common * common test case * Done testing core * Add test for BSTableItem Component * Add partial views test * Add test for views * add doc * run ui unittest * Apply suggestions from code review Co-authored-by: Hanlin Miao <46973263+HanlinMiao@users.noreply.github.com> * fix markdown * update ReadMe * Update nautobot/ui/README.md Co-authored-by: Bryan Culver <31187+bryanculver@users.noreply.github.com> * Merge conflicts * Update README.md --------- Co-authored-by: Hanlin Miao <46973263+HanlinMiao@users.noreply.github.com> Co-authored-by: Bryan Culver <31187+bryanculver@users.noreply.github.com> Co-authored-by: Bryan Culver <bryan.culver@networktocode.com> * UI 2.0 Cleanup (#3444) * Provide a way to refresh CSRF without shortcutting CSRF protections * Session endpoint * Stashing to switch between computers * more stashing * yeeet * This is going to be a lot * Updates * Updates from feedback * Black & flake8 * Fix indention * Remove top-level package lock * Revert bad merge * UI 2.0: Cleanup Router Links, Import Font as Source (#3482) * Cleanup Router Links * Move font to built-in instead of served via Google Fonts. * Remove unneccessary import * UI 2.0: Introduce Prettier, Use ESLint for Formatting and Linting (#3531) * Move to craco (#3546) Fix Jest testing Remove should be ignored paths file as this is autogenerated Scope creep avoid get tests passing so we can demonstrate it's working. Prettier... Add base paths for testing No cached example, just copy the template in CI Mock would prefer a file exists for app_imports.js * Add New UI Toggle (#3615) * Add New UI Toggle * Add changelog fragment. * Prettier * Fix corrupted package-lock.json (#3618) * Fix corrupted package-lock.json * Add changelog fragment. * Remove duplicate package for nautbot-ui * Get tests passing for UI 2.0 (#3632) * Get tests passing for UI 2.0 * Add changelog fragment. * Updates from feedback * Exception handling * Fix CI step merge * Pylint * Fix changes from next * UI 2.0 Implement GenericView component (#3626) * [UI 2.0] Implement GenericView component * [UI 2.0] Add missing objectData prop to GenericView in ObjectRetrieve view * [UI 2.0] Remove Current route is ... debug message * Move popover to it's own component. --------- Co-authored-by: Bryan Culver <bryan.culver@networktocode.com> Co-authored-by: Bryan Culver <me@bryanculver.com> * 👟 --------- Co-authored-by: Timizuo <timizuoebideri@gmail.com> Co-authored-by: Chris Thant <chris.thant@networktocode.com> Co-authored-by: Gary Snider <gary.snider@networktocode.com> Co-authored-by: jathanism <jathan@gmail.com> Co-authored-by: Hanlin Miao <46973263+HanlinMiao@users.noreply.github.com> Co-authored-by: Hanlin Miao <hanlinmiao@Hanlins-MBP-2.home> Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com> Co-authored-by: Gary Snider <75227981+gsnider2195@users.noreply.github.com> Co-authored-by: Timizuo <94907097+timizuoebideri1@users.noreply.github.com> Co-authored-by: Norbert Mieczkowski <117445994+norbert-mieczkowski-codilime@users.noreply.github.com>
Closes: #DNE
What's Changed
web_url
payload on the serializer which may need to be tweaked once ReplaceNestedFooSerializer
and?brief=True
parameters using DRF's built-inself.Meta.depth
#3500 is mergedget_absolute_url()
onBaseModel
#2901TODO