-
Notifications
You must be signed in to change notification settings - Fork 44
feat: projects pages revamp #1503
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
14 commits
Select commit
Hold shift + click to select a range
66f576d
chore: use apsara v1 in sdk
rohanchkrabrty b6b1082
feat: general page revamp
rohanchkrabrty fd07c82
feat: preferences page revamp
rohanchkrabrty 09f6f1b
feat: profile page revamp
rohanchkrabrty ff4680f
feat: sessions page revamp
rohanchkrabrty f00670c
feat: fix logout redirect
rohanchkrabrty 18a0bc9
wip: members page revamp
rohanchkrabrty 73a444f
wip: members
rohanchkrabrty 3da222b
feat: members page revamp
rohanchkrabrty 7bdcddd
feat: members page improvements
rohanchkrabrty f464535
feat: security pages revamp
rohanchkrabrty 5753b97
feat: projects pages revamp
rohanchkrabrty 3306c5b
feat: projects page revamp
rohanchkrabrty 554cbed
Merge branch 'main' into feat-projects-revamp
rohanchkrabrty 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
Some comments aren't visible on the classic Files Changed page.
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
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
17 changes: 17 additions & 0 deletions
17
web/apps/client-demo/src/pages/settings/ProjectDetails.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,17 @@ | ||
| import { useParams, useNavigate } from 'react-router-dom'; | ||
| import { ProjectDetailsView } from '@raystack/frontier/react'; | ||
|
|
||
| export default function ProjectDetails() { | ||
| const { orgId, projectId } = useParams<{ orgId: string; projectId: string }>(); | ||
| const navigate = useNavigate(); | ||
|
|
||
| if (!projectId) return null; | ||
|
|
||
| return ( | ||
| <ProjectDetailsView | ||
| projectId={projectId} | ||
| onNavigateToProjects={() => navigate(`/${orgId}/settings/projects`)} | ||
| onDeleteSuccess={() => navigate(`/${orgId}/settings/projects`)} | ||
| /> | ||
| ); | ||
| } |
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,13 @@ | ||
| import { useParams, useNavigate } from 'react-router-dom'; | ||
| import { ProjectsView } from '@raystack/frontier/react'; | ||
|
|
||
| export default function Projects() { | ||
| const { orgId } = useParams<{ orgId: string }>(); | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| <ProjectsView | ||
| onProjectClick={(projectId) => navigate(`/${orgId}/settings/projects/${projectId}`)} | ||
| /> | ||
| ); | ||
| } |
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
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
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
251 changes: 251 additions & 0 deletions
251
web/sdk/react/views-new/projects/components/add-member-menu.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,251 @@ | ||
| 'use client'; | ||
|
|
||
| import { useCallback, useEffect, useMemo, useState } from 'react'; | ||
| import { CardStackPlusIcon, PlusIcon } from '@radix-ui/react-icons'; | ||
| import { | ||
| Avatar, | ||
| Button, | ||
| Flex, | ||
| Menu, | ||
| Separator, | ||
| Skeleton, | ||
| Tooltip | ||
| } from '@raystack/apsara-v1'; | ||
| import { toastManager } from '@raystack/apsara-v1'; | ||
| import { useQuery, useMutation } from '@connectrpc/connect-query'; | ||
| import { | ||
| FrontierServiceQueries, | ||
| ListOrganizationUsersRequestSchema, | ||
| CreatePolicyForProjectRequestSchema, | ||
| type User | ||
| } from '@raystack/proton/frontier'; | ||
| import { create } from '@bufbuild/protobuf'; | ||
| import { useFrontier } from '../../../contexts/FrontierContext'; | ||
| import { useOrganizationTeams } from '../../../hooks/useOrganizationTeams'; | ||
| import { AuthTooltipMessage } from '../../../utils'; | ||
| import { | ||
| PERMISSIONS, | ||
| filterUsersfromUsers, | ||
| getInitials | ||
| } from '../../../../utils'; | ||
| import styles from '../project-details-view.module.css'; | ||
|
|
||
| interface AddMemberMenuProps { | ||
| projectId: string; | ||
| canUpdateProject: boolean; | ||
| members: User[]; | ||
| refetch: () => void; | ||
| } | ||
|
|
||
| export function AddMemberMenu({ | ||
| projectId, | ||
| canUpdateProject, | ||
| members, | ||
| refetch | ||
| }: AddMemberMenuProps) { | ||
| const [showTeam, setShowTeam] = useState(false); | ||
|
|
||
| const { activeOrganization: organization } = useFrontier(); | ||
| const { isFetching: isTeamsLoading, teams } = useOrganizationTeams({}); | ||
|
|
||
| const { | ||
| data: orgUsersData, | ||
| isLoading: isOrgUsersLoading, | ||
| error: orgUsersError | ||
| } = useQuery( | ||
| FrontierServiceQueries.listOrganizationUsers, | ||
| create(ListOrganizationUsersRequestSchema, { | ||
| id: organization?.id || '' | ||
| }), | ||
| { enabled: !!organization?.id && canUpdateProject } | ||
| ); | ||
|
|
||
| const orgUsers = useMemo( | ||
| () => orgUsersData?.users ?? [], | ||
| [orgUsersData] | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| if (orgUsersError) { | ||
| toastManager.add({ | ||
| title: 'Something went wrong', | ||
| description: orgUsersError.message, | ||
| type: 'error' | ||
| }); | ||
| } | ||
| }, [orgUsersError]); | ||
|
|
||
| const invitableUsers = useMemo( | ||
| () => filterUsersfromUsers(orgUsers, members), | ||
| [orgUsers, members] | ||
| ); | ||
|
|
||
| const { mutate: createPolicyForProject } = useMutation( | ||
| FrontierServiceQueries.createPolicyForProject, | ||
| { | ||
| onSuccess: () => { | ||
| toastManager.add({ | ||
| title: 'Member added', | ||
| type: 'success' | ||
| }); | ||
| refetch(); | ||
| }, | ||
| onError: (err: Error) => { | ||
| toastManager.add({ | ||
| title: 'Something went wrong', | ||
| description: err.message, | ||
| type: 'error' | ||
| }); | ||
| } | ||
| } | ||
| ); | ||
|
|
||
| const addMember = useCallback( | ||
| (userId: string) => { | ||
| if (!userId || !organization?.id || !projectId) return; | ||
| const principal = `${PERMISSIONS.UserNamespace}:${userId}`; | ||
| createPolicyForProject( | ||
| create(CreatePolicyForProjectRequestSchema, { | ||
| projectId, | ||
| body: { roleId: PERMISSIONS.RoleProjectViewer, principal } | ||
| }) | ||
| ); | ||
| }, | ||
| [createPolicyForProject, organization?.id, projectId] | ||
| ); | ||
|
|
||
| const addTeam = useCallback( | ||
| (teamId: string) => { | ||
| if (!teamId || !organization?.id || !projectId) return; | ||
| const principal = `${PERMISSIONS.GroupNamespace}:${teamId}`; | ||
| createPolicyForProject( | ||
| create(CreatePolicyForProjectRequestSchema, { | ||
| projectId, | ||
| body: { roleId: PERMISSIONS.RoleProjectViewer, principal } | ||
| }) | ||
| ); | ||
| }, | ||
| [createPolicyForProject, organization?.id, projectId] | ||
| ); | ||
|
|
||
| const toggleShowTeam = useCallback(() => { | ||
| setShowTeam(prev => !prev); | ||
| }, []); | ||
|
|
||
| const isLoading = showTeam ? isTeamsLoading : isOrgUsersLoading; | ||
|
|
||
| if (!canUpdateProject) { | ||
| return ( | ||
| <Tooltip> | ||
| <Tooltip.Trigger render={<span />}> | ||
| <Button | ||
| variant="solid" | ||
| color="accent" | ||
| disabled | ||
| data-test-id="frontier-sdk-add-project-member-btn" | ||
| > | ||
| Add a member | ||
| </Button> | ||
| </Tooltip.Trigger> | ||
| <Tooltip.Content>{AuthTooltipMessage}</Tooltip.Content> | ||
| </Tooltip> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Menu autocomplete> | ||
| <Menu.Trigger | ||
| render={ | ||
| <Button | ||
| variant="solid" | ||
| color="accent" | ||
| data-test-id="frontier-sdk-add-project-member-btn" | ||
| /> | ||
| } | ||
| > | ||
| Add a member | ||
| </Menu.Trigger> | ||
| <Menu.Content | ||
| align="end" | ||
| className={styles.addMemberContent} | ||
| searchPlaceholder={showTeam ? 'Search teams...' : 'Search...'} | ||
| > | ||
| <div className={styles.addMemberMenuList}> | ||
| {isLoading | ||
| ? <Flex gap={1} direction="column"> | ||
| { | ||
| Array.from({ length: 6 }, (_, i) => ( | ||
| <Skeleton key={i} height="30px" width="100%" /> | ||
| )) | ||
| } | ||
| </Flex> | ||
| : showTeam | ||
| ? teams.map(team => ( | ||
| <Menu.Item | ||
| key={team.id} | ||
| value={team.title || team.name || ''} | ||
| className={styles.addMemberMenuItem} | ||
| leadingIcon={ | ||
| <Avatar | ||
| fallback={getInitials(team.title || team.name || '')} | ||
| size={1} | ||
| /> | ||
| } | ||
| onClick={() => addTeam(team.id || '')} | ||
| data-test-id={`frontier-sdk-add-team-to-project-item-${team.id}`} | ||
| > | ||
| <span className={styles.addMemberMenuItemText}>{team.title || team.name}</span> | ||
| </Menu.Item> | ||
| )) | ||
| : invitableUsers.map(user => ( | ||
| <Menu.Item | ||
| key={user.id} | ||
| value={user.title || user.email || ''} | ||
| className={styles.addMemberMenuItem} | ||
| leadingIcon={ | ||
| <Avatar | ||
| src={user.avatar} | ||
| fallback={getInitials( | ||
| user.title || user.email || '' | ||
| )} | ||
| size={1} | ||
| /> | ||
| } | ||
| onClick={() => addMember(user.id || '')} | ||
| data-test-id={`frontier-sdk-add-user-to-project-item-${user.id}`} | ||
| > | ||
| <span className={styles.addMemberMenuItemText}>{user.title || user.email}</span> | ||
| </Menu.Item> | ||
| ))} | ||
|
|
||
| {!isLoading && | ||
| (showTeam ? !teams.length : !invitableUsers.length) && ( | ||
| <Menu.EmptyState className={styles.addMemberEmptyState}> | ||
| {showTeam ? 'No teams found' : 'No users found'} | ||
| </Menu.EmptyState> | ||
| )} | ||
| </div> | ||
| <Flex direction="column" align="center" className={styles.addMemberFooter}> | ||
| <Separator className={styles.addMemberSeparator} /> | ||
| <Button | ||
| width="100%" | ||
| variant="text" | ||
| color="neutral" | ||
| className={styles.addMemberToggleBtn} | ||
| leadingIcon={ | ||
| showTeam ? ( | ||
| <PlusIcon /> | ||
| ) : ( | ||
| <CardStackPlusIcon /> | ||
| ) | ||
| } | ||
| onClick={toggleShowTeam} | ||
| data-test-id="frontier-sdk-add-project-member-toggle" | ||
| > | ||
| {showTeam ? 'Add project member' : 'Add team to project'} | ||
| </Button> | ||
| </Flex> | ||
| </Menu.Content> | ||
| </Menu> | ||
| ); | ||
| } | ||
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.