-
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
[Discover] Hide "Add a field", "Edit" and "Create a data view" buttons in viewer mode #134582
[Discover] Hide "Add a field", "Edit" and "Create a data view" buttons in viewer mode #134582
Conversation
…d only access on mobile
…ere reduced for a user in meantime
); | ||
|
||
const createNewDataView = useCallback(() => { | ||
const dataViewEditPermission = dataViewEditor.userPermissions.editDataView; |
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.
It's a function which returns a boolean .editDataView()
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
@elasticmachine merge upstream |
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.
AppServices changes LGTM! Thanks @jughosta !
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.
Tested locally, all good for @elastic/kibana-vis-editors
@@ -244,7 +244,7 @@ export const LensTopNavMenu = ({ | |||
const [indexPatterns, setIndexPatterns] = useState<DataView[]>([]); | |||
const [currentIndexPattern, setCurrentIndexPattern] = useState<DataView>(); | |||
const [rejectedIndexPatterns, setRejectedIndexPatterns] = useState<string[]>([]); | |||
const editPermission = dataViewFieldEditor.userPermissions.editIndexPattern(); | |||
const canEditDataView = !!dataViewEditor?.userPermissions.editDataView(); |
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: in Lens we usually use the convention Boolean( ... )
rather than !! ...
/** | ||
* Handles "Edit field" action | ||
* Buttons will be hidden if not provided | ||
* @param fieldName | ||
*/ | ||
editField?: (fieldName?: string) => void; |
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.
👍 for the solution and the documentation
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 👍 tested locally with a user having insufficient permissions, worked as expected. Merci!
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @jughosta |
…s in viewer mode (elastic#134582) * [Discover] Hide "Add a field" button for read only access * [Discover] Hide "Create a data view" button for read only access on desktop * [Discover] Hide "Create a data view" and "Add a field" button for read only access on mobile * [Discover] Make sure that error message is shown when access rights were reduced for a user in meantime * [Discover] Make checks safe * [Discover] Update tests * [Discover] Streamline the logic * [Discover] Update tests * [Discover] Add tests * [Discover] Add tests * [Discover] Update code style Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 7410fbf)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…s in viewer mode (#134582) (#134802) * [Discover] Hide "Add a field" button for read only access * [Discover] Hide "Create a data view" button for read only access on desktop * [Discover] Hide "Create a data view" and "Add a field" button for read only access on mobile * [Discover] Make sure that error message is shown when access rights were reduced for a user in meantime * [Discover] Make checks safe * [Discover] Update tests * [Discover] Streamline the logic * [Discover] Update tests * [Discover] Add tests * [Discover] Add tests * [Discover] Update code style Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 7410fbf) Co-authored-by: Julia Rechkunova <[email protected]>
Closes #134265
Summary
This PR hides the bottom "Add a field" button from Discover sidebar and "Create a data view" button from Unified search data view picker for desktop and mobile views if user does not have rights to edit data views.
If user opens a flyout to create a field or data view and somebody reduces that user access rights in the meantime, on Save action an error toast will be shown to the user instead of no feedback.
Checklist