-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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 9 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
12 changes: 12 additions & 0 deletions
12
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,12 @@ | ||
| import { Tag } from '@rocket.chat/fuselage'; | ||
| import type { ReactElement } from 'react'; | ||
|
|
||
| type UserInfoABACAttributeProps = { | ||
| attribute: string; | ||
| }; | ||
|
|
||
| const UserInfoABACAttribute = ({ attribute }: UserInfoABACAttributeProps): ReactElement => { | ||
| return <Tag variant='secondary-warning' children={attribute} />; | ||
| }; | ||
|
|
||
| export default UserInfoABACAttribute; | ||
32 changes: 32 additions & 0 deletions
32
apps/meteor/client/components/UserInfo/UserInfoABACAttributes.spec.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,32 @@ | ||
| import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { axe } from 'jest-axe'; | ||
|
|
||
| import UserInfoABACAttributes from './UserInfoABACAttributes'; | ||
|
|
||
| const appRoot = mockAppRoot() | ||
| .withTranslations('en', 'core', { | ||
| ABAC_attributes: 'ABAC Attributes', | ||
|
MartinSchoeler marked this conversation as resolved.
Outdated
|
||
| ABAC_Attributes_description: 'Attribute-Based Access Control', | ||
| }) | ||
| .build(); | ||
|
|
||
| describe('UserInfoABACAttributes', () => { | ||
| it('should render with multiple attributes', () => { | ||
| const attributes = ['Classified', 'Top Secret', 'Confidential']; | ||
| const { baseElement } = render(<UserInfoABACAttributes abacAttributes={attributes} />, { wrapper: appRoot }); | ||
|
|
||
| expect(baseElement).toMatchSnapshot(); | ||
| expect(screen.getByText('Classified')).toBeInTheDocument(); | ||
| expect(screen.getByText('Top Secret')).toBeInTheDocument(); | ||
| expect(screen.getByText('Confidential')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should have no accessibility violations with multiple attributes', async () => { | ||
| const attributes = ['Classified', 'Top Secret', 'Confidential']; | ||
| const { container } = render(<UserInfoABACAttributes abacAttributes={attributes} />, { wrapper: appRoot }); | ||
|
|
||
| const results = await axe(container); | ||
| expect(results).toHaveNoViolations(); | ||
| }); | ||
| }); | ||
39 changes: 39 additions & 0 deletions
39
apps/meteor/client/components/UserInfo/UserInfoABACAttributes.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 |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import UserInfoABACAttributes from './UserInfoABACAttributes'; | ||
|
|
||
| const meta = { | ||
| component: UserInfoABACAttributes, | ||
| parameters: { | ||
| layout: 'centered', | ||
| }, | ||
| args: { | ||
| abacAttributes: ['Classified', 'Top Secret', 'Confidential'], | ||
| }, | ||
| decorators: [ | ||
| (Story) => { | ||
| const AppRoot = mockAppRoot() | ||
| .withTranslations('en', 'core', { | ||
| ABAC_attributes: 'ABAC Attributes', | ||
| ABAC_Attributes_description: 'Attribute-Based Access Control', | ||
| }) | ||
| .build(); | ||
|
|
||
| return ( | ||
| <AppRoot> | ||
| <Story /> | ||
| </AppRoot> | ||
| ); | ||
| }, | ||
| ], | ||
| } satisfies Meta<typeof UserInfoABACAttributes>; | ||
|
|
||
| export default meta; | ||
| type Story = StoryObj<typeof meta>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| abacAttributes: ['Top Secret', 'Classified', 'Confidential', 'Restricted', 'Internal'], | ||
| }, | ||
| }; |
22 changes: 22 additions & 0 deletions
22
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,22 @@ | ||
| import { Box, Margins } from '@rocket.chat/fuselage'; | ||
| import type { ComponentProps, ReactElement } from 'react'; | ||
|
|
||
| import UserInfoABACAttribute from './UserInfoABACAttribute'; | ||
|
|
||
| type UserCardABACAttributesProps = { | ||
| abacAttributes: string[]; | ||
| } & ComponentProps<typeof Box>; | ||
|
MartinSchoeler marked this conversation as resolved.
Outdated
|
||
|
|
||
| const UserInfoABACAttributes = ({ abacAttributes }: UserCardABACAttributesProps): ReactElement => { | ||
|
MartinSchoeler marked this conversation as resolved.
Outdated
|
||
| return ( | ||
|
MartinSchoeler marked this conversation as resolved.
|
||
| <Box flexWrap='wrap' display='flex'> | ||
| {abacAttributes.map((attribute, index) => ( | ||
| <Margins inline={2} blockEnd={4} key={index}> | ||
|
MartinSchoeler marked this conversation as resolved.
Outdated
|
||
| <UserInfoABACAttribute attribute={attribute} /> | ||
| </Margins> | ||
| ))} | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default UserInfoABACAttributes; | ||
39 changes: 39 additions & 0 deletions
39
apps/meteor/client/components/UserInfo/__snapshots__/UserInfoABACAttributes.spec.tsx.snap
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,39 @@ | ||
| // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing | ||
|
|
||
| exports[`UserInfoABACAttributes should render with multiple attributes 1`] = ` | ||
| <body> | ||
| <div> | ||
| <span | ||
| class="rcx-box rcx-box--full rcx-css-zr2f9f" | ||
| > | ||
| <span | ||
| class="rcx-box rcx-box--full rcx-tag rcx-tag--secondary-warning rcx-css-wcp0mp" | ||
| > | ||
| <span | ||
| class="rcx-tag__inner" | ||
| > | ||
| Classified | ||
| </span> | ||
| </span> | ||
| <span | ||
| class="rcx-box rcx-box--full rcx-tag rcx-tag--secondary-warning rcx-css-wcp0mp" | ||
| > | ||
| <span | ||
| class="rcx-tag__inner" | ||
| > | ||
| Top Secret | ||
| </span> | ||
| </span> | ||
| <span | ||
| class="rcx-box rcx-box--full rcx-tag rcx-tag--secondary-warning rcx-css-wcp0mp" | ||
| > | ||
| <span | ||
| class="rcx-tag__inner" | ||
| > | ||
| Confidential | ||
| </span> | ||
| </span> | ||
| </span> | ||
| </div> | ||
| </body> | ||
| `; |
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
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.