-
Notifications
You must be signed in to change notification settings - Fork 13k
chore: new field for ABAC Attributes on user info #37135
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
18553f7
feat: add basic tags components
MartinSchoeler d392747
test: add tests
MartinSchoeler b6e13e8
test: use correct translation key on tests
MartinSchoeler 01247ee
review: Don't use userCard Component
MartinSchoeler 98846b4
reviews: less props and move tooltip
MartinSchoeler 51d5b73
chore: update label usage
MartinSchoeler a9fb546
reviews: make component prettier :)
MartinSchoeler cdfcd48
snapshot
MartinSchoeler 1653f8b
review: :(
MartinSchoeler 4072d2c
test: oh snap
MartinSchoeler d476132
fix: simplify tests
dougfabris c626706
Merge branch 'develop' into feat/ABAC-user-attributes
kodiakhq[bot] dbe15ce
test: snapshot
dougfabris 67b5b65
Merge branch 'develop' into feat/ABAC-user-attributes
MartinSchoeler 40d8233
Merge branch 'develop' into feat/ABAC-user-attributes
MartinSchoeler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { composeStories } from '@storybook/react'; | ||
| import { render } from '@testing-library/react'; | ||
| import { axe } from 'jest-axe'; | ||
|
|
||
| import * as stories from './UserInfo.stories'; | ||
|
|
||
| const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]); | ||
| test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => { | ||
| const { baseElement } = render(<Story />); | ||
| expect(baseElement).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test.each(testCases)('%s should have no a11y violations', async (_storyname, Story) => { | ||
| const { container } = render(<Story />); | ||
|
|
||
| const results = await axe(container); | ||
| expect(results).toHaveNoViolations(); | ||
| }); |
41 changes: 21 additions & 20 deletions
41
apps/meteor/client/components/UserInfo/UserInfo.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,42 @@ | ||
| import type { Meta, StoryFn } from '@storybook/react'; | ||
|
|
||
| import { Contextualbar } from '../Contextualbar'; | ||
| import { ContextualbarDialog } from '../Contextualbar'; | ||
| import * as Status from '../UserStatus'; | ||
| import UserInfo from './UserInfo'; | ||
| import { UserCardRole } from '../UserCard'; | ||
|
|
||
| export default { | ||
| component: UserInfo, | ||
| parameters: { | ||
| layout: 'fullscreen', | ||
| actions: { argTypesRegex: '^on.*' }, | ||
| }, | ||
| decorators: [(fn) => <Contextualbar height='100vh'>{fn()}</Contextualbar>], | ||
| decorators: [ | ||
| (fn) => ( | ||
| <ContextualbarDialog aria-label='User Info' height='100vh'> | ||
| {fn()} | ||
| </ContextualbarDialog> | ||
| ), | ||
| ], | ||
| } satisfies Meta<typeof UserInfo>; | ||
|
|
||
| const Template: StoryFn<typeof UserInfo> = (args) => <UserInfo {...args} />; | ||
|
|
||
| export const Default = Template.bind({}); | ||
| Default.args = { | ||
| const defaultArgs = { | ||
| name: 'Guilherme Gazzo', | ||
| username: 'guilherme.gazzo', | ||
| nickname: 'gazzo', | ||
| statusText: '🛴 currently working on User Card', | ||
| bio: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tempus, eros convallis vulputate cursus, nisi neque eleifend libero, eget lacinia justo purus nec est. In at sodales ipsum. Sed lacinia quis purus eget pulvinar. Aenean eu pretium nunc, at aliquam magna. Praesent dignissim, tortor sed volutpat mattis, mauris diam pulvinar leo, porta commodo risus est non purus. Mauris in justo vel lorem ullamcorper hendrerit. Nam est metus, viverra a pellentesque vitae, ornare eget odio. Morbi tempor feugiat mattis. Morbi non felis tempor, aliquam justo sed, sagittis nibh. Mauris consequat ex metus. Praesent sodales sit amet nibh a vulputate. Integer commodo, mi vel bibendum sollicitudin, urna lectus accumsan ante, eget faucibus augue ex id neque. Aenean consectetur, orci a pellentesque mattis, tortor tellus fringilla elit, non ullamcorper risus nunc feugiat risus. Fusce sit amet nisi dapibus turpis commodo placerat. In tortor ante, vehicula sit amet augue et, imperdiet porta sem.', | ||
| // actions: [<UserCard.Action icon='message'/>, <UserCard.Action icon='phone'/>], | ||
| utcOffset: -3, | ||
| bio: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tempus, eros convallis vulputate cursus, nisi neque eleifend libero, eget lacinia justo purus nec est. In at sodales ipsum. Sed lacinia quis purus eget pulvinar. Aenean eu pretium nunc, at aliquam magna. Praesent dignissim, tortor sed volutpat mattis, mauris diam pulvinar leo, porta commodo risus est non purus.', | ||
| email: '[email protected]', | ||
| status: <Status.Offline />, | ||
| roles: [<UserCardRole key='admin'>admin</UserCardRole>, <UserCardRole key='user'>user</UserCardRole>], | ||
| }; | ||
|
|
||
| export const WithNickname = Template.bind({}); | ||
| WithNickname.args = { | ||
| name: 'Guilherme Gazzo', | ||
| username: 'guilherme.gazzo', | ||
| statusText: '🛴 currently working on User Card', | ||
| bio: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tempus, eros convallis vulputate cursus, nisi neque eleifend libero, eget lacinia justo purus nec est. In at sodales ipsum. Sed lacinia quis purus eget pulvinar. Aenean eu pretium nunc, at aliquam magna. Praesent dignissim, tortor sed volutpat mattis, mauris diam pulvinar leo, porta commodo risus est non purus. Mauris in justo vel lorem ullamcorper hendrerit. Nam est metus, viverra a pellentesque vitae, ornare eget odio. Morbi tempor feugiat mattis. Morbi non felis tempor, aliquam justo sed, sagittis nibh. Mauris consequat ex metus. Praesent sodales sit amet nibh a vulputate. Integer commodo, mi vel bibendum sollicitudin, urna lectus accumsan ante, eget faucibus augue ex id neque. Aenean consectetur, orci a pellentesque mattis, tortor tellus fringilla elit, non ullamcorper risus nunc feugiat risus. Fusce sit amet nisi dapibus turpis commodo placerat. In tortor ante, vehicula sit amet augue et, imperdiet porta sem.', | ||
| // actions: [<UserCard.Action icon='message'/>, <UserCard.Action icon='phone'/>], | ||
| utcOffset: -3, | ||
| email: '[email protected]', | ||
| status: <Status.Offline />, | ||
| nickname: 'Nickname', | ||
| const Template: StoryFn<typeof UserInfo> = (args) => <UserInfo {...defaultArgs} {...args} />; | ||
|
|
||
| export const Default = Template.bind({}); | ||
|
|
||
| export const WithABACAttributes = Template.bind({}); | ||
| WithABACAttributes.args = { | ||
| // @ts-expect-error - abacAttributes is not yet implemented in Users properties | ||
| abacAttributes: ['Classified', 'Top Secret', 'Confidential'], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
apps/meteor/client/components/UserInfo/UserInfoABACAttribute.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { Tag } from '@rocket.chat/fuselage'; | ||
|
|
||
| type UserInfoABACAttributeProps = { | ||
| attribute: string; | ||
| }; | ||
|
|
||
| const UserInfoABACAttribute = ({ attribute }: UserInfoABACAttributeProps) => { | ||
| return <Tag variant='secondary-warning' children={attribute} />; | ||
| }; | ||
|
|
||
| export default UserInfoABACAttribute; | ||
23 changes: 23 additions & 0 deletions
23
apps/meteor/client/components/UserInfo/UserInfoABACAttributes.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { Box, Margins } from '@rocket.chat/fuselage'; | ||
|
|
||
| import UserInfoABACAttribute from './UserInfoABACAttribute'; | ||
|
|
||
| type UserInfoABACAttributesProps = { | ||
| abacAttributes: string[]; | ||
| }; | ||
|
|
||
| const UserInfoABACAttributes = ({ abacAttributes }: UserInfoABACAttributesProps) => { | ||
| return ( | ||
MartinSchoeler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <Box m='neg-x2'> | ||
| <Box flexWrap='wrap' display='flex' flexShrink={0} mb={8}> | ||
| {abacAttributes.map((attribute, index) => ( | ||
| <Margins inline={2} blockEnd={4} key={`${attribute}-${index}`}> | ||
| <UserInfoABACAttribute attribute={attribute} /> | ||
| </Margins> | ||
| ))} | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default UserInfoABACAttributes; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.