-
Notifications
You must be signed in to change notification settings - Fork 77
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
WIP: Plugable NavTabs implementation candidate #775
WIP: Plugable NavTabs implementation candidate #775
Conversation
/cc @orlandohohmeier |
Hey @daltonmatos, thanks a lot for your proposal! Please excuse my late response, we're currently busy cutting the 1.8 DC/OS release and haven't found much time to review PRs. |
Hello @orlandohohmeier, First of all, thank you very much for your time to take a quick look at this proposal. I'm glad you liked it at the first look. Don't worry about the late response, take your time to look at it more deeply so when can discuss all the technical details. I also still have to think about the routing implementation. I have 2 approaches in mind:
These are just loose ideas that passed through my head, let me know what do you think about this part of the implementation. I'm sure we will find a good solution to this. Thanks a lot! |
Hello all! I added one more commit that makes us closer to a fully functional code. Now the core of marathon-ui listens to the I took some time to realize that there are two Does it make sense to unify these two? This is the patch applied to the marathon-ui-example-plugin project: diff --git a/src/main/js/main.js b/src/main/js/main.js
index bb925f6..f496570 100644
--- a/src/main/js/main.js
+++ b/src/main/js/main.js
@@ -1,7 +1,18 @@
import ExamplePluginComponent from "./components/ExamplePluginComponent";
const {PluginHelper, PluginMountPoints} = window.marathonPluginInterface;
+const {PluginDispatcher, PluginEvents} = window.marathonPluginInterface;
PluginHelper.registerMe();
PluginHelper.injectComponent(ExamplePluginComponent,
PluginMountPoints.SIDEBAR_BOTTOM);
+PluginDispatcher.dispatch({
+ eventType: PluginEvents.APPEND_NAVTAB,
+ data: [
+ {
+ id: "/mesos",
+ text: "Mesos",
+ component: ""
+ }
+ ]
+}); And after re-building the plugin and copying the resulting The last step is the route registering implementation. When this is done we will be able to fill the Let me know what you think. |
Moving APPEND_NAVTAB to plugin/shared/PluginEvents.js since this is what is exposed to plugins.
Hello @orlandohohmeier, I tried some approaches on the dynamic route implementation but I think I will need your help on this, not just with ideas but maybe with some code. I tried to use the + var newroute = new Route({
+ name: "Mesos",
+ path: "/mesos",
+ handler: DummyComponent
+ });
+ this.context.router.addRoutes(newroute);
+ this.context.router.refresh(); I discovered the Another approach was to create a new wildcard Route (inside +import PluginRouteComponent from "./components/PluginRouteComponent";
var routes = (
<Route name="home" path="/" handler={Marathon}>
@@ -17,6 +18,7 @@ var routes = (
<Route name="taskView" path="apps/:appId/:view/:tab"
handler={AppPageComponent} />
<Route name="deployments" path="deployments" handler={TabPanesComponent} />
+ <Route name="plugin" path="plugin/:id" handler={PluginRouteComponent} />
<Redirect from="/" to="apps" />
<NotFoundRoute name="404" handler={PageNotFoundComponent} />
</Route> This means that any tab added by a plugin must use the path This works, but is not the way I wanted it to be. This limits the power of what a plugin can do and would probably invalidade a possible "Login Plugin", for example, since such plugin would very likely want to hijack the root route ( So I would like to have your help on this part of the implementation, more specifically:
Thanks a lot! |
Hello @orlandohohmeier, Do you think that splitting this PR in two would make this implementation more likely to be merged? The idea would be:
Let me know and I will split the code and open the PRs. Thanks, |
Hey @daltonmatos, I'm really sorry that I still haven't found the time to look into the details of your PR - I had to prioritize bug fixes over features. 👼 Let's not split this into different PRs as the number of changes is rather small and I don't think that it will help streamlining the process. I can't say this enough, your work is highly appreciated and more than welcome! |
Thanks a lot @orlandohohmeier !! I fully understand you! Again, thanks a lot for taking your time to look at this. |
Hello all, I'm putting this PR on hold because of the announcement about the discontinuation of marathon-ui in favor of DC/OS-ui. Commit: 05ce810 |
@daltonmatos I'm really sorry that we didn't manage to land this feature. Thanks again for your work! |
No problem @orlandohohmeier! It was, in fact, very fun to write this code, learn about ReactJS and the Marathon-ui code base. I plan to implement this same feature in DC/OS-ui. I just have to reserve some time do study the code and start the implementation. |
@daltonmatos Hope you're ok with me closing this PR as we first need to updated react and react router to enable the needed capabilities to properly implement this feature. |
No Problem, @orlandohohmeier. I will come back to this implementation in the future. Maybe there's a way to do it without havbing to update |
Hello,
Here is a Pul lRequest with an idea of implementation of issue #4169. The ideia here uses the Event firing approach.
What have been done
js/constants/tabs.js
was replaced with a ne NavTabStore (js/stores/NavTabStore.js
);js/constants/tabs.js
now imports the newNavTabStore
and call itsgetTabs()
method.PluginDispatcher
, this functions is intended to be used by plugins that want to append a new navtab. This functions generates a new event,NavTabEvents.CHANGE
. The ideia of this event is to re-render all components that relates to navtab rendering;js/components/TabPanesComponent.jsx
was refactored to extract each tab to a new React component (Deployments tab was already extracted, so only Applications tab was extracted and generated a new component:js/components/AppsAndGroupsListComponent.jsx
);What still needs to be done
window.marathonPluginInterface
? Maybe a better approach would be to register the new route automatically after appending the new tab to the internal array. This is possible because the Tab ID is also the Tab route. Maybe a future modification could allow a Tab to choose which React route it wants to use.Final considerations
Let me know what do you think. Don't worry about the commits, I will squash any commit as needed, just say it. Also I will rebase this code when needed. This is a work in progress, is here for revision and suggestions.
Thanks a lot.