elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.73k stars 8.14k forks source link

Support un-sharing saved objects from current space in saved objects management UI #169865

Open jeramysoucy opened 11 months ago

jeramysoucy commented 11 months ago

Kibana version: <= 8.11.0

Description: On the saved objects management screen, it is currently not possible to un-share a saved object from the current space. This is a result of the share flyout when the behaviorContext property is set to 'within-space'.

Steps to reproduce:

  1. Create a sharable saved object (e.g. saved query)
  2. Create an additional space
  3. Navigate to the saved objects management screen
  4. Select the 'share to space' action for the object you created
  5. Observe that the current space cannot be removed, even if the additional space is selected

Expected behavior: A user with adequate privileges should be able to remove the current space from an object, as long as the object exists in at least one other space. The behavior of the flyout should simply enforce a minimum of one selected space, and should notify the user that the saved object must exist in at least one space when no spaces are selected. This is very close to the behavior of the flyout when the behaviorContext property is set to 'outside-space', however, this mode does not provide any in-line feedback as to why the changes cannot be applied when no spaces are selected. This can be observed in the machine learning jobs screen.

elasticmachine commented 11 months ago

Pinging @elastic/kibana-security (Team:Security)

teresaalvarezsoler commented 10 months ago

Hi team, do you have any ETA for this work? We depend on it in order to launch sharing dashboards across spaces in 8.12, thanks! https://github.com/elastic/kibana/issues/167959#issuecomment-1791296434

jeramysoucy commented 10 months ago

@teresaalvarezsoler It is not currently assigned to a sprint/iteration. We have a planning snyc tomorrow and I will bring this up.

cc: @legrego

legrego commented 10 months ago

@teresaalvarezsoler the platform already supports this functionality via the behaviorContext: 'outside-space' configuration setting that @jeramysoucy outlined in the description. If I understand this issue correctly (@jeramysoucy keep me honest), we are looking to improve the UX to make it more intuitive. Functionally, there shouldn't be anything preventing consumers from using this existing configuration property, and they'll benefit from the UX improvement when it lands.

jeramysoucy commented 10 months ago

we are looking to improve the UX to make it more intuitive. Functionally, there shouldn't be anything preventing consumers from using this existing configuration property, and they'll benefit from the UX improvement when it lands.

That's correct. You could use the ShareToSpaceFlyout with behaviorContext of 'outside-space', and this would provide the desired functionality. This issue addresses making this the default behavior under Stack Management -> Saved Objects, and improving the UX with better messaging, etc.

nickpeihl commented 10 months ago

That's correct. You could use the ShareToSpaceFlyout with behaviorContext of 'outside-space', and this would provide the desired functionality. This issue addresses making this the default behavior under Stack Management -> Saved Objects, and improving the UX with better messaging, etc.

Thanks for clarifying. However, even with behaviorContext: 'outside-space', I'm still seeing the active space disabled.

However, I think I've narrowed it down to https://github.com/elastic/kibana/blob/main/x-pack/plugins/spaces/public/share_saved_objects_to_space/components/selectable_spaces_control.tsx#L272-L278. This function appears to be called regardless of the behaviorContext. So it always disables the active space. Is this check superfluous or should it be modified to check the behaviorContext?

jeramysoucy commented 10 months ago

@nickpeihl Interesting. Following the chain, behaviorContext is used to set enableSpaceAgnosticBehavior, which is passed down to ShareToSpaceForm and then ShareModeControl and finally to SelectableSpacesControl, which is what is used to set (or not) the activeSpaceId. Somewhere along the line, there must be a issue. Where are you setting behaviorContext to 'outside-space'?

jeramysoucy commented 10 months ago

@nickpeihl I think the only example is in the ML SO list, which appears to have the expected behavior.

nickpeihl commented 10 months ago

@jeramysoucy I'm setting the behaviorContext here. https://github.com/elastic/kibana/pull/170359/files#diff-60851e27573386d5d4d9668ef0c26a8555d937abeb110047c661a1a946bfab4eR60-R70

The SelectableSpacesControl calls the getAdditionalProps function and uses that to disable the active space in the flyout.

I'll review how ML handles this to see if there's something obvious that I am missing. 👀

nickpeihl commented 10 months ago

Ah, nevermind. I figured out what I did wrong. I was not passing the behaviorContext to the right component. Sorry for the noise.

https://media.giphy.com/media/pJmnk86fXFNmrUb8LB/giphy.gif