-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Spaces] Space Avatar with selector in main Kibana menu #18609
Conversation
x-pack/plugins/spaces/index.js
Outdated
@@ -52,6 +54,42 @@ export const spaces = (kibana) => new kibana.Plugin({ | |||
const config = server.config(); | |||
validateConfig(config, message => server.log(['spaces', 'warning'], message)); | |||
|
|||
if (!config.get('xpack.spaces.enabled')) { |
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.
I think we shouldn't hit the init if the spaces plugin is disabled, so we should be able to remove this.
export class SpacesManager { | ||
constructor(httpAgent, chrome) { | ||
this._httpAgent = httpAgent; | ||
this.chrome = chrome; |
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.
nit: it doesn't look like this is used after storing it at this.chrome
, can we not store a reference to the chrome or rename it to this._chrome
?
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.
good catch, I'll fix this
|
||
async updateSpace(space) { | ||
return await this._httpAgent | ||
.post(`${this._baseUrl}/${space.id}?overwrite=true`, space) |
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.
Any reason why are aren't using PUT
for updates?
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.
that's an oversight - thanks!
|
||
async getActiveSpace() { | ||
if (!this._activeSpace) { | ||
this._activeSpace = await this._httpAgent |
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.
This is an interesting approach, are we executing a full-page request after switching a space so that we clear this out?
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.
I was thinking that we'd have to do a full page request after switching spaces. If we don't, then there are other implications, like changing the chrome service's basePath
, and identifying any places where that might have been cached, such as the left nav bar.
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.
that makes sense, sounds good!
return reply(); | ||
} | ||
|
||
return reply(convertSavedObjectToSpace(spaces[0])); |
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.
Can we modify this to throw that Error that we talked about if we find more than one space that matches the url-context?
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.
Yes We Can! 👍
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.
What should our behavior be when we detect this? Should a banner display at the top of the screen, should we redirect to the default space, or something else?
I don't think we should allow the user to stay in this Space, because we don't really know which space they intended to visit. If security wasn't an issue, then we could send them to the management screen, but not everybody will have access to it. We could also send them to a dedicated error page that explains what happened...maybe with a link to the management screen?
Similarly, what should the experience be when navigating to a space that doesn't exist?
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.
Most 500s from APIs will cause that toast notification that an error occurred, so doing the same thing here (if possible) makes sense to me. We do have a fatal error page that we could potentially use, but the toast notification is probably more consistent.
Also, the redirect that is occurring from the switching is just going to |
Great catch - I fixed this as well. Thanks! |
The flow seems to work well. I'm curious what the design team thinks of a modal vs. another kind of visual motif. I'm curious whether the Delete Space has all the warnings one needs. Which brings up: what happens when a space is deleted? Objects that were assigned to that space become global again? (Edit: I think this is a better place for this discussion than #18862 because that is more about SOC than Spaces itself) |
Yeah I don't love the modal. The initial mockups had the space selector in a popover, but I ran into display & positioning issues in the left nav bar, so I swapped it out...at least temporarily. I wanted to get the rest of the PR functional and not churn on that in the short term. |
What about my main question? |
The ability to delete a space and all related objects is the one of the main reasons why we scheduled the meeting this afternoon, so hopefully we'll have a better answer after this. |
Here is the The Popover is constrained to the navbar area, and it doesn't seem possible to get it to "break free" and use the rest of the available space. |
After talking with @kobelb, we decided in the interest of time that we can move forward with the Modal approach. If we would prefer the popover in the future, then we can perhaps reevaluate once we are on the new platform (where the left nav is Reactified) |
@kobelb This is ready for your review. I haven't scheduled a design review yet, but I want to merge this to our feature branch so that I can move other work forward. I'll do the UI touchups as a separate PR. I unfortunately scattered the tests across a couple of different PRs, so it's hard to see right now what has tests and what doesn't. In any event, I plan on adding more tests once I have these PRs merged together. |
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.
Looks great, one concern with our callWithInternalUser
usage, but besides that it's looking good.
}; | ||
} | ||
|
||
const callWithInternalUser = getClient(server).callWithInternalUser; |
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.
I'm assuming it's not possible to use the SavedObjectsClient here? We shouldn't be using callWithInternalUser
at least, as this has the potential to grant unauthorized users permission to the spaces... using callWithRequest
is at least safer, but the SavedObjectClient is preferable (unless we can't do so until the Client/Repository split actually happens).
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.
If I did this right, callWithInternalUser
should only be used within checkForDuplicateContext
, which tries to prevent two Spaces from existing with the same urlContext
. To do that correctly, I need to bypass the security and space filters that exist on the SavedObjectsClient.
So the short answer is "we can't do so until the Client/Repository split actually happens"
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.
Gotcha, that makes sense. As long as we have it noted that we'll need to switch this in the future, LGTM
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.
LGTM
This adds a Global Nav Link to the main Kibana Menu, which will eventually show the currently selected space. It's currently a placeholder space until we can add the correct hooks to detect the active space.
Clicking the link will display a modal allowing the user to change their space.
Space Selection Screen
When security is enabled, this will appear after logging in. Without security, this will be the initial screen users see when navigating directly to Kibana, and not to an app within Kibana:

Main Navigation
The bottom-left navigation region now shows the user's active Space. Clicking this will show a modal allowing them to switch spaces:
Space Selection Modal
Space Management
Quick Visual Walkthrough
Sorry for the low-quality GIF 🥔

TODO: