Skip to content

Commit 03980ea

Browse files
committed
feat: convert resource ids to names
1 parent eff31d8 commit 03980ea

23 files changed

+221
-507
lines changed

src/App.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import Clusters from 'pages/Clusters'
1515
import Catalogs from 'pages/Catalogs'
1616
import Catalog from 'pages/Catalog'
1717
import Error from 'pages/Error'
18-
import Secret from 'pages/Secret'
1918
import SealedSecret from 'pages/SealedSecret'
20-
import Secrets from 'pages/Secrets'
2119
import SealedSecrets from 'pages/SealedSecrets'
2220
import Service from 'pages/Service'
2321
import Services from 'pages/Services'
@@ -106,7 +104,7 @@ function App() {
106104
exact
107105
/>
108106
<PrivateRoute
109-
path='/teams/:teamId/coderepositories/:coderepositoryId'
107+
path='/teams/:teamId/coderepositories/:codeRepositoryName'
110108
component={CodeRepository}
111109
exact
112110
/>
@@ -133,7 +131,6 @@ function App() {
133131
exact
134132
/>
135133
<PrivateRoute path='/services' component={Services} platformAdminRoute exact />
136-
<PrivateRoute path='/secrets' component={Secrets} platformAdminRoute exact />
137134
<PrivateRoute
138135
path='/sealed-secrets'
139136
component={SealedSecrets}
@@ -152,7 +149,6 @@ function App() {
152149
<PrivateRoute path='/teams/:teamId' component={Team} exact />
153150
<PrivateRoute path='/teams/:teamId/create-backup' component={Backup} exact />
154151
<PrivateRoute path='/teams/:teamId/create-netpol' component={Netpol} exact />
155-
<PrivateRoute path='/teams/:teamId/create-secret' component={Secret} exact />
156152
<PrivateRoute
157153
path='/teams/:teamId/create-sealedsecret'
158154
component={SealedSecret}
@@ -162,28 +158,26 @@ function App() {
162158
<PrivateRoute path='/teams/:teamId/create-user' component={User} exact />
163159
<PrivateRoute path='/teams/:teamId/create-project' component={Project} exact />
164160
<PrivateRoute path='/teams/:teamId/create-build' component={Build} exact />
165-
<PrivateRoute path='/teams/:teamId/secrets' component={Secrets} exact />
166161
<PrivateRoute path='/teams/:teamId/sealed-secrets' component={SealedSecrets} exact />
167-
<PrivateRoute path='/teams/:teamId/secrets/:secretId' component={Secret} exact />
168162
<PrivateRoute
169-
path='/teams/:teamId/sealed-secrets/:secretId'
163+
path='/teams/:teamId/sealed-secrets/:sealedSecretName'
170164
component={SealedSecret}
171165
exact
172166
/>
173167
<PrivateRoute path='/teams/:teamId/backups' component={Backups} exact />
174-
<PrivateRoute path='/teams/:teamId/backups/:backupId' component={Backup} exact />
168+
<PrivateRoute path='/teams/:teamId/backups/:backupName' component={Backup} exact />
175169
<PrivateRoute path='/teams/:teamId/netpols' component={Netpols} exact />
176-
<PrivateRoute path='/teams/:teamId/netpols/:netpolId' component={Netpol} exact />
170+
<PrivateRoute path='/teams/:teamId/netpols/:netpolName' component={Netpol} exact />
177171
<PrivateRoute path='/teams/:teamId/projects' component={Projects} exact />
178-
<PrivateRoute path='/teams/:teamId/projects/:projectId' component={Project} exact />
172+
<PrivateRoute path='/teams/:teamId/projects/:projectName' component={Project} exact />
179173
{/* <Route path='/teams/:teamId/builds' component={Builds} exact /> */}
180174
<PrivateRoute exact path='/teams/:teamId/builds' component={Builds} />
181175
<PrivateRoute path='/teams/:teamId/builds/:buildName' component={Build} exact />
182176
<PrivateRoute path='/teams/:teamId/policies' component={Policies} exact />
183177
<PrivateRoute path='/teams/:teamId/policies/:policyId' component={Policy} exact />
184178
<PrivateRoute path='/teams/:teamId/workloads' component={Workloads} exact />
185179
<PrivateRoute path='/teams/:teamId/services' component={Services} exact />
186-
<PrivateRoute path='/teams/:teamId/services/:serviceId' component={Service} exact />
180+
<PrivateRoute path='/teams/:teamId/services/:serviceName' component={Service} exact />
187181
<PrivateRoute path='/maintenance' component={Maintenance} platformAdminRoute exact />
188182
<Route path='/logout' component={Logout} />
189183
<Route path='*'>

src/components/Backups.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface Row {
1515
}
1616

1717
const getBackupNames = (row: Row) => {
18-
const path = `/teams/${row.teamId}/backups/${encodeURIComponent(row.id)}`
18+
const path = `/teams/${row.teamId}/backups/${encodeURIComponent(row.name)}`
1919
return (
2020
<RLink to={path} label={row.name}>
2121
{row.name}

src/components/Build.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ export const getBuildSchema = (teamId: string): any => {
1111
return schema
1212
}
1313

14-
export const getBuildUiSchema = (user: GetSessionApiResponse['user'], teamId: string, formData: any): any => {
14+
export const getBuildUiSchema = (
15+
user: GetSessionApiResponse['user'],
16+
teamId: string,
17+
formData: any,
18+
isNameEditable: boolean,
19+
): any => {
1520
const uiSchema = {
1621
id: { 'ui:widget': 'hidden' },
1722
teamId: { 'ui:widget': 'hidden' },
23+
name: { 'ui:readonly': !isNameEditable },
1824
namespace: teamId !== 'admin' && { 'ui:widget': 'hidden' },
1925
secretName: !formData?.externalRepo && { 'ui:widget': 'hidden' },
2026
}
@@ -38,6 +44,6 @@ export default function ({ build, teamId, ...other }: Props): React.ReactElement
3844
// END HOOKS
3945
const formData = cloneDeep(data)
4046
const schema = getBuildSchema(teamId)
41-
const uiSchema = getBuildUiSchema(user, teamId, formData)
47+
const uiSchema = getBuildUiSchema(user, teamId, formData, !build?.name)
4248
return <Form schema={schema} uiSchema={uiSchema} data={formData} onChange={setData} resourceType='Build' {...other} />
4349
}

src/components/Netpols.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import ListTable from './ListTable'
88

99
const getNetpolLink = (isAdmin, ownerId) =>
1010
function (row) {
11-
const { teamId, id, name }: { teamId: string; id: string; name: string } = row
11+
const { teamId, name }: { teamId: string; id: string; name: string } = row
1212
if (!(isAdmin || teamId === ownerId)) return name
1313

1414
const path =
15-
isAdmin && !ownerId ? `/netpols/${encodeURIComponent(id)}` : `/teams/${teamId}/netpols/${encodeURIComponent(id)}`
15+
isAdmin && !ownerId
16+
? `/netpols/${encodeURIComponent(name)}`
17+
: `/teams/${teamId}/netpols/${encodeURIComponent(name)}`
1618
return (
1719
<RLink to={path} label={name}>
1820
{name}

src/components/Project.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ interface Props extends CrudProps {
133133
teamId: string
134134
create: any
135135
update: any
136-
projectId?: string
136+
projectName?: string
137137
project?: any
138138
onDelete?: any
139139
}
@@ -142,7 +142,7 @@ export default function ({
142142
teamId,
143143
create,
144144
update,
145-
projectId,
145+
projectName,
146146
project,
147147
onDelete,
148148
...other
@@ -223,7 +223,7 @@ export default function ({
223223
const projectUiSchema = getProjectUiSchema(user, teamId)
224224

225225
const buildSchema = getBuildSchema(teamId)
226-
const buildUiSchema = getBuildUiSchema(user, teamId, formData?.build)
226+
const buildUiSchema = getBuildUiSchema(user, teamId, formData?.build, !project?.build?.name)
227227
buildUiSchema.name = { 'ui:widget': 'hidden' }
228228

229229
const helmChart: string = data?.workload?.chartMetadata?.helmChart || data?.workload?.path || helmCharts?.[0]
@@ -262,7 +262,7 @@ export default function ({
262262

263263
const handleCreateProject = () => {
264264
const { name } = formData
265-
if (formData?.id) {
265+
if (projectName) {
266266
if (!formData.service.name) setData({ ...formData, service: { name } })
267267
if (selectedPath === 'useExisting') {
268268
delete formData.build
@@ -301,15 +301,15 @@ export default function ({
301301
}
302302
const res = await update({
303303
teamId,
304-
projectId,
304+
projectName,
305305
body,
306306
})
307307
if (res.error) return
308308
history.push(user.isPlatformAdmin ? `/projects` : `/teams/${teamId}/projects`)
309309
}
310310

311311
const handleDeleteProject = () => {
312-
onDelete({ teamId, projectId })
312+
onDelete({ teamId, projectName })
313313
history.push(user.isPlatformAdmin ? `/projects` : `/teams/${teamId}/projects`)
314314
}
315315

@@ -329,7 +329,7 @@ export default function ({
329329
return (
330330
<Box>
331331
<Box sx={{ position: 'absolute', right: '24px' }}>
332-
{projectId && (
332+
{projectName && (
333333
<DeleteButton
334334
onDelete={handleDeleteProject}
335335
resourceName={project?.name}

src/components/Projects.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface Row {
1818
}
1919

2020
const getProjectLink = (row: Row) => {
21-
const path = `/teams/${row.teamId}/projects/${encodeURIComponent(row.id)}`
21+
const path = `/teams/${row.teamId}/projects/${encodeURIComponent(row.name)}`
2222
return (
2323
<RLink to={path} label={row.name}>
2424
{row.name}

src/components/SealedSecrets.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import InformationBanner from './InformationBanner'
1313

1414
const getSecretLink = (isAdmin, ownerId) =>
1515
function (row) {
16-
const { teamId, id, name }: { teamId: string; id: string; name: string } = row
16+
const { teamId, name }: { teamId: string; name: string } = row
1717
if (!(isAdmin || teamId === ownerId)) return name
1818

1919
const path =
2020
isAdmin && !ownerId
21-
? `/sealed-secrets/${encodeURIComponent(id)}`
22-
: `/teams/${teamId}/sealed-secrets/${encodeURIComponent(id)}`
21+
? `/sealed-secrets/${encodeURIComponent(name)}`
22+
: `/teams/${teamId}/sealed-secrets/${encodeURIComponent(name)}`
2323
return (
2424
<RLink to={path} label={name}>
2525
{name}
@@ -28,11 +28,11 @@ const getSecretLink = (isAdmin, ownerId) =>
2828
}
2929

3030
interface Props {
31-
secrets: GetSealedSecretsApiResponse
31+
sealedSecrets: GetSealedSecretsApiResponse
3232
teamId?: string
3333
}
3434

35-
export default function ({ secrets, teamId }: Props): React.ReactElement {
35+
export default function ({ sealedSecrets, teamId }: Props): React.ReactElement {
3636
const {
3737
oboTeamId,
3838
user: { isPlatformAdmin },
@@ -54,7 +54,7 @@ export default function ({ secrets, teamId }: Props): React.ReactElement {
5454
{
5555
id: 'Status',
5656
label: 'Status',
57-
renderer: (row) => getStatus(status?.sealedSecrets?.[row.id]),
57+
renderer: (row) => getStatus(status?.sealedSecrets?.[row.name]),
5858
},
5959
]
6060
if (!teamId) {
@@ -74,7 +74,7 @@ export default function ({ secrets, teamId }: Props): React.ReactElement {
7474
</MuiLink>
7575
</InformationBanner>
7676
)}
77-
<ListTable teamId={teamId} headCells={headCells} rows={secrets} resourceType='SealedSecret' />
77+
<ListTable teamId={teamId} headCells={headCells} rows={sealedSecrets} resourceType='SealedSecret' />
7878
</Box>
7979
)
8080
}

src/components/Secret.tsx

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/components/Secrets.tsx

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)