Skip to content
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

Merged
merged 12 commits into from
Jun 21, 2022

Conversation

jughosta
Copy link
Contributor

@jughosta jughosta commented Jun 16, 2022

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.

Screenshot 2022-06-17 at 19 15 59

Screenshot 2022-06-17 at 19 16 05

Screenshot 2022-06-17 at 19 16 27

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

@jughosta jughosta added Feature:Discover Discover Application release_note:fix Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Jun 16, 2022
@jughosta jughosta self-assigned this Jun 16, 2022
);

const createNewDataView = useCallback(() => {
const dataViewEditPermission = dataViewEditor.userPermissions.editDataView;
Copy link
Contributor Author

@jughosta jughosta Jun 17, 2022

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()

@jughosta jughosta changed the title [Discover] Hide "Add a field" and "Create a data view" buttons in viewer mode [Discover] Hide "Add a field", "Edit" and "Create a data view" buttons in viewer mode Jun 17, 2022
@jughosta jughosta marked this pull request as ready for review June 20, 2022 08:45
@jughosta jughosta requested review from a team as code owners June 20, 2022 08:45
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@jughosta
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@jloleysens jloleysens left a 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 !

Copy link
Contributor

@dej611 dej611 left a 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();
Copy link
Contributor

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 !! ...

Comment on lines +71 to +76
/**
* Handles "Edit field" action
* Buttons will be hidden if not provided
* @param fieldName
*/
editField?: (fieldName?: string) => void;
Copy link
Member

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

Copy link
Member

@kertal kertal left a 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!

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 488.1KB 487.8KB -239.0B
lens 1.2MB 1.2MB -3.0B
total -242.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jughosta

@jughosta jughosta merged commit 7410fbf into elastic:main Jun 21, 2022
@jughosta jughosta deleted the 134265-add-field-in-view-mode branch June 21, 2022 07:05
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jun 21, 2022
…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)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.3

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 21, 2022
…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]>
@nickofthyme nickofthyme linked an issue Jul 8, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Discover Discover Application release_note:fix Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.3.0 v8.4.0
Projects
None yet
7 participants