-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Show/Hide apps programmatically from plugin #10286
Comments
/cc @stacey-gammon and @spalger since you were both talking about this recently. |
mark |
WARNING: this just hides the links from the side bar like you asked, it does not prevent users from accessing them with a direct url or prevent them from being linked to in other ways. In your plugin, try exporting a // my_plugin/index.js
export default (kibana) => new kibana.Plugin({
uiExports: {
replaceInjectedVars(injectedVars, request) {
if (/*some condition based on request.headers */) {
injectedVars.hiddenAppIds = ['kibana:discover'];
}
return injectedVars
},
hacks: [
'my_plugin/hacks/hide_nav'
]
}
}) Then you could consume that injected vars and hide the app links with the // my_plugin/public/hacks/hide_nav.js
import chrome from 'ui/chrome'
const hiddenAppIds = chrome.getInjected('hiddenAppIds') || []
hiddenAppIds.forEach(id => {
chrome.getNavLinkById(id).hidden = true;
}) |
Cool! Thanks @spalger, this helps a lot. |
You would need both a server-side and client-side hack that filtered all requests/route resolution. Client side you could potentially use a |
could you show some demo code? |
@sscarduzio if you get something working would you mind sharing? |
@spalger sure, I'm having a taste of what's possible for now. Full explorative phase, will hack something up soon! Once again, thanks for the suggestions. |
@sscarduzio great!!, your demo code is expected |
I made almost everything work, quite cool, it took just a day! Client side: I can successfully hide any app icon via the suggested 'hack'. I understood the hack files are the go-to place where to apply anything that has a global scope in the UI functionality. Very handy. Server side: I can prevent forced navigation to independent apps (i.e. accessing timelion from a bookmark) intercepting certain paths from the suggested hiddenApps.forEach((ha) => {
if (request.path.match('(.*/app/' + ha + '.*)|(.*/api/' + ha + '.*)')) {
forbid = true;
}
}) Unfortunately I didn't find a way to prevent forced navigation to kibana sub-apps like So I guess this can be handled via I found this example, but there's no "path" to make a conditional statement:
Suggestions on this last step? |
|
yeah, cool. that was really great if anyone can give some client side code |
@xycloud this is my current client side snippet (the "hack" file) import chrome from "ui/chrome";
uiRoutes.addSetupWork(function ($http) {
$http.get('../elasticsearch/').then((response) => {
const hiddenAppIds = response.headers()['x-kibana-hide-apps']
hiddenAppIds.split(",").forEach(id => {
chrome.getNavLinkById(id.trim()).hidden = true;
})
})
}) |
@sscarduzio then the plugin origin url cannot be access if they are hidden from client side code? |
@xycloud the above is obtaining the list of apps to hide from a header and removing the icons from the UI. I'm still doing the part where I block the navigation on the client side (I'm having some issues with the build system ATM, I lost an entire day on it because I'm not so expert with this tools). |
@sscarduzio I am sorry, could you share your code if there is any movement |
Hey guys,
}); |
@sscarduzio , where I can get your work, I am trying to get knowledge on this, thanks |
finnaly, I found another way: uiRoutes.addSetupWork(function ($http, $location, kbnUrl) { |
Linking to the work being done for Granular Application Privileges in #20277 |
@alexfrancoeur Feature Controls are doing this exact behavior. The interface for doing so isn't properly documented for external consumers as the "Spaces" and "Security" plugins are the only ones doing so. However, I'd consider this request satisfied. |
Hi guys, I don't know why but the Machine Learning App it's the only app that i can't hide. Does everybody have this issue? I think something on source code overrides my changes... |
I'm trying to write a Kibana plugin that implements role based access control, in which Kibana apps represent the resources users will have permissions to use (or not).
How can I programmatically show/hide apps from the left tabs according to the presence of some HTTP headers?
The text was updated successfully, but these errors were encountered: