diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 2d2ba56d..2d260197 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -41,7 +41,7 @@ "Key Name": "Key Name", " will be deleted.": " will be deleted.", "Delete": "Delete", - "will be deleted from Redis for VS Code.": "will be deleted from Redis for VS Code.", + "will be removed from Redis for VS Code.": "will be removed from Redis for VS Code.", "Key Size": "Key Size", "Key Size: ": "Key Size: ", "Length": "Length", @@ -295,9 +295,6 @@ "Host:": "Host:", "Database Index:": "Database Index:", "Modules:": "Modules:", - "Select Logical Database": "Select Logical Database", - "Database Index": "Database Index", - "Enter Database Index": "Enter Database Index", "No decompression": "No decompression", "Enable automatic data decompression": "Enable automatic data decompression", "Decompression format": "Decompression format", diff --git a/package.json b/package.json index d829405c..00c17e55 100644 --- a/package.json +++ b/package.json @@ -143,6 +143,7 @@ "download:backend": "tsc ./scripts/downloadBackend.ts && node ./scripts/downloadBackend.js", "dev": "vite dev", "dev:key": "cross-env RI_DATA_ROUTE=main/key vite dev", + "dev:database": "cross-env RI_DATA_ROUTE=main/add_database vite dev", "dev:sidebar": "cross-env RI_DATA_ROUTE=sidebar vite dev", "l10n:collect": "npx @vscode/l10n-dev export -o ./l10n ./src", "watch": "tsc -watch -p ./", @@ -286,7 +287,7 @@ "react-inlinesvg": "^4.1.1", "react-monaco-editor": "^0.55.0", "react-router-dom": "^6.17.0", - "react-select": "^5.8.0", + "react-select": "^5.8.3", "react-spinners": "^0.13.8", "react-virtualized": "^9.22.5", "react-virtualized-auto-sizer": "^1.0.20", diff --git a/src/webviews/src/components/database-form/TlsDetails.tsx b/src/webviews/src/components/database-form/TlsDetails.tsx index ddd70cd6..d4398d89 100644 --- a/src/webviews/src/components/database-form/TlsDetails.tsx +++ b/src/webviews/src/components/database-form/TlsDetails.tsx @@ -2,40 +2,61 @@ import React, { ChangeEvent, useId } from 'react' import cx from 'classnames' import { FormikProps } from 'formik' import * as l10n from '@vscode/l10n' -import { VSCodeDivider } from '@vscode/webview-ui-toolkit/react' import { CheckboxChangeEvent } from 'rc-checkbox' +import { find } from 'lodash' +import { MenuListProps } from 'react-select' -import { validateCertName, validateField } from 'uiSrc/utils' +import { sendEventTelemetry, TelemetryEvent, validateCertName, validateField } from 'uiSrc/utils' import { ADD_NEW, ADD_NEW_CA_CERT, - ADD_NEW_CA_CERT_LABEL, - ADD_NEW_LABEL, + ApiEndpoints, NO_CA_CERT, - NO_CA_CERT_LABEL, } from 'uiSrc/constants' -import { DbConnectionInfo } from 'uiSrc/interfaces' -import { Checkbox, InputText, Select, TextArea } from 'uiSrc/ui' +import { DbConnectionInfo, RedisString } from 'uiSrc/interfaces' +import { Checkbox, InputText, TextArea } from 'uiSrc/ui' +import { removeCertAction } from 'uiSrc/store' +import { SuperSelectRemovableOption, SuperSelect, SuperSelectOption } from 'uiSrc/components' import styles from './styles.module.scss' +const suffix = '_tls_details' + export interface Props { formik: FormikProps caCertificates?: { id: string, name: string }[] certificates?: { id: string, name: string }[] } + const TlsDetails = (props: Props) => { const { formik, caCertificates, certificates } = props const id = useId() - const optionsCertsCA = [ - { - value: NO_CA_CERT, - label: NO_CA_CERT_LABEL, - }, - { - value: ADD_NEW_CA_CERT, - label: ADD_NEW_CA_CERT_LABEL, - }, + const handleDeleteCaCert = (id: RedisString, onSuccess?: () => void) => { + removeCertAction(id, ApiEndpoints.CA_CERTIFICATES, () => { + onSuccess?.() + handleClickDeleteCert('CA') + }) + } + + const handleDeleteClientCert = (id: RedisString, onSuccess?: () => void) => { + removeCertAction(id, ApiEndpoints.CLIENT_CERTIFICATES, () => { + onSuccess?.() + handleClickDeleteCert('Client') + }) + } + + const handleClickDeleteCert = (certificateType: 'Client' | 'CA') => { + sendEventTelemetry({ + event: TelemetryEvent.CONFIG_DATABASES_CERTIFICATE_REMOVED, + eventData: { + certificateType, + }, + }) + } + + const optionsCertsCA: SuperSelectOption[] = [ + NO_CA_CERT, + ADD_NEW_CA_CERT, ] caCertificates?.forEach((cert) => { @@ -45,12 +66,7 @@ const TlsDetails = (props: Props) => { }) }) - const optionsCertsClient = [ - { - value: ADD_NEW, - label: ADD_NEW_LABEL, - }, - ] + const optionsCertsClient: SuperSelectOption[] = [ADD_NEW] certificates?.forEach((cert) => { optionsCertsClient.push({ @@ -130,17 +146,22 @@ const TlsDetails = (props: Props) => {
{`${l10n.t('CA Certificate')}${formik.values.verifyServerTlsCert ? '*' : ''}`}
-