Skip to content

Commit 25c0e64

Browse files
authored
chore: update todo htmlFor usage in labels COMPASS-5653 (#3447)
1 parent d59e5e9 commit 25c0e64

File tree

7 files changed

+65
-60
lines changed

7 files changed

+65
-60
lines changed

packages/connection-form/src/components/advanced-options-tabs/advanced-tab/url-options.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import {
33
spacing,
4-
Label,
4+
Body,
55
Description,
66
Link,
77
css,
@@ -29,7 +29,7 @@ function UrlOptions({
2929
}): React.ReactElement {
3030
return (
3131
<div className={urlOptionsContainerStyles} data-testid="url-options">
32-
<Label htmlFor={''}>URI Options</Label>
32+
<Body weight="medium">URI Options</Body>
3333
<Description className={urlOptionsTableDescriptionStyles}>
3434
Add additional MongoDB URI options to customize your connection.&nbsp;
3535
<Link

packages/connection-form/src/components/advanced-options-tabs/csfle-tab/csfle-tab.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { ConnectionOptions } from 'mongodb-data-service';
44
import {
55
Accordion,
66
Banner,
7+
Body,
78
Checkbox,
89
Label,
910
Link,
@@ -147,7 +148,7 @@ function CSFLETab({
147148
/>
148149
</FormFieldContainer>
149150
<FormFieldContainer>
150-
<Label htmlFor="TODO(COMPASS-5653)">KMS Providers</Label>
151+
<Body weight="medium">KMS Providers</Body>
151152
<Description>
152153
Specify one or more Key Management Systems to use.
153154
</Description>

packages/connection-form/src/components/advanced-options-tabs/csfle-tab/encrypted-field-config-input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const ENCRYPTED_FIELDS_MAP_PLACEHOLDER = `{
3636
}
3737
`;
3838

39+
const encryptedFieldsMapEditorId = 'encrypted-fields-map-editor-id';
40+
3941
function EncryptedFieldConfigInput({
4042
encryptedFieldsMap,
4143
errorMessage,
@@ -60,11 +62,12 @@ function EncryptedFieldConfigInput({
6062
return (
6163
<div data-testid="connection-csfle-encrypted-fields-map">
6264
<FormFieldContainer>
63-
<Label htmlFor="TODO(COMPASS-5653)">{label}</Label>
65+
<Label htmlFor={encryptedFieldsMapEditorId}>{label}</Label>
6466
<Description>{description}</Description>
6567
<Editor
6668
data-testid="encrypted-fields-map-editor"
6769
variant="Shell"
70+
id={encryptedFieldsMapEditorId}
6871
text={encryptedFieldConfigToText(encryptedFieldsMap)}
6972
onChangeText={(newText) => {
7073
setHasEditedContent(true);

packages/databases-collections/src/components/collection-fields/capped-collection-fields.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { TextInput } from '@mongodb-js/compass-components';
4-
import { spacing, css } from '@mongodb-js/compass-components';
54

65
import CollapsibleFieldSet from '../collapsible-field-set/collapsible-field-set';
76
import FieldSet from '../field-set/field-set';

packages/databases-collections/src/components/collection-fields/fle2-fields.jsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import {
4-
css,
54
Description,
65
Editor,
76
EditorVariant,
87
Label,
9-
Option,
108
RadioBox,
119
RadioBoxGroup,
12-
Select,
13-
SelectSize
1410
} from '@mongodb-js/compass-components';
1511

1612
import CollapsibleFieldSet from '../collapsible-field-set/collapsible-field-set';
@@ -56,6 +52,9 @@ const keyEncryptionKeyTemplate = {
5652
kmip: '/* No KeyEncryptionKey required */\n{}'
5753
};
5854

55+
const queryableEncryptedFieldsEditorId = 'queryable-encrypted-fields-editor-id';
56+
const keyEncryptionKeyEditorId = 'key-encryption-key-editor-id';
57+
5958
function FLE2Fields({
6059
isCapped,
6160
isTimeSeries,
@@ -77,10 +76,11 @@ function FLE2Fields({
7776
description="Encrypt a subset of the fields using Queryable Encryption."
7877
>
7978
<FieldSet>
80-
<Label htmlFor="TODO(COMPASS-5653)">Encrypted fields</Label>
79+
<Label htmlFor={queryableEncryptedFieldsEditorId}>Encrypted fields</Label>
8180
<Description>Indicate which fields should be encrypted and whether they should be queryable.</Description>
8281
<Editor
8382
variant={EditorVariant.Shell}
83+
id={queryableEncryptedFieldsEditorId}
8484
name="fle2.encryptedFields"
8585
value={fle2.encryptedFields}
8686
data-testid="fle2-encryptedFields"
@@ -124,10 +124,11 @@ function FLE2Fields({
124124
</FieldSet>
125125

126126
<FieldSet>
127-
<Label htmlFor="TODO(COMPASS-5653)">Key Encryption Key</Label>
127+
<Label htmlFor={keyEncryptionKeyEditorId}>Key Encryption Key</Label>
128128
<Description>Specify which key encryption key to use for creating new data encryption keys.</Description>
129129
<Editor
130130
variant={EditorVariant.Shell}
131+
id={keyEncryptionKeyEditorId}
131132
name="fle2.keyEncryptionKey"
132133
defaultValue={keyEncryptionKeyTemplate[fle2.kmsProvider]}
133134
value={fle2.keyEncryptionKey || keyEncryptionKeyTemplate[fle2.kmsProvider]}

packages/databases-collections/src/components/collection-fields/time-series-fields.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback } from 'react';
22
import PropTypes from 'prop-types';
33
import { Select, Option, TextInput } from '@mongodb-js/compass-components';
4-
import { spacing, css } from '@mongodb-js/compass-components';
4+
import { css } from '@mongodb-js/compass-components';
55

66
import FieldSet from '../field-set/field-set';
77
import CollapsibleFieldSet from '../collapsible-field-set/collapsible-field-set';

packages/databases-collections/src/modules/create-collection/index.js

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,55 @@ export const open = (dbName) => ({
100100
databaseName: dbName
101101
});
102102

103+
104+
export async function handleFLE2Options(ds, options) {
105+
if (!options) {
106+
return options;
107+
}
108+
109+
if (options.encryptedFields) {
110+
try {
111+
options.encryptedFields = queryParser(options.encryptedFields);
112+
} catch (err) {
113+
throw new Error(`Could not parse encryptedFields config: ${err.message}`);
114+
}
115+
116+
if (Object.keys(options.encryptedFields).length === 0) {
117+
delete options.encryptedFields;
118+
} else if (options.kmsProvider) {
119+
// If keys are missing from the encryptedFields config,
120+
// generate them as part of the collection creation operation.
121+
let keyEncryptionKey;
122+
try {
123+
keyEncryptionKey = queryParser(options.keyEncryptionKey || '{}');
124+
} catch (err) {
125+
throw new Error(`Could not parse keyEncryptionKey: ${err.message}`);
126+
}
127+
128+
const fields = options.encryptedFields.fields;
129+
if (Array.isArray(fields)) {
130+
const keyCreationPromises = [];
131+
for (const field of fields) {
132+
if (field.keyId) continue;
133+
keyCreationPromises.push((async() => {
134+
field.keyId = await ds.createDataKey(options.kmsProvider, {
135+
masterKey: keyEncryptionKey
136+
});
137+
})());
138+
}
139+
await Promise.all(keyCreationPromises);
140+
}
141+
}
142+
} else {
143+
delete options.encryptedFields;
144+
}
145+
146+
delete options.kmsProvider;
147+
delete options.keyEncryptionKey;
148+
149+
return options;
150+
}
151+
103152
export const createCollection = (data, kind = 'Collection') => {
104153
// Note: This method can also be called from createDatabase(),
105154
// against a different state.
@@ -152,51 +201,3 @@ export const createCollection = (data, kind = 'Collection') => {
152201
}
153202
};
154203
};
155-
156-
export async function handleFLE2Options(ds, options) {
157-
if (!options) {
158-
return options;
159-
}
160-
161-
if (options.encryptedFields) {
162-
try {
163-
options.encryptedFields = queryParser(options.encryptedFields);
164-
} catch (err) {
165-
throw new Error(`Could not parse encryptedFields config: ${err.message}`);
166-
}
167-
168-
if (Object.keys(options.encryptedFields).length === 0) {
169-
delete options.encryptedFields;
170-
} else if (options.kmsProvider) {
171-
// If keys are missing from the encryptedFields config,
172-
// generate them as part of the collection creation operation.
173-
let keyEncryptionKey;
174-
try {
175-
keyEncryptionKey = queryParser(options.keyEncryptionKey || '{}');
176-
} catch (err) {
177-
throw new Error(`Could not parse keyEncryptionKey: ${err.message}`);
178-
}
179-
180-
const fields = options.encryptedFields.fields;
181-
if (Array.isArray(fields)) {
182-
const keyCreationPromises = [];
183-
for (const field of fields) {
184-
if (field.keyId) continue;
185-
keyCreationPromises.push((async() => {
186-
field.keyId = await ds.createDataKey(options.kmsProvider, {
187-
masterKey: keyEncryptionKey
188-
});
189-
})());
190-
}
191-
await Promise.all(keyCreationPromises);
192-
}
193-
}
194-
} else {
195-
delete options.encryptedFields;
196-
}
197-
198-
delete options.kmsProvider;
199-
delete options.keyEncryptionKey;
200-
201-
return options;
202-
}

0 commit comments

Comments
 (0)