Skip to content

Commit 21a8efc

Browse files
committed
further refactoring
1 parent 51b90c5 commit 21a8efc

17 files changed

+1022
-1647
lines changed

webroot/adm/client-key.html

Lines changed: 82 additions & 190 deletions
Large diffs are not rendered by default.

webroot/adm/client-side-keypair.html

Lines changed: 49 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,37 @@ <h1>UID2 Env - Client Side Keypair Management</h1>
2424
import { initializeOutput } from '/js/output.js';
2525

2626
document.addEventListener('DOMContentLoaded', function () {
27-
const operationConfig = [
28-
{
29-
type: 'read-only',
30-
title: 'Read Only Operations',
31-
operations: [
27+
const siteIdInput = {
28+
name: 'siteId',
29+
label: 'Site ID',
30+
required: true,
31+
type: 'number'
32+
};
33+
34+
const subscriptionIdInput = {
35+
name: 'subscriptionId',
36+
label: 'Subscription ID',
37+
required: true,
38+
size: 2
39+
};
40+
41+
const keypairNameInput = {
42+
name: 'name',
43+
label: 'Keypair Name',
44+
required: false,
45+
size: 2
46+
};
47+
48+
const disableCheckbox = {
49+
name: 'disable',
50+
label: 'Disable Keypair',
51+
type: 'checkbox'
52+
};
53+
54+
const operationConfig = {
55+
read: [
3256
{
33-
id: 'doList',
57+
id: 'listKeypairs',
3458
title: 'List Keypairs',
3559
role: 'maintainer',
3660
inputs: [],
@@ -40,19 +64,10 @@ <h1>UID2 Env - Client Side Keypair Management</h1>
4064
}
4165
},
4266
{
43-
id: 'doListSite',
67+
id: 'listKeypairsBySiteId',
4468
title: 'List Keypairs By Site ID',
4569
role: 'maintainer',
46-
inputs: [
47-
{
48-
id: 'siteId-listSite',
49-
name: 'siteId',
50-
label: 'Site ID',
51-
required: true,
52-
size: 1,
53-
type: 'number'
54-
}
55-
],
70+
inputs: [ siteIdInput ],
5671
apiCall: {
5772
method: 'GET',
5873
url: '/api/client_side_keypairs/list'
@@ -63,56 +78,25 @@ <h1>UID2 Env - Client Side Keypair Management</h1>
6378
}
6479
},
6580
{
66-
id: 'doListSubscription',
81+
id: 'getKeypairBySubscriptionId',
6782
title: 'Get Keypair By Subscription ID',
6883
role: 'maintainer',
69-
inputs: [
70-
{
71-
id: 'subscriptionId-get',
72-
name: 'subscriptionId',
73-
label: 'Subscription ID',
74-
required: true,
75-
size: 2
76-
}
77-
],
84+
inputs: [ subscriptionIdInput ],
7885
apiCall: {
7986
method: 'GET',
8087
getUrl: (inputs) => `/api/client_side_keypairs/${encodeURIComponent(inputs.subscriptionId)}`
8188
}
8289
}
83-
]
84-
},
85-
{
86-
type: 'write',
87-
title: 'Write Operations',
88-
operations: [
90+
],
91+
write: [
8992
{
90-
id: 'doCreate',
93+
id: 'addKeypair',
9194
title: 'Add Keypair',
9295
role: 'maintainer',
9396
inputs: [
94-
{
95-
id: 'siteId-create',
96-
name: 'siteId',
97-
label: 'Site ID',
98-
required: true,
99-
size: 1,
100-
type: 'number'
101-
},
102-
{
103-
id: 'name-create',
104-
name: 'name',
105-
label: 'Keypair Name',
106-
required: false,
107-
size: 2
108-
},
109-
{
110-
id: 'disable-create',
111-
name: 'disable',
112-
label: 'Disable Keypair',
113-
type: 'checkbox',
114-
size: 1
115-
}
97+
siteIdInput,
98+
keypairNameInput,
99+
disableCheckbox
116100
],
117101
apiCall: {
118102
method: 'POST',
@@ -125,31 +109,13 @@ <h1>UID2 Env - Client Side Keypair Management</h1>
125109
}
126110
},
127111
{
128-
id: 'doUpdate',
112+
id: 'updateKeypair',
129113
title: 'Update Keypair',
130114
role: 'maintainer',
131115
inputs: [
132-
{
133-
id: 'subscriptionId-update',
134-
name: 'subscriptionId',
135-
label: 'Subscription ID',
136-
required: true,
137-
size: 2
138-
},
139-
{
140-
id: 'name-update',
141-
name: 'name',
142-
label: 'Keypair Name',
143-
required: false,
144-
size: 2
145-
},
146-
{
147-
id: 'disable-update',
148-
name: 'disable',
149-
label: 'Disable Keypair',
150-
type: 'checkbox',
151-
size: 1
152-
}
116+
subscriptionIdInput,
117+
keypairNameInput,
118+
disableCheckbox
153119
],
154120
preProcess: (inputs) => {
155121
// Show confirmation dialog with appropriate message
@@ -181,25 +147,13 @@ <h1>UID2 Env - Client Side Keypair Management</h1>
181147
}
182148
}
183149
}
184-
]
185-
},
186-
{
187-
type: 'danger-zone',
188-
title: '☠️ Danger Zone ☠️',
189-
operations: [
150+
],
151+
danger: [
190152
{
191-
id: 'doDelete',
153+
id: 'deleteKeypair',
192154
title: 'Delete Keypair',
193155
role: 'elevated',
194-
inputs: [
195-
{
196-
id: 'subscriptionId-delete',
197-
name: 'subscriptionId',
198-
label: 'Subscription ID',
199-
required: true,
200-
size: 2
201-
}
202-
],
156+
inputs: [ subscriptionIdInput ],
203157
description: 'This will permanently delete the client-side keypair. This action cannot be undone.',
204158
preProcess: (inputs) => {
205159
const message = `Are you sure you want to delete ${inputs.subscriptionId}?`;
@@ -214,8 +168,7 @@ <h1>UID2 Env - Client Side Keypair Management</h1>
214168
}
215169
}
216170
]
217-
}
218-
];
171+
};
219172

220173
initializeOperations(operationConfig);
221174
initializeOutput();

webroot/adm/cloud-encryption-key.html

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,10 @@ <h1>UID2 Env - Cloud Encryption Key Management</h1>
132132
grid.updateConfig({ data: [] }).forceRender();
133133
};
134134

135-
const operationConfig = [
136-
{
137-
type: 'read-only',
138-
title: 'Read Only Operations',
139-
operations: [
135+
const operationConfig = {
136+
read: [
140137
{
141-
id: 'doMeta',
138+
id: 'getCloudEncryptionMetadata',
142139
title: 'Get Metadata',
143140
role: 'maintainer',
144141
inputs: [],
@@ -148,7 +145,7 @@ <h1>UID2 Env - Cloud Encryption Key Management</h1>
148145
}
149146
},
150147
{
151-
id: 'doList',
148+
id: 'listCloudEncryptionKeys',
152149
title: 'List Cloud Encryption Keys',
153150
role: 'maintainer',
154151
inputs: [],
@@ -184,14 +181,10 @@ <h1>UID2 Env - Cloud Encryption Key Management</h1>
184181
url: '/api/cloud-encryption-key/list'
185182
}
186183
}
187-
]
188-
},
189-
{
190-
type: 'write',
191-
title: 'Write Operations',
192-
operations: [
184+
],
185+
write: [
193186
{
194-
id: 'doRotate',
187+
id: 'rotateCloudEncryptionKeys',
195188
title: 'Rotate Cloud Encryption Keys',
196189
role: 'maintainer',
197190
inputs: [],
@@ -222,7 +215,7 @@ <h1>UID2 Env - Cloud Encryption Key Management</h1>
222215
}
223216
},
224217
{
225-
id: 'doEncrypt',
218+
id: 'reencryptAllS3Files',
226219
title: 'Re-encrypt All S3 Files',
227220
role: 'maintainer',
228221
inputs: [],
@@ -232,8 +225,7 @@ <h1>UID2 Env - Cloud Encryption Key Management</h1>
232225
}
233226
}
234227
]
235-
}
236-
];
228+
};
237229

238230
initializeOperations(operationConfig);
239231
initializeOutput();

webroot/adm/enclave-gcp-v2.html

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -109,44 +109,18 @@ <h3>Generated Examples</h3>
109109
return sha256base64(str);
110110
}
111111

112-
const operationConfig = [
113-
{
114-
type: 'write',
112+
const operationConfig = {
113+
write: {
115114
title: 'GCP Enclave V2 Operations',
116115
operations: [
117116
{
118-
id: 'doGenerate',
117+
id: 'generateGcpV2EnclaveConfig',
119118
title: 'Generate Enclave ID and gcloud command',
120119
role: 'elevated',
121120
inputs: [
122-
{
123-
id: 'imageId-generate',
124-
name: 'imageId',
125-
label: 'Operator Docker Image ID',
126-
required: true,
127-
size: 3,
128-
placeholder: 'The full digest for the image, with or without \'sha256:\''
129-
},
130-
{
131-
id: 'envId-generate',
132-
name: 'envId',
133-
label: 'Environment',
134-
type: 'select',
135-
required: true,
136-
size: 1,
137-
defaultValue: 'integ',
138-
options: [
139-
{ value: 'integ', label: 'Integration' },
140-
{ value: 'prod', label: 'Production' }
141-
]
142-
},
143-
{
144-
id: 'debugMode-generate',
145-
name: 'debugMode',
146-
label: 'Debug Mode (Integration Only)',
147-
type: 'checkbox',
148-
size: 2
149-
}
121+
imageIdInput,
122+
envIdSelectInput,
123+
debugModeCheckboxInput
150124
],
151125
description: 'Set Debug Mode to true if you want to use DebugMode Confidential Space host image in integration env. (You need to generate a new enclaveId.)',
152126
preProcess: async (inputs) => {
@@ -202,7 +176,7 @@ <h3>Generated Examples</h3>
202176
}
203177
]
204178
}
205-
];
179+
};
206180

207181
initializeOperations(operationConfig);
208182
initializeOutput();

0 commit comments

Comments
 (0)