forked from harness/canary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,060 additions
and
609 deletions.
There are no files selected for viewing
24 changes: 21 additions & 3 deletions
24
apps/design-system/src/pages/view-preview/project-settings-wrapper.tsx
This file contains 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 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
100 changes: 100 additions & 0 deletions
100
apps/design-system/src/subjects/views/space-settings-members/space-settings-members.tsx
This file contains 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,100 @@ | ||
import { useState } from 'react' | ||
|
||
import { noop, useTranslationsStore } from '@utils/viewUtils' | ||
|
||
import { DeleteAlertDialog } from '@harnessio/ui/components' | ||
import { PrincipalData, ProjectMemberListView } from '@harnessio/ui/views' | ||
|
||
const usePrincipalListStore = () => { | ||
return { | ||
principalList: [ | ||
{ | ||
uid: 'test1', | ||
display_name: 'Test 1', | ||
email: '[email protected]', | ||
avatar_url: '' | ||
}, | ||
{ | ||
uid: 'test2', | ||
display_name: 'Test 2', | ||
email: '[email protected]', | ||
avatar_url: '' | ||
} | ||
], | ||
setPrincipalList: (_principals: PrincipalData[]) => {} | ||
} | ||
} | ||
|
||
const useMemberListStore = () => { | ||
return { | ||
memberList: [ | ||
{ | ||
display_name: 'Test 1', | ||
role: 'space_owner', | ||
email: '[email protected]', | ||
avatarUrl: '', | ||
timestamp: '2 hours ago', | ||
uid: 'test1' | ||
}, | ||
{ | ||
display_name: 'Test 2', | ||
role: 'space_owner', | ||
email: '[email protected]', | ||
avatarUrl: '', | ||
timestamp: 'Jan 14, 2025', | ||
uid: 'test2' | ||
} | ||
], | ||
spaceId: '', | ||
page: 1, | ||
setPage: noop, | ||
totalPages: 10 | ||
} | ||
} | ||
|
||
export const SpaceSettingsMembers = () => { | ||
const [deleteMemberId, setDeleteMemberId] = useState<string | null>(null) | ||
const [isInviteDialogOpen, setIsInviteDialogOpen] = useState(false) | ||
const [principalsSearchQuery, setPrincipalsSearchQuery] = useState('') | ||
|
||
const handleSetDeleteMember = (id: string) => { | ||
setDeleteMemberId(id) | ||
} | ||
|
||
const handleResetDeleteMember = () => { | ||
setDeleteMemberId(null) | ||
} | ||
|
||
return ( | ||
<> | ||
<ProjectMemberListView | ||
isLoading={false} | ||
useTranslationStore={useTranslationsStore} | ||
useMemberListStore={useMemberListStore} | ||
usePrincipalListStore={usePrincipalListStore} | ||
isInvitingMember={false} | ||
onSubmit={() => {}} | ||
onDeleteHandler={handleSetDeleteMember} | ||
isInviteMemberDialogOpen={isInviteDialogOpen} | ||
setIsInviteMemberDialogOpen={setIsInviteDialogOpen} | ||
searchQuery={null} | ||
setSearchQuery={() => {}} | ||
onEditMember={() => {}} | ||
setPrincipalsSearchQuery={setPrincipalsSearchQuery} | ||
principalsSearchQuery={principalsSearchQuery} | ||
/> | ||
|
||
<DeleteAlertDialog | ||
open={deleteMemberId !== null} | ||
onClose={handleResetDeleteMember} | ||
deleteFn={() => {}} | ||
error={null} | ||
type="member" | ||
identifier={deleteMemberId ?? undefined} | ||
isLoading={false} | ||
useTranslationStore={useTranslationsStore} | ||
withForm | ||
/> | ||
</> | ||
) | ||
} |
40 changes: 40 additions & 0 deletions
40
apps/gitness/src/hooks/use-pagination-query-state-with-store.ts
This file contains 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,40 @@ | ||
import { useEffect } from 'react' | ||
|
||
import { parseAsInteger, useQueryState } from 'nuqs' | ||
|
||
export interface UsePaginationQueryStateWithStoreProps { | ||
page: number | ||
setPage: (val: number) => void | ||
} | ||
|
||
/** | ||
* A hook for working with pagination, useQueryState, and updating entity store values based on pagination. | ||
* | ||
* @param page - page from store | ||
* @param setPage - setPage from store | ||
*/ | ||
const usePaginationQueryStateWithStore = ({ page, setPage }: UsePaginationQueryStateWithStoreProps) => { | ||
const [queryPage, setQueryPage] = useQueryState('page', parseAsInteger.withDefault(1)) | ||
|
||
/** | ||
* Update query state if store page change | ||
*/ | ||
useEffect(() => { | ||
setQueryPage(page) | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [page]) | ||
|
||
/** | ||
* Set page from query state to store | ||
*/ | ||
useEffect(() => { | ||
setPage(queryPage) | ||
}, [queryPage, setPage]) | ||
|
||
return { | ||
queryPage, | ||
setQueryPage | ||
} | ||
} | ||
|
||
export default usePaginationQueryStateWithStore |
Oops, something went wrong.