-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathedit.tsx
More file actions
126 lines (113 loc) · 3.91 KB
/
edit.tsx
File metadata and controls
126 lines (113 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* Copyright Oxide Computer Company
*/
import { useForm } from 'react-hook-form'
import { useNavigate, type LoaderFunctionArgs } from 'react-router'
import { api, q, queryClient, usePrefetchedQuery } from '@oxide/api'
import { Access16Icon } from '@oxide/design-system/icons/react'
import { DescriptionField } from '~/components/form/fields/DescriptionField'
import { NameField } from '~/components/form/fields/NameField'
import { TextField } from '~/components/form/fields/TextField'
import { ReadOnlySideModalForm } from '~/components/form/ReadOnlySideModalForm'
import { titleCrumb } from '~/hooks/use-crumbs'
import { getIdpSelector, useIdpSelector } from '~/hooks/use-params'
import { FormDivider } from '~/ui/lib/Divider'
import { SideModalFormDocs } from '~/ui/lib/ModalLinks'
import { PropertiesTable } from '~/ui/lib/PropertiesTable'
import { ResourceLabel, SideModal } from '~/ui/lib/SideModal'
import { docLinks } from '~/util/links'
import { pb } from '~/util/path-builder'
export async function clientLoader({ params }: LoaderFunctionArgs) {
const { silo, provider } = getIdpSelector(params)
await queryClient.prefetchQuery(
q(api.samlIdentityProviderView, { path: { provider }, query: { silo } })
)
return null
}
export const handle = titleCrumb('Edit Identity Provider')
export default function EditIdpSideModalForm() {
const { silo, provider } = useIdpSelector()
const { data: idp } = usePrefetchedQuery(
q(api.samlIdentityProviderView, { path: { provider }, query: { silo } })
)
const navigate = useNavigate()
const onDismiss = () => navigate(pb.silo({ silo }))
const form = useForm({ defaultValues: idp })
return (
<ReadOnlySideModalForm
title="Identity provider"
onDismiss={onDismiss}
subtitle={
<ResourceLabel>
<Access16Icon /> {idp.name}
</ResourceLabel>
}
>
<PropertiesTable>
<PropertiesTable.IdRow id={idp.id} />
<PropertiesTable.DateRow date={idp.timeCreated} label="Created" />
<PropertiesTable.DateRow date={idp.timeModified} label="Updated" />
</PropertiesTable>
<NameField name="name" control={form.control} disabled />
<DescriptionField name="description" control={form.control} required disabled />
<TextField
name="technicalContactEmail"
label="Technical contact email"
required
control={form.control}
disabled
copyable
/>
<FormDivider />
<SideModal.Heading>Service provider</SideModal.Heading>
<TextField
name="spClientId"
label="Service provider client ID"
required
control={form.control}
disabled
/>
<TextField
name="acsUrl"
label="ACS URL"
description="Service provider endpoint for the IdP to send the SAML response"
required
control={form.control}
disabled
/>
<TextField
name="sloUrl"
label="Single Logout (SLO) URL"
description="Service provider endpoint for log out requests"
required
control={form.control}
disabled
/>
<FormDivider />
<SideModal.Heading>Identity provider</SideModal.Heading>
<TextField
name="idpEntityId"
label="Entity ID"
required
control={form.control}
disabled
/>
<TextField
name="groupAttributeName"
label="Group attribute name"
description="Name of the SAML attribute in the IdP response listing the user’s groups"
required
control={form.control}
disabled
/>
<SideModalFormDocs
docs={[docLinks.identityProviders]}
apiOp="saml_identity_provider_view"
/>
</ReadOnlySideModalForm>
)
}