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

Re-introduce app provided model view override #3721

Merged
merged 22 commits into from
May 22, 2023

Conversation

timizuoebideri1
Copy link
Contributor

@timizuoebideri1 timizuoebideri1 commented May 9, 2023

Closes: #3711

What's Changed

Screenshot 2023-05-10 at 10 00 23 PM

The latest commit has the following:

  1. ExampleModel uses the Nautobot Default ObjectRetrieveView.
    Screen Shot 2023-05-12 at 3 24 33 PM
  2. AnotherExampleModel uses a Customized ModelView from example_plugin.
    Screen Shot 2023-05-12 at 3 24 44 PM
  3. Finally, the Location model uses OverridenView provided by example_plugin_with_view_override.
    Screen Shot 2023-05-12 at 3 24 23 PM

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

@bryanculver
Copy link
Member

w8... wot?

What is the code in the retrieve to render the plugin's view instead of the core one? I would have thought we accidentally removed that.

Two points:

@bryanculver bryanculver linked an issue May 10, 2023 that may be closed by this pull request
@timizuoebideri1
Copy link
Contributor Author

timizuoebideri1 commented May 10, 2023

  • Can you have it provide a view for its own model too?

Example Plugin has a model view

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.

😵 OK so I think I understand how this is working now.

What I'd like to see is three examples when starting the app with the example_plugin is installed:

  • A model provided by example_plugin that uses what we provide for it's detail view (what should be working today)
  • A model providing its own view for its own model (I suppose this is working) but isn't technically an override. It just wants to define its own view.
  • A model providing an overridden view for another model that is not its own (the thing we have to use example_plugin_with_view_override for as @glennmatthews stated above)

For the latter two cases they should have their own discrete dictionary items in the index.js

  • Here are a list of my views for my models (maybe something like views: {"example_plugin:example_models": Component})
  • Here are a list of the views I want to override elsewhere (like the existing view_overrides)

@@ -33,6 +33,7 @@

PLUGINS = [
"example_plugin",
"example_plugin_with_view_override",
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be enabled by default; again, it will break tests. It should only be enabled ad-hoc for demo purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooooh i understand now 😔

@HanlinMiao
Copy link
Contributor

HanlinMiao commented May 12, 2023

The latest commit has the following:

  1. ExampleModel uses the Nautobot Default ObjectRetrieveView.
    Screen Shot 2023-05-12 at 3 24 33 PM
  2. AnotherExampleModel uses a Customized ModelView from example_plugin.
    Screen Shot 2023-05-12 at 3 24 44 PM
  3. Finally, the Location model uses OverridenView provided by example_plugin_with_view_override.
    Screen Shot 2023-05-12 at 3 24 23 PM

Copy link
Contributor

@jathanism jathanism left a comment

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.

This file and view need to be renamed from OverridenView to OverriddenView for correct spelling of "overridden", or maybe since that kind of reads weird we might just name it OverrideView?

export { default as PluginFullWidthPageComponent } from "./FullWidthPage.jsx";
export { default as ExamplePluginRetrieveViewOverride } from "./CustomView"
export { default as PluginFullWidthPageComponent } from "./FullWidthPage";
export { default as ExamplePluginOverridenModelView } from "./OverridenView";
Copy link
Contributor

Choose a reason for hiding this comment

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

Same rename to fix the typo needs to happen here, too, please.

examples/example_plugin/example_plugin/ui/index.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
@timizuoebideri1 timizuoebideri1 changed the base branch from next to u/timizuoebideri1-3712-app-non-model-view May 16, 2023 12:55
@timizuoebideri1 timizuoebideri1 changed the base branch from u/timizuoebideri1-3712-app-non-model-view to next May 16, 2023 12:55
import { Box } from '@nautobot/nautobot-ui';

export function MyFancyCard(props) {
return <Box body>I am a full-fledge component provided by the default example App. The ID of the object I am displaying is: {props.id}</Box>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return <Box body>I am a full-fledge component provided by the default example App. The ID of the object I am displaying is: {props.id}</Box>;
return <Box body>I am a full-fledged component provided by the Example App. The ID of the object I am displaying is: {props.id}</Box>;

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this belong in #3736 instead? Seems like there's a lot of duplicated code between the two PRs, can you clarify?

@timizuoebideri1 timizuoebideri1 force-pushed the u/timizuoebideri1-3711-app-provided-model-view branch from 64d470c to 1ea2aa6 Compare May 17, 2023 16:04
@timizuoebideri1 timizuoebideri1 force-pushed the u/timizuoebideri1-3711-app-provided-model-view branch from 1ea2aa6 to 315abcb Compare May 17, 2023 16:07
@HanlinMiao
Copy link
Contributor

Removed changes in example_plugin_with_view_override, since we already proved that we can override the Location Detail View from an app.

Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

Code looks good to me. At some point we need to document this pattern in the app developer guide - is that in scope here?

@HanlinMiao
Copy link
Contributor

Code looks good to me. At some point we need to document this pattern in the app developer guide - is that in scope here?

I think this story only entails the re-introduction of the app overrides. I will open a follow-up issue that tracks this.

@HanlinMiao
Copy link
Contributor

Code looks good to me. At some point we need to document this pattern in the app developer guide - is that in scope here?

I think this story only entails the re-introduction of the app overrides. I will open a follow-up issue that tracks this.

#3773

Comment on lines +9 to +13
view_overrides: {
"example-plugin:other-models": {
"retrieve": "ExampleAppOverrideModelView"
},
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you just add one paragraph to our existing docs to this convention? Not perfect but starts getting these conventions documented.

@HanlinMiao HanlinMiao merged commit af0cc5f into next May 22, 2023
19 checks passed
@HanlinMiao HanlinMiao deleted the u/timizuoebideri1-3711-app-provided-model-view branch May 22, 2023 00:48
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 Model View
5 participants