@shipfox/client-workspace-settings 3.0.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +30 -0
- package/dist/components/members/workspace-members-section.d.ts.map +1 -1
- package/dist/components/members/workspace-members-section.js +4 -4
- package/dist/components/members/workspace-members-section.js.map +1 -1
- package/dist/core/invitation.d.ts +15 -0
- package/dist/core/invitation.d.ts.map +1 -0
- package/dist/core/invitation.js +3 -0
- package/dist/core/invitation.js.map +1 -0
- package/dist/feature.d.ts +0 -70
- package/dist/feature.d.ts.map +1 -1
- package/dist/feature.js +0 -84
- package/dist/feature.js.map +1 -1
- package/dist/hooks/api/create-invitation.d.ts +2 -13
- package/dist/hooks/api/create-invitation.d.ts.map +1 -1
- package/dist/hooks/api/create-invitation.js +12 -9
- package/dist/hooks/api/create-invitation.js.map +1 -1
- package/dist/hooks/api/invitation-mapper.d.ts +4 -0
- package/dist/hooks/api/invitation-mapper.d.ts.map +1 -0
- package/dist/hooks/api/invitation-mapper.js +15 -0
- package/dist/hooks/api/invitation-mapper.js.map +1 -0
- package/dist/hooks/api/list-invitations.d.ts +10 -13
- package/dist/hooks/api/list-invitations.d.ts.map +1 -1
- package/dist/hooks/api/list-invitations.js +11 -5
- package/dist/hooks/api/list-invitations.js.map +1 -1
- package/dist/hooks/api/revoke-invitation.js +2 -4
- package/dist/hooks/api/revoke-invitation.js.map +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +5 -30
- package/src/components/members/workspace-members-section.tsx +6 -11
- package/src/core/invitation.ts +15 -0
- package/src/feature.ts +0 -84
- package/src/hooks/api/create-invitation.ts +20 -10
- package/src/hooks/api/invitation-mapper.test.ts +29 -0
- package/src/hooks/api/invitation-mapper.ts +16 -0
- package/src/hooks/api/list-invitations.ts +17 -7
- package/src/hooks/api/revoke-invitation.ts +2 -2
- package/src/index.ts +0 -7
- package/test/pages.tsx +1 -5
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/pages/events-settings-page.d.ts +0 -2
- package/dist/pages/events-settings-page.d.ts.map +0 -1
- package/dist/pages/events-settings-page.js +0 -30
- package/dist/pages/events-settings-page.js.map +0 -1
- package/dist/pages/integrations-settings-page.d.ts +0 -2
- package/dist/pages/integrations-settings-page.d.ts.map +0 -1
- package/dist/pages/integrations-settings-page.js +0 -10
- package/dist/pages/integrations-settings-page.js.map +0 -1
- package/dist/pages/model-providers-settings-page.d.ts +0 -2
- package/dist/pages/model-providers-settings-page.d.ts.map +0 -1
- package/dist/pages/model-providers-settings-page.js +0 -20
- package/dist/pages/model-providers-settings-page.js.map +0 -1
- package/dist/pages/provisioners-settings-page.d.ts +0 -2
- package/dist/pages/provisioners-settings-page.d.ts.map +0 -1
- package/dist/pages/provisioners-settings-page.js +0 -14
- package/dist/pages/provisioners-settings-page.js.map +0 -1
- package/dist/pages/runners-settings-page.d.ts +0 -2
- package/dist/pages/runners-settings-page.d.ts.map +0 -1
- package/dist/pages/runners-settings-page.js +0 -14
- package/dist/pages/runners-settings-page.js.map +0 -1
- package/dist/pages/secrets-settings-page.d.ts +0 -2
- package/dist/pages/secrets-settings-page.d.ts.map +0 -1
- package/dist/pages/secrets-settings-page.js +0 -14
- package/dist/pages/secrets-settings-page.js.map +0 -1
- package/dist/pages/variables-settings-page.d.ts +0 -2
- package/dist/pages/variables-settings-page.d.ts.map +0 -1
- package/dist/pages/variables-settings-page.js +0 -14
- package/dist/pages/variables-settings-page.js.map +0 -1
- package/dist/routes/agents.d.ts +0 -6
- package/dist/routes/agents.d.ts.map +0 -1
- package/dist/routes/agents.js +0 -7
- package/dist/routes/agents.js.map +0 -1
- package/dist/routes/events.d.ts +0 -8
- package/dist/routes/events.d.ts.map +0 -1
- package/dist/routes/events.js +0 -9
- package/dist/routes/events.js.map +0 -1
- package/dist/routes/integrations.d.ts +0 -6
- package/dist/routes/integrations.d.ts.map +0 -1
- package/dist/routes/integrations.js +0 -7
- package/dist/routes/integrations.js.map +0 -1
- package/dist/routes/provisioners.d.ts +0 -6
- package/dist/routes/provisioners.d.ts.map +0 -1
- package/dist/routes/provisioners.js +0 -7
- package/dist/routes/provisioners.js.map +0 -1
- package/dist/routes/runners.d.ts +0 -6
- package/dist/routes/runners.d.ts.map +0 -1
- package/dist/routes/runners.js +0 -7
- package/dist/routes/runners.js.map +0 -1
- package/dist/routes/secrets.d.ts +0 -6
- package/dist/routes/secrets.d.ts.map +0 -1
- package/dist/routes/secrets.js +0 -7
- package/dist/routes/secrets.js.map +0 -1
- package/dist/routes/variables.d.ts +0 -6
- package/dist/routes/variables.d.ts.map +0 -1
- package/dist/routes/variables.js +0 -7
- package/dist/routes/variables.js.map +0 -1
- package/src/pages/events-settings-page.tsx +0 -25
- package/src/pages/integrations-settings-page.test.tsx +0 -72
- package/src/pages/integrations-settings-page.tsx +0 -6
- package/src/pages/model-providers-settings-page.test.tsx +0 -48
- package/src/pages/model-providers-settings-page.tsx +0 -15
- package/src/pages/provisioners-settings-page.test.tsx +0 -29
- package/src/pages/provisioners-settings-page.tsx +0 -14
- package/src/pages/runners-settings-page.test.tsx +0 -23
- package/src/pages/runners-settings-page.tsx +0 -14
- package/src/pages/secrets-settings-page.tsx +0 -14
- package/src/pages/variables-settings-page.tsx +0 -14
- package/src/routes/agents.tsx +0 -3
- package/src/routes/events.tsx +0 -7
- package/src/routes/integrations.tsx +0 -3
- package/src/routes/provisioners.tsx +0 -3
- package/src/routes/runners.tsx +0 -3
- package/src/routes/secrets.tsx +0 -3
- package/src/routes/variables.tsx +0 -3
- package/test/typecheck/route-ids.tsx +0 -7
- package/test/typecheck/settings-composition.tsx +0 -95
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/client-workspace-settings",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -32,15 +32,10 @@
|
|
|
32
32
|
"@swc/helpers": "^0.5.17",
|
|
33
33
|
"@tanstack/react-form": "^1.32.0",
|
|
34
34
|
"@shipfox/api-workspaces-dto": "6.0.0",
|
|
35
|
-
"@shipfox/client-
|
|
36
|
-
"@shipfox/client-
|
|
37
|
-
"@shipfox/client-
|
|
38
|
-
"@shipfox/client-
|
|
39
|
-
"@shipfox/client-integrations": "3.0.1",
|
|
40
|
-
"@shipfox/client-shell": "3.0.1",
|
|
41
|
-
"@shipfox/client-secrets": "3.0.1",
|
|
42
|
-
"@shipfox/client-triggers": "3.0.1",
|
|
43
|
-
"@shipfox/client-ui": "3.0.1",
|
|
35
|
+
"@shipfox/client-api": "4.0.0",
|
|
36
|
+
"@shipfox/client-auth": "5.0.0",
|
|
37
|
+
"@shipfox/client-shell": "5.0.0",
|
|
38
|
+
"@shipfox/client-ui": "4.0.0",
|
|
44
39
|
"@shipfox/react-ui": "0.3.5"
|
|
45
40
|
},
|
|
46
41
|
"peerDependencies": {
|
|
@@ -49,26 +44,6 @@
|
|
|
49
44
|
"react": "^19.0.0",
|
|
50
45
|
"react-dom": "^19.0.0"
|
|
51
46
|
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@tanstack/react-query": "^5.101.0",
|
|
54
|
-
"@tanstack/react-router": "^1.170.16",
|
|
55
|
-
"@testing-library/jest-dom": "^6.6.3",
|
|
56
|
-
"@testing-library/react": "^16.3.2",
|
|
57
|
-
"@testing-library/user-event": "^14.6.1",
|
|
58
|
-
"@types/react": "^19.1.11",
|
|
59
|
-
"@types/react-dom": "^19.1.7",
|
|
60
|
-
"jotai": "^2.19.1",
|
|
61
|
-
"jsdom": "^29.0.0",
|
|
62
|
-
"react": "^19.1.1",
|
|
63
|
-
"react-dom": "^19.1.1",
|
|
64
|
-
"@shipfox/biome": "1.8.2",
|
|
65
|
-
"@shipfox/client-test-setup": "0.0.3",
|
|
66
|
-
"@shipfox/swc": "1.2.6",
|
|
67
|
-
"@shipfox/ts-config": "1.3.8",
|
|
68
|
-
"@shipfox/vite": "1.2.5",
|
|
69
|
-
"@shipfox/vitest": "1.2.3",
|
|
70
|
-
"@shipfox/typescript": "1.1.7"
|
|
71
|
-
},
|
|
72
47
|
"scripts": {
|
|
73
48
|
"build": "shipfox-swc",
|
|
74
49
|
"check": "shipfox-biome-check",
|
|
@@ -31,6 +31,7 @@ import {Code, Header, Text} from '@shipfox/react-ui/typography';
|
|
|
31
31
|
import {formatDate} from '@shipfox/react-ui/utils';
|
|
32
32
|
import {useForm} from '@tanstack/react-form';
|
|
33
33
|
import {useState} from 'react';
|
|
34
|
+
import type {Invitation} from '#core/invitation.js';
|
|
34
35
|
import {useCreateInvitation} from '#hooks/api/create-invitation.js';
|
|
35
36
|
import {useListInvitations} from '#hooks/api/list-invitations.js';
|
|
36
37
|
import {useListMembers} from '#hooks/api/list-members.js';
|
|
@@ -194,7 +195,7 @@ function PendingInvitationsSection({
|
|
|
194
195
|
workspaceName: string;
|
|
195
196
|
}) {
|
|
196
197
|
const query = useListInvitations(workspaceId);
|
|
197
|
-
const invitations = query.data
|
|
198
|
+
const invitations = query.data ?? [];
|
|
198
199
|
const [inviteOpen, setInviteOpen] = useState(false);
|
|
199
200
|
|
|
200
201
|
return (
|
|
@@ -249,16 +250,10 @@ function PendingInvitationsSection({
|
|
|
249
250
|
);
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
function InvitationRow({
|
|
253
|
-
invitation,
|
|
254
|
-
workspaceId,
|
|
255
|
-
}: {
|
|
256
|
-
invitation: import('@shipfox/api-workspaces-dto').InvitationDto;
|
|
257
|
-
workspaceId: string;
|
|
258
|
-
}) {
|
|
253
|
+
function InvitationRow({invitation, workspaceId}: {invitation: Invitation; workspaceId: string}) {
|
|
259
254
|
const [open, setOpen] = useState(false);
|
|
260
255
|
const revoke = useRevokeInvitation(workspaceId);
|
|
261
|
-
const expiresAt = new Date(invitation.
|
|
256
|
+
const expiresAt = new Date(invitation.expiresAt);
|
|
262
257
|
const expiresSoon = expiresAt.getTime() - Date.now() < EXPIRES_SOON_MS;
|
|
263
258
|
|
|
264
259
|
async function handleRevoke() {
|
|
@@ -276,10 +271,10 @@ function InvitationRow({
|
|
|
276
271
|
<TableCell>
|
|
277
272
|
<Code variant="paragraph">{invitation.email}</Code>
|
|
278
273
|
</TableCell>
|
|
279
|
-
<TableCell>{invitation.
|
|
274
|
+
<TableCell>{invitation.invitedByDisplay ?? '—'}</TableCell>
|
|
280
275
|
<TableCell>
|
|
281
276
|
<div className="flex items-center gap-8">
|
|
282
|
-
<Text size="sm">{formatDate(invitation.
|
|
277
|
+
<Text size="sm">{formatDate(invitation.expiresAt)}</Text>
|
|
283
278
|
{expiresSoon ? <Badge variant="warning">Soon</Badge> : null}
|
|
284
279
|
</div>
|
|
285
280
|
</TableCell>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Invitation {
|
|
2
|
+
id: string;
|
|
3
|
+
workspaceId: string;
|
|
4
|
+
email: string;
|
|
5
|
+
expiresAt: string;
|
|
6
|
+
acceptedAt: string | null;
|
|
7
|
+
invitedByUserId: string;
|
|
8
|
+
invitedByDisplay: string | null;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CreateInvitationCommand {
|
|
14
|
+
email: string;
|
|
15
|
+
}
|
package/src/feature.ts
CHANGED
|
@@ -14,41 +14,6 @@ export const workspaceSettingsFeature = defineClientFeature({
|
|
|
14
14
|
parent: 'workspaceSettings',
|
|
15
15
|
impl: '@shipfox/client-workspace-settings/routes/members',
|
|
16
16
|
},
|
|
17
|
-
{
|
|
18
|
-
path: '/workspaces/$wid/settings/runners',
|
|
19
|
-
parent: 'workspaceSettings',
|
|
20
|
-
impl: '@shipfox/client-workspace-settings/routes/runners',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
path: '/workspaces/$wid/settings/provisioners',
|
|
24
|
-
parent: 'workspaceSettings',
|
|
25
|
-
impl: '@shipfox/client-workspace-settings/routes/provisioners',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
path: '/workspaces/$wid/settings/agents',
|
|
29
|
-
parent: 'workspaceSettings',
|
|
30
|
-
impl: '@shipfox/client-workspace-settings/routes/agents',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
path: '/workspaces/$wid/settings/secrets',
|
|
34
|
-
parent: 'workspaceSettings',
|
|
35
|
-
impl: '@shipfox/client-workspace-settings/routes/secrets',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
path: '/workspaces/$wid/settings/variables',
|
|
39
|
-
parent: 'workspaceSettings',
|
|
40
|
-
impl: '@shipfox/client-workspace-settings/routes/variables',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
path: '/workspaces/$wid/settings/integrations',
|
|
44
|
-
parent: 'workspaceSettings',
|
|
45
|
-
impl: '@shipfox/client-workspace-settings/routes/integrations',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
path: '/workspaces/$wid/settings/events',
|
|
49
|
-
parent: 'workspaceSettings',
|
|
50
|
-
impl: '@shipfox/client-workspace-settings/routes/events',
|
|
51
|
-
},
|
|
52
17
|
],
|
|
53
18
|
navigation: [
|
|
54
19
|
{
|
|
@@ -67,54 +32,5 @@ export const workspaceSettingsFeature = defineClientFeature({
|
|
|
67
32
|
icon: 'userLine' as IconName,
|
|
68
33
|
order: 100,
|
|
69
34
|
},
|
|
70
|
-
{
|
|
71
|
-
id: 'settings.runners',
|
|
72
|
-
pathSegment: 'runners',
|
|
73
|
-
label: 'Runners',
|
|
74
|
-
icon: 'settings3Line' as IconName,
|
|
75
|
-
order: 200,
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
id: 'settings.provisioners',
|
|
79
|
-
pathSegment: 'provisioners',
|
|
80
|
-
label: 'Runner provisioners',
|
|
81
|
-
icon: 'serverLine' as IconName,
|
|
82
|
-
order: 300,
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: 'settings.agents',
|
|
86
|
-
pathSegment: 'agents',
|
|
87
|
-
label: 'Agents',
|
|
88
|
-
icon: 'robot2Line' as IconName,
|
|
89
|
-
order: 400,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: 'settings.secrets',
|
|
93
|
-
pathSegment: 'secrets',
|
|
94
|
-
label: 'Secrets',
|
|
95
|
-
icon: 'keyLine' as IconName,
|
|
96
|
-
order: 500,
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
id: 'settings.variables',
|
|
100
|
-
pathSegment: 'variables',
|
|
101
|
-
label: 'Variables',
|
|
102
|
-
icon: 'bracesLine' as IconName,
|
|
103
|
-
order: 600,
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: 'settings.integrations',
|
|
107
|
-
pathSegment: 'integrations',
|
|
108
|
-
label: 'Integrations',
|
|
109
|
-
icon: 'plugLine' as IconName,
|
|
110
|
-
order: 700,
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
id: 'settings.events',
|
|
114
|
-
pathSegment: 'events',
|
|
115
|
-
label: 'Events',
|
|
116
|
-
icon: 'pulseLine' as IconName,
|
|
117
|
-
order: 800,
|
|
118
|
-
},
|
|
119
35
|
],
|
|
120
36
|
});
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import {invitationDtoSchema} from '@shipfox/api-workspaces-dto';
|
|
2
|
+
import {checkedApiRequest} from '@shipfox/client-api';
|
|
3
3
|
import {useMutation, useQueryClient} from '@tanstack/react-query';
|
|
4
|
-
import {
|
|
4
|
+
import type {CreateInvitationCommand, Invitation} from '#core/invitation.js';
|
|
5
|
+
import {toInvitation} from './invitation-mapper.js';
|
|
6
|
+
import {listInvitationsQueryOptions} from './list-invitations.js';
|
|
5
7
|
|
|
6
|
-
async function createInvitation(params: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
async function createInvitation(params: {
|
|
9
|
+
workspaceId: string;
|
|
10
|
+
command: CreateInvitationCommand;
|
|
11
|
+
}): Promise<Invitation> {
|
|
12
|
+
const response = await checkedApiRequest(
|
|
13
|
+
invitationDtoSchema,
|
|
14
|
+
`/workspaces/${params.workspaceId}/invitations`,
|
|
15
|
+
{
|
|
16
|
+
method: 'POST',
|
|
17
|
+
body: {email: params.command.email},
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
return toInvitation(response);
|
|
11
21
|
}
|
|
12
22
|
|
|
13
23
|
export function useCreateInvitation(workspaceId: string) {
|
|
14
24
|
const queryClient = useQueryClient();
|
|
15
25
|
return useMutation({
|
|
16
|
-
mutationFn: (
|
|
26
|
+
mutationFn: (command: CreateInvitationCommand) => createInvitation({workspaceId, command}),
|
|
17
27
|
onSuccess: async () => {
|
|
18
|
-
await queryClient.invalidateQueries(
|
|
28
|
+
await queryClient.invalidateQueries(listInvitationsQueryOptions(workspaceId));
|
|
19
29
|
},
|
|
20
30
|
});
|
|
21
31
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {toInvitation} from './invitation-mapper.js';
|
|
2
|
+
|
|
3
|
+
describe('toInvitation', () => {
|
|
4
|
+
test('maps the transport response to the package domain model', () => {
|
|
5
|
+
const invitation = toInvitation({
|
|
6
|
+
id: 'f87901d8-4a7e-43e7-84f5-a9c73456657f',
|
|
7
|
+
workspace_id: 'ab03cfd0-1845-453b-867c-a661c8e62f13',
|
|
8
|
+
email: 'member@example.com',
|
|
9
|
+
expires_at: '2026-07-29T12:00:00.000Z',
|
|
10
|
+
accepted_at: null,
|
|
11
|
+
invited_by_user_id: 'b8d2ab85-9e38-4449-af50-8beaabf058e5',
|
|
12
|
+
invited_by_display: 'Noé',
|
|
13
|
+
created_at: '2026-07-22T12:00:00.000Z',
|
|
14
|
+
updated_at: '2026-07-22T12:00:00.000Z',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(invitation).toEqual({
|
|
18
|
+
id: 'f87901d8-4a7e-43e7-84f5-a9c73456657f',
|
|
19
|
+
workspaceId: 'ab03cfd0-1845-453b-867c-a661c8e62f13',
|
|
20
|
+
email: 'member@example.com',
|
|
21
|
+
expiresAt: '2026-07-29T12:00:00.000Z',
|
|
22
|
+
acceptedAt: null,
|
|
23
|
+
invitedByUserId: 'b8d2ab85-9e38-4449-af50-8beaabf058e5',
|
|
24
|
+
invitedByDisplay: 'Noé',
|
|
25
|
+
createdAt: '2026-07-22T12:00:00.000Z',
|
|
26
|
+
updatedAt: '2026-07-22T12:00:00.000Z',
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type {InvitationDto} from '@shipfox/api-workspaces-dto';
|
|
2
|
+
import type {Invitation} from '#core/invitation.js';
|
|
3
|
+
|
|
4
|
+
export function toInvitation(dto: InvitationDto): Invitation {
|
|
5
|
+
return {
|
|
6
|
+
id: dto.id,
|
|
7
|
+
workspaceId: dto.workspace_id,
|
|
8
|
+
email: dto.email,
|
|
9
|
+
expiresAt: dto.expires_at,
|
|
10
|
+
acceptedAt: dto.accepted_at,
|
|
11
|
+
invitedByUserId: dto.invited_by_user_id,
|
|
12
|
+
invitedByDisplay: dto.invited_by_display,
|
|
13
|
+
createdAt: dto.created_at,
|
|
14
|
+
updatedAt: dto.updated_at,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {useQuery} from '@tanstack/react-query';
|
|
1
|
+
import {listInvitationsResponseSchema} from '@shipfox/api-workspaces-dto';
|
|
2
|
+
import {checkedApiRequest} from '@shipfox/client-api';
|
|
3
|
+
import {queryOptions, useQuery} from '@tanstack/react-query';
|
|
4
|
+
import type {Invitation} from '#core/invitation.js';
|
|
5
|
+
import {toInvitation} from './invitation-mapper.js';
|
|
4
6
|
|
|
5
7
|
export const listInvitationsQueryKey = (workspaceId: string) =>
|
|
6
8
|
['workspaces', workspaceId, 'invitations'] as const;
|
|
7
9
|
|
|
8
|
-
async function listInvitations(workspaceId: string): Promise<
|
|
9
|
-
|
|
10
|
+
async function listInvitations(workspaceId: string): Promise<Invitation[]> {
|
|
11
|
+
const response = await checkedApiRequest(
|
|
12
|
+
listInvitationsResponseSchema,
|
|
13
|
+
`/workspaces/${workspaceId}/invitations`,
|
|
14
|
+
);
|
|
15
|
+
return response.invitations.map(toInvitation);
|
|
10
16
|
}
|
|
11
17
|
|
|
12
|
-
export function
|
|
13
|
-
return
|
|
18
|
+
export function listInvitationsQueryOptions(workspaceId: string) {
|
|
19
|
+
return queryOptions({
|
|
14
20
|
queryKey: listInvitationsQueryKey(workspaceId),
|
|
15
21
|
queryFn: () => listInvitations(workspaceId),
|
|
16
22
|
});
|
|
17
23
|
}
|
|
24
|
+
|
|
25
|
+
export function useListInvitations(workspaceId: string) {
|
|
26
|
+
return useQuery(listInvitationsQueryOptions(workspaceId));
|
|
27
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {apiRequest} from '@shipfox/client-api';
|
|
2
2
|
import {useMutation, useQueryClient} from '@tanstack/react-query';
|
|
3
|
-
import {
|
|
3
|
+
import {listInvitationsQueryOptions} from './list-invitations.js';
|
|
4
4
|
|
|
5
5
|
async function revokeInvitation(params: {workspaceId: string; invitationId: string}) {
|
|
6
6
|
await apiRequest<void>(`/workspaces/${params.workspaceId}/invitations/${params.invitationId}`, {
|
|
@@ -13,7 +13,7 @@ export function useRevokeInvitation(workspaceId: string) {
|
|
|
13
13
|
return useMutation({
|
|
14
14
|
mutationFn: (invitationId: string) => revokeInvitation({workspaceId, invitationId}),
|
|
15
15
|
onSuccess: async () => {
|
|
16
|
-
await queryClient.invalidateQueries(
|
|
16
|
+
await queryClient.invalidateQueries(listInvitationsQueryOptions(workspaceId));
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export * from './pages/events-settings-page.js';
|
|
2
|
-
export * from './pages/integrations-settings-page.js';
|
|
3
1
|
export * from './pages/members-settings-page.js';
|
|
4
|
-
export * from './pages/model-providers-settings-page.js';
|
|
5
|
-
export * from './pages/provisioners-settings-page.js';
|
|
6
|
-
export * from './pages/runners-settings-page.js';
|
|
7
|
-
export * from './pages/secrets-settings-page.js';
|
|
8
|
-
export * from './pages/variables-settings-page.js';
|
package/test/pages.tsx
CHANGED
|
@@ -22,11 +22,7 @@ const authState: AuthState = {
|
|
|
22
22
|
user: {
|
|
23
23
|
id: '22222222-2222-4222-8222-222222222222',
|
|
24
24
|
email: 'user@example.com',
|
|
25
|
-
|
|
26
|
-
email_verified_at: new Date().toISOString(),
|
|
27
|
-
status: 'active',
|
|
28
|
-
created_at: new Date().toISOString(),
|
|
29
|
-
updated_at: new Date().toISOString(),
|
|
25
|
+
emailVerifiedAt: new Date().toISOString(),
|
|
30
26
|
},
|
|
31
27
|
workspaces: [{id: WORKSPACE_SETTINGS_TEST_WID, name: 'Acme', membershipId: 'm-1'}],
|
|
32
28
|
};
|