-
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
[Enterprise Search] Add User management feature #103173
[Enterprise Search] Add User management feature #103173
Conversation
This is shared with the forthcoming user flyouts closeRoleMappingFlyout -> closeUsersAndRolesFlyout
- Showing and hiding flyouts - Select and text input values - User created state to turn flyout into a success message state
- Users & roles -> Users and roles - roleId -> roleMappingId (matches other places in code) - also added a missing prop to the actions col
The UI sets the default group on page load but did not cover the case where the user has chosen a group in a previous interaction and the closed the flyout. This commit adds a method that resets that state when the flyout is closed Part of porting of https://github.com/elastic/ent-search/pull/3865 Specifically: https://github.com/elastic/ent-search/commit/a4131b95dab7c0df97bd78e660f25e09ac3e7cec
This was missed from the design Part of porting of https://github.com/elastic/ent-search/pull/3865 Specifically: https://github.com/elastic/ent-search/commit/03aa349cab4fb32069b64ab8c51a7252ba52e805
Role-> RoleTypes 🤷🏽♀️
Wasn’t needed in ent-search; already done for RomeMappingFlyout. Hide whitespace changes plskthx
Since we're moving fully into Kibana, we're losing our concept of auth providers. In 8.0, role mappings the specify an auth provider will no longer work, so this adds a small deprecation warning in the role mappings table. https://github.com/elastic/ent-search/pull/3885
After a slack discussion, it was determined that email should be optional. This commit also fixes another instance of the App Search role type being wrong.
⏳ Build in-progress, with failures
To update your PR or re-run it, just comment with: |
3 similar comments
⏳ Build in-progress, with failures
To update your PR or re-run it, just comment with: |
⏳ Build in-progress, with failures
To update your PR or re-run it, just comment with: |
⏳ Build in-progress, with failures
To update your PR or re-run it, just comment with: |
@elasticmachine merge upstream |
x-pack/plugins/enterprise_search/server/routes/workplace_search/role_mappings.test.ts
Show resolved
Hide resolved
} = useValues(RoleMappingsLogic); | ||
|
||
useEffect(() => { | ||
initializeRoleMappings(); | ||
return resetState; | ||
}, []); | ||
|
||
const hasUsers = singleUserRoleMappings.length > 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.
[optional techdebt for the future] I've recently been refactoring flags like these to Kea selectors, it just generally feels nicer to have them in Kea
Need to change folder and file names but will punt until after 7.14FF I did throw in updating the logic file path
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
const standardRoles = (['owner', 'admin'] as unknown) as RoleTypes[]; | ||
const advancedRoles = (['dev', 'editor', 'analyst'] as unknown) as RoleTypes[]; |
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.
Ha, fun with Typescript - this is where enums are a little nicer to use than string unions I think (not a change request, just me rambling out loud)
setMockActions({ | ||
handleSaveUser, |
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.
[not a change request, just a comment] in general in AS we put our actions in a single obj, similar to mockValues, so they don't need to be redeclared individually here:
const mockActions = { a: jest.fn(), b: jest.fn() } // etc
setMockActions(mockActions);
just a little less repetitive is all
import { RoleRules } from '../types'; | ||
|
||
import './role_mappings_table.scss'; | ||
|
||
const AUTH_PROVIDER_DOCUMENTATION_URL = `${docLinks.enterpriseSearchBase}/users-access.html`; |
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.
[optional] It might be nice to move documentation links to constants.ts
as well for organization
<EuiLink href={AUTH_PROVIDER_DOCUMENTATION_URL} target="_blank"> | ||
<EuiIconTip type="alert" color="warning" content={AUTH_PROVIDER_TOOLTIP} /> | ||
</EuiLink> | ||
</span> |
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 QAing well for me 👍
it('renders without email', () => { | ||
const wrapper = shallow(<UserAddedInfo {...props} email="" />); | ||
|
||
expect(wrapper).toMatchInlineSnapshot(` |
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.
nice, glad you got to use inline snapshots so soon! these test names are great for helping understand/look for the rendered diffs, thanks for that 💯
@@ -19,6 +19,8 @@ interface Props { | |||
roleType: string; | |||
} | |||
|
|||
const noItemsPlaceholder = <EuiTextColor color="subdued">—</EuiTextColor>; |
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.
[optional/personal preference] If this isn't being reused in multiple places, maybe just leave it in inline? 🤷
<EuiPortal> | ||
<EuiFlyout ownFocus onClose={closeUserFlyout} size="s" aria-labelledby="userFlyoutTitle"> |
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.
Nice catch on this EuiPortal!
Super optional, but as of EUI 34.x I believe EuiFlyout now defaults to ownFocus={true}
so you could leave it out if you wanted. Don't worry if you'd rather not though, there's plenty of other flyouts in our app that still have ownFocus, so we could opt to clean it up across the board in a separate PR
} | ||
|
||
export const RoleMappingsLogic = kea<MakeLogicType<RoleMappingsValues, RoleMappingsActions>>({ | ||
path: ['enterprise_search', 'app_search', 'role_mappings'], | ||
path: ['enterprise_search', 'app_search', 'users_and_roles'], |
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.
[not a change request] I wonder if we should similarly change all our folder/file names (e.g. components/role_mappings
-> components/user_and_roles
). Might make more sense in 7.15 when we're cleaning/DRYing things out though, especially if we split up the logic files into role_mappings_logic vs users_logic
const singleUserRoleMapping = values.singleUserRoleMappings.find( | ||
({ roleMapping }) => roleMapping.id === roleMappingId | ||
); |
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.
[not a change request] in a future refactor, do you think it would be worth storing a map copy of of user roles with id
as key so lookup is immediate rather than having to search through an array?... 🤔
... i'm definitely overthinking this. just give me my own paragraph in this blog post already
EDIT: HMMM wait tho, we're already using Set()
in this logic file! I mean, if we're ALREADY being all cool and microperfing, I'm just sayin'
const user = values.elasticsearchUsers.find((u) => u.username === username); | ||
if (user) actions.setElasticsearchUser(user); |
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.
[optional, just me being a jerk] i'm generally not a super huge fan of single letter vars, maybe this could help w/ specificity?
const user = values.elasticsearchUsers.find((u) => u.username === username); | |
if (user) actions.setElasticsearchUser(user); | |
const selectedUser = values.elasticsearchUsers.find((user) => user.username === username); | |
if (selectedUser) actions.setElasticsearchUser(selectedUser); |
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.
Optional comments only!! My QA was not super thorough but from what I could tell everything on AS worked with both role mappings and users 🎉
Seriously can't applaud y'all for getting this out as fast as you did, huge kudos!
* Rename method to close both flyouts This is shared with the forthcoming user flyouts closeRoleMappingFlyout -> closeUsersAndRolesFlyout * Add logic for elasticsearch users and single user role mappings * Add logic for various form states - Showing and hiding flyouts - Select and text input values - User created state to turn flyout into a success message state * Add User server routes * Add logic for saving a user * Add User components * Add User list and User flyout to RoleMappings view * Fix path * Rename things - Users & roles -> Users and roles - roleId -> roleMappingId (matches other places in code) - also added a missing prop to the actions col * Set default group when modal closed The UI sets the default group on page load but did not cover the case where the user has chosen a group in a previous interaction and the closed the flyout. This commit adds a method that resets that state when the flyout is closed Part of porting of elastic/ent-search#3865 Specifically: elastic/ent-search@a4131b9 * Adds tooltip for external attribute This was missed from the design Part of porting of elastic/ent-search#3865 Specifically: elastic/ent-search@03aa349 * Fix invitations link * Fix incorrect role type Role-> RoleTypes 🤷🏽♀️ * Add EuiPortal to Flyout Wasn’t needed in ent-search; already done for RomeMappingFlyout. Hide whitespace changes plskthx * Auth provider deprecation warning in mapping UI Since we're moving fully into Kibana, we're losing our concept of auth providers. In 8.0, role mappings the specify an auth provider will no longer work, so this adds a small deprecation warning in the role mappings table. elastic/ent-search#3885 * Email is no longer required After a slack discussion, it was determined that email should be optional. This commit also fixes another instance of the App Search role type being wrong. * Existing users’ usernames should not be editable * Use EuiLink instead of anchor * Add validation tests * Change URL for users_and_roles Need to change folder and file names but will punt until after 7.14FF I did throw in updating the logic file path * Remove unused import Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
Thanks @constancecchen! CI issues yesterday had me worried and I have PRs depending on this so I merged and just made notes of all the change requests in the refactor doc for 7.15. |
* Rename method to close both flyouts This is shared with the forthcoming user flyouts closeRoleMappingFlyout -> closeUsersAndRolesFlyout * Add logic for elasticsearch users and single user role mappings * Add logic for various form states - Showing and hiding flyouts - Select and text input values - User created state to turn flyout into a success message state * Add User server routes * Add logic for saving a user * Add User components * Add User list and User flyout to RoleMappings view * Fix path * Rename things - Users & roles -> Users and roles - roleId -> roleMappingId (matches other places in code) - also added a missing prop to the actions col * Set default group when modal closed The UI sets the default group on page load but did not cover the case where the user has chosen a group in a previous interaction and the closed the flyout. This commit adds a method that resets that state when the flyout is closed Part of porting of elastic/ent-search#3865 Specifically: elastic/ent-search@a4131b9 * Adds tooltip for external attribute This was missed from the design Part of porting of elastic/ent-search#3865 Specifically: elastic/ent-search@03aa349 * Fix invitations link * Fix incorrect role type Role-> RoleTypes 🤷🏽♀️ * Add EuiPortal to Flyout Wasn’t needed in ent-search; already done for RomeMappingFlyout. Hide whitespace changes plskthx * Auth provider deprecation warning in mapping UI Since we're moving fully into Kibana, we're losing our concept of auth providers. In 8.0, role mappings the specify an auth provider will no longer work, so this adds a small deprecation warning in the role mappings table. elastic/ent-search#3885 * Email is no longer required After a slack discussion, it was determined that email should be optional. This commit also fixes another instance of the App Search role type being wrong. * Existing users’ usernames should not be editable * Use EuiLink instead of anchor * Add validation tests * Change URL for users_and_roles Need to change folder and file names but will punt until after 7.14FF I did throw in updating the logic file path * Remove unused import Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Scotty Bollinger <scotty.bollinger@elastic.co>
closes https://github.com/elastic/enterprise-search-team/issues/597
closes https://github.com/elastic/enterprise-search-team/issues/599
closes https://github.com/elastic/enterprise-search-team/issues/668
closes https://github.com/elastic/enterprise-search-team/issues/669
closes https://github.com/elastic/enterprise-search-team/issues/654
closes https://github.com/elastic/enterprise-search-team/issues/678
Summary
This is the remaining monster PR for the User management feature in Kibana. It follows #102826 and is a combined port of https://github.com/elastic/ent-search/pull/3861 and https://github.com/elastic/ent-search/pull/3853.
There are also some bugfix ports added as the last several commits. When applicable, a link to the ent-search equivalent and/or issue is linked.
This is a DRYtemare so please ignore duplicated code.
Checklist