From c046cbc85d516295cdb1fed8175e6724e9de3aa8 Mon Sep 17 00:00:00 2001 From: N00bG1rl <403helen@gmail.com> Date: Fri, 29 Sep 2023 12:24:17 +0300 Subject: [PATCH 1/3] Delete redundant code --- .../SelfService/Web/admin/CreateCustomer.tsx | 145 ------------- Source/SelfService/Web/admin/index.tsx | 2 - .../microservice/components/headDataRow.tsx | 39 ---- .../components/liveIngressView.tsx | 52 ----- .../microservice/rawDataLog/config/config.tsx | 81 ------- .../rawDataLog/config/configView.tsx | 50 ----- .../microservice/rawDataLog/config/edit.tsx | 32 --- .../rawDataLog/config/editConfig.tsx | 47 ----- .../microservice/rawDataLog/view.tsx | 94 --------- .../microservice/rawDataLog/webhook/edit.tsx | 197 ------------------ .../microservice/rawDataLog/webhooks.tsx | 148 ------------- .../Web/components/basicAuthComponent.tsx | 58 ------ .../Web/components/bearerAuthComponent.tsx | 36 ---- .../Web/components/breadCrumbWithRedirect.tsx | 22 -- .../SelfService/Web/components/buttonLink.tsx | 22 -- .../Web/components/layout/breadcrumbs.tsx | 57 ----- .../Web/components/theme-legacy/textField.tsx | 86 -------- 17 files changed, 1168 deletions(-) delete mode 100644 Source/SelfService/Web/admin/CreateCustomer.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/components/headDataRow.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/components/liveIngressView.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/rawDataLog/config/config.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/rawDataLog/config/configView.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/rawDataLog/config/edit.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/rawDataLog/config/editConfig.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/rawDataLog/view.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/rawDataLog/webhook/edit.tsx delete mode 100644 Source/SelfService/Web/applications/microservice/rawDataLog/webhooks.tsx delete mode 100644 Source/SelfService/Web/components/basicAuthComponent.tsx delete mode 100644 Source/SelfService/Web/components/bearerAuthComponent.tsx delete mode 100644 Source/SelfService/Web/components/breadCrumbWithRedirect.tsx delete mode 100644 Source/SelfService/Web/components/buttonLink.tsx delete mode 100644 Source/SelfService/Web/components/layout/breadcrumbs.tsx delete mode 100644 Source/SelfService/Web/components/theme-legacy/textField.tsx diff --git a/Source/SelfService/Web/admin/CreateCustomer.tsx b/Source/SelfService/Web/admin/CreateCustomer.tsx deleted file mode 100644 index 592879ec4..000000000 --- a/Source/SelfService/Web/admin/CreateCustomer.tsx +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -import React from 'react'; - -import { useNavigate } from 'react-router-dom'; -import { useSnackbar } from 'notistack'; - -import { Box, Grid, Step, Stepper, StepContent, StepLabel, Typography } from '@mui/material'; - -import { TextField as ThemedTextField } from '../components/theme-legacy/textField'; -import { Button } from '@dolittle/design-system'; - -import { createCustomer, HttpCustomerRequest } from '../apis/solutions/customer'; - -const styles = { - root: { - width: '100%', - }, - button: { - marginTop: 1, - marginRight: 1, - }, - actionsContainer: { - marginBottom: 2, - }, - resetContainer: { - padding: 3, - }, - inactiveText: { - color: '#93959F', - }, - progressBar: { - color: '#ff9366', - }, - stepIcon: { - 'color': '#3B3D48', - '&.MuiStepIcon-root.Mui-active': { - color: '#6678F6' - }, - '&.MuiStepIcon-root.Mui-completed': { - color: '#6678F6' - }, - '&.MuiStepIcon-root.Mui-active .MuiStepIcon-text': { - fill: '#B3BBFB' - }, - '&.MuiStepIcon-root .MuiStepIcon-text': { - fill: '#93959F' - } - } -}; - -export const CreateCustomer = () => { - const navigate = useNavigate(); - const { enqueueSnackbar } = useSnackbar(); - - const steps = [ - 'Provide a name', - ]; - - const [activeStep, setActiveStep] = React.useState(0); - const [customerName, setCustomerName] = React.useState(''); - - const [activeNextButton, setActiveNextButton] = React.useState(false); - - const stepsContent = [ - <> - Customer Name - - - ) => { - setCustomerName(event.target.value!); - setActiveNextButton(true); - }} - /> - - - ]; - - const handleNext = async () => { - const input: HttpCustomerRequest = { - name: customerName, - }; - - try { - const data = await createCustomer(input); - enqueueSnackbar('Customer created', { variant: 'info' }); - } catch (error) { - enqueueSnackbar('Error creating customer.', { variant: 'error' }); - } - - return; - }; - - return ( - <> - Create Customer Screen - - - - {steps.map((label, index) => ( - - - = index ? {} : styles.inactiveText}>{label} - - - {stepsContent[index]} - - -
-
-
-
-
- ))} -
-
- - ); -}; diff --git a/Source/SelfService/Web/admin/index.tsx b/Source/SelfService/Web/admin/index.tsx index c8faae1e0..6d9175459 100644 --- a/Source/SelfService/Web/admin/index.tsx +++ b/Source/SelfService/Web/admin/index.tsx @@ -7,7 +7,6 @@ import { Route, Routes } from 'react-router-dom'; import { WorkSpaceLayoutWithSidePanel } from '../components/layout/workSpaceLayout'; import { Welcome } from './Welcome'; -import { CreateCustomer } from './CreateCustomer'; import { AllCustomersView } from './AllCustomersView'; import { CustomerView } from './CustomerView'; import { ApplicationAccessView } from './ApplicationAccessView'; @@ -17,7 +16,6 @@ export const AdminIndex = () => } /> } /> - } /> } /> } /> diff --git a/Source/SelfService/Web/applications/microservice/components/headDataRow.tsx b/Source/SelfService/Web/applications/microservice/components/headDataRow.tsx deleted file mode 100644 index 0275097ef..000000000 --- a/Source/SelfService/Web/applications/microservice/components/headDataRow.tsx +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -import React from 'react'; - -import { Box, Typography } from '@mui/material'; - -const styles = { - - label: { - paddingBottom: 2, - color: theme => theme.palette.text.primary - }, - data: { - color: theme => theme.palette.text.secondary - }, - -}; - -export interface HeaderDataRowProps { - head: string - data: string -} - -export const HeaderDataRow: React.FunctionComponent = (props) => { - const head = props!.head; - const data = props!.data; - - return ( - - - {head} - - - - {data} - - - ); -}; diff --git a/Source/SelfService/Web/applications/microservice/components/liveIngressView.tsx b/Source/SelfService/Web/applications/microservice/components/liveIngressView.tsx deleted file mode 100644 index e50839ebb..000000000 --- a/Source/SelfService/Web/applications/microservice/components/liveIngressView.tsx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -import React from 'react'; - -import { Grid, Typography } from '@mui/material'; - -import { HeaderDataRow } from './headDataRow'; -import { IngressURLWithCustomerTenantID, SimpleIngressPath } from '../../../apis/solutions/api'; - -type Props = { - urls: IngressURLWithCustomerTenantID[]; - paths: SimpleIngressPath[]; -}; - -export const LiveIngressView: React.FunctionComponent = (props) => { - const _props = props!; - const urls = _props.urls; - const paths = _props.paths; - - const tenantEndpoints = urls.map(info => { - const data = `${info.url} (${info.customerTenantID})`; - // React is unhappy when customTenantID is empty multiple times - const key = `${info.url}-${info.customerTenantID}`; - return ; - }); - - // Showing unique paths - const microservicePaths = [...new Set(paths.map(info => info.path))].map(infoPath => { - return ; - }); - - - return ( - - - {tenantEndpoints.length > 0 && - <> - Tenant Endpoints - {tenantEndpoints} - - } - - Microservice Paths - {microservicePaths} - - ); -}; diff --git a/Source/SelfService/Web/applications/microservice/rawDataLog/config/config.tsx b/Source/SelfService/Web/applications/microservice/rawDataLog/config/config.tsx deleted file mode 100644 index fb6c992d4..000000000 --- a/Source/SelfService/Web/applications/microservice/rawDataLog/config/config.tsx +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -import React from 'react'; - -import { Label } from '@fluentui/react/lib/Label'; -import { TextField, ITextFieldStyles } from '@fluentui/react/lib/TextField'; -import { Stack } from '@fluentui/react/lib/Stack'; -import { PrimaryButton } from '@fluentui/react/lib/Button'; - -import { MicroserviceRawDataLogIngestor } from '../../../../apis/solutions/index'; - -const textFieldStyles: Partial = { fieldGroup: { width: 300 } }; -const stackTokens = { childrenGap: 15 }; - - -type WebhooksConfigProps = { - domain: string - action: string - ms: MicroserviceRawDataLogIngestor - onSave?: (ms: MicroserviceRawDataLogIngestor) => Promise; -}; -// TODO how to pass in - -export const Config: React.FunctionComponent = (props) => { - const domain = props!.domain; - const onSave = props!.onSave!; - const action = props!.action!; - const ms = props!.ms!; - let actionText = 'Create'; - - switch (action) { - case 'insert': - actionText = 'Create'; - break; - case 'upsert': - actionText = 'Save'; - break; - - } - - return ( - - - - { - ms.name = v!; - }} - /> - - - - - - / - { - ms.extra.ingress.path = `/${v!}`; - }} - /> - - - - { - (async () => { - await onSave(ms); - })(); - }} /> - - - ); -}; - diff --git a/Source/SelfService/Web/applications/microservice/rawDataLog/config/configView.tsx b/Source/SelfService/Web/applications/microservice/rawDataLog/config/configView.tsx deleted file mode 100644 index 6c3cc2463..000000000 --- a/Source/SelfService/Web/applications/microservice/rawDataLog/config/configView.tsx +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -import React from 'react'; - -import { Label } from '@fluentui/react/lib/Label'; -import { TextField, ITextFieldStyles } from '@fluentui/react/lib/TextField'; -import { Stack } from '@fluentui/react/lib/Stack'; - -import { MicroserviceRawDataLogIngestor } from '../../../../apis/solutions/index'; - -const textFieldStyles: Partial = { fieldGroup: { width: 300 } }; -const stackTokens = { childrenGap: 15 }; - -type WebhooksConfigProps = { - microservice: MicroserviceRawDataLogIngestor -}; - -export const ConfigView: React.FunctionComponent = (props) => { - const ms = props!.microservice; - const domain = 'TODO'; - - return ( - - - - - - - - - - / - - - - ); -}; - diff --git a/Source/SelfService/Web/applications/microservice/rawDataLog/config/edit.tsx b/Source/SelfService/Web/applications/microservice/rawDataLog/config/edit.tsx deleted file mode 100644 index 2f52744e5..000000000 --- a/Source/SelfService/Web/applications/microservice/rawDataLog/config/edit.tsx +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - - -// TODO how to load the logs? -// TODO validate the data -// TODO change action button from create to save - -import React from 'react'; - -import { MicroserviceRawDataLogIngestor } from '../../../../apis/solutions/index'; -import { HttpResponseApplication } from '../../../../apis/solutions/application'; -import { EditConfig } from './editConfig'; - -type Props = { - application: HttpResponseApplication - environment: string - ms: MicroserviceRawDataLogIngestor -}; - -export const Edit: React.FunctionComponent = (props) => { - const _props = props!; - const application = _props.application; - const environment = _props.environment; - const ms = _props.ms; - - return ( - <> - - - ); -}; diff --git a/Source/SelfService/Web/applications/microservice/rawDataLog/config/editConfig.tsx b/Source/SelfService/Web/applications/microservice/rawDataLog/config/editConfig.tsx deleted file mode 100644 index 2eab793a7..000000000 --- a/Source/SelfService/Web/applications/microservice/rawDataLog/config/editConfig.tsx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - - -// TODO how to load the logs? -// TODO validate the data -// TODO change action button from create to save - -import React from 'react'; -import { useNavigate } from 'react-router-dom'; - -import { Stack } from '@fluentui/react/lib/Stack'; -import { Config } from './config'; -import { saveRawDataLogIngestorMicroservice } from '../../../stores/microservice'; -import { MicroserviceRawDataLogIngestor } from '../../../../apis/solutions/index'; - -import { HttpResponseApplication } from '../../../../apis/solutions/application'; - -const stackTokens = { childrenGap: 15 }; - -type Props = { - application: HttpResponseApplication - environment: string - ms: MicroserviceRawDataLogIngestor -}; - -export const EditConfig: React.FunctionComponent = (props) => { - const navigate = useNavigate(); - const _props = props!; - const application = _props.application; - const environment = _props.environment; - const ms = _props.ms; - - const onSave = async (ms: MicroserviceRawDataLogIngestor): Promise => { - const data = await saveRawDataLogIngestorMicroservice(ms); - const href = `/microservices/application/${application.id}/${environment}/overview`; - navigate(href); - }; - - return ( - <> - - - - - ); -}; diff --git a/Source/SelfService/Web/applications/microservice/rawDataLog/view.tsx b/Source/SelfService/Web/applications/microservice/rawDataLog/view.tsx deleted file mode 100644 index e44d6dda6..000000000 --- a/Source/SelfService/Web/applications/microservice/rawDataLog/view.tsx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -import React, { useState } from 'react'; - -import { useNavigate } from 'react-router-dom'; -import { useReadable } from 'use-svelte-store'; - -import { microservices, MicroserviceStore } from '../../stores/microservice'; - -import { Stack } from '@fluentui/react/lib/Stack'; -import { Pivot, PivotItem } from '@fluentui/react'; - -import { Typography } from '@mui/material'; - -import { HttpResponsePodStatus } from '../../../apis/solutions/api'; - -import { Webhooks } from './webhooks'; -import { ConfigView } from './config/configView'; - -import { HealthStatusIndex } from '../microserviceDetails/microserviceView/healthStatus'; - -const stackTokens = { childrenGap: 15 }; - -type Props = { - applicationId: string - environment: string - microserviceId: string - podsData: HttpResponsePodStatus -}; - -export const View: React.FunctionComponent = (props) => { - const navigate = useNavigate(); - const $microservices = useReadable(microservices) as any; - - const _props = props!; - const applicationId = _props.applicationId; - const microserviceId = _props.microserviceId; - const environment = _props.environment; - const podsData = _props.podsData; - const [selectedKey, setSelectedKey] = useState('healthStatus'); - - // TODO ENV - const currentMicroservice: MicroserviceStore = $microservices.find(ms => ms.id === microserviceId && ms.environment === environment); - - if (!currentMicroservice) { - const href = `/microservices/application/${applicationId}/overview`; - navigate(href); - return null; - } - - return ( - <> - - {currentMicroservice.name} - - ) => { - const key = item?.props.itemKey as string; - if (selectedKey !== key) { - setSelectedKey(key); - } - }} - > - { - setSelectedKey('config'); - }} - > - {/* */} - - - { - setSelectedKey('webhooks'); - }} - > - {/* */} - - - - - - - - - ); -}; diff --git a/Source/SelfService/Web/applications/microservice/rawDataLog/webhook/edit.tsx b/Source/SelfService/Web/applications/microservice/rawDataLog/webhook/edit.tsx deleted file mode 100644 index 5deb8bbbe..000000000 --- a/Source/SelfService/Web/applications/microservice/rawDataLog/webhook/edit.tsx +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) Dolittle. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -import React, { useState } from 'react'; - -import { Label } from '@fluentui/react/lib/Label'; -import { TextField, ITextFieldStyles } from '@fluentui/react/lib/TextField'; -import { Stack } from '@fluentui/react/lib/Stack'; -import { Dropdown } from '@fluentui/react/lib/Dropdown'; -import { IDropdownOption } from '@fluentui/react'; - -import { Button } from '@dolittle/design-system'; - -import { MicroserviceRawDataLogIngestorWebhookConfig, ConnectorWebhookConfigBasic } from '../../../../apis/solutions/index'; -import { BasicAuthComponent } from '../../../../components/basicAuthComponent'; -import { BearerAuthComponent } from '../../../../components/bearerAuthComponent'; - -import { trimPrefix, trimSuffix } from '../../../../utils/helpers'; -import { makeBasicAuth, makeBearer } from '../../../../utils/httpCredentials'; - -const textFieldStyles: Partial = { fieldGroup: { width: 300 } }; -const stackTokens = { childrenGap: 15 }; - -export type EditProps = { - domain: string; - ingressPath: string; - webhook: MicroserviceRawDataLogIngestorWebhookConfig; - onAfterSave: (webhooks: MicroserviceRawDataLogIngestorWebhookConfig) => Promise; -}; - -const defaultAuthType = 'Basic'; - -export const Edit = (props: EditProps) => { - const currentWebhook = props!.webhook; - let domain = props!.domain; - let ingressPath = props!.ingressPath; - const onAfterSave = props!.onAfterSave; - - domain = trimSuffix(domain, '/'); - ingressPath = trimPrefix(ingressPath, '/'); - ingressPath = trimSuffix(ingressPath, '/'); - - const urlPrefix = `${domain}/${ingressPath}`; - const actionText = 'Save'; - const authInfo = getAuthInfo(currentWebhook.authorization); - - const [authOptionState, setAuthOptionState] = useState(authInfo[0]); - const [config, setConfig] = useState(authInfo); - const [webhook, setWebhook] = useState(currentWebhook); - - const authenticationOptions: IDropdownOption[] = [ - { key: 'Bearer', text: 'Bearer Token' }, - { key: 'Basic', text: 'Basic (username and password)' } - ]; - - const authTypeChanged = (event: React.FormEvent, option?: IDropdownOption, index?: number) => { - // TODO Need to update the config for this kind as well - switch (option!.key) { - case 'Basic': - setConfig(['Basic', '']); - break; - case 'Bearer': - setConfig(['Bearer', '']); - break; - } - - setWebhook({ - ...webhook, - authorization: '', - }); - setAuthOptionState(option!.key as string); - }; - - const onUpdateConfig = (data: any) => { - switch (authOptionState) { - case 'Bearer': - setWebhook({ - ...webhook, - authorization: makeBearer(data), - }); - return; - case 'Basic': - setWebhook({ - ...webhook, - authorization: makeBasicAuth(data as ConnectorWebhookConfigBasic), - }); - return; - } - }; - - return ( - <> - - - , newValue?: string) => { - let kind = newValue!; - if (kind === '') { - kind = webhook.uriSuffix; - } - - setWebhook({ - ...webhook, - kind, - }); - }} - /> - - - - - - / - , newValue?: string) => { - const uriSuffix = newValue!; - let kind = webhook.kind; - if (kind === '' || kind === webhook.uriSuffix) { - kind = uriSuffix; - } - - setWebhook({ - ...webhook, - uriSuffix, - kind, - }); - }} - /> - - - - - - - - - {authOptionState === 'Basic' && ( - - )} - - {authOptionState === 'Bearer' && ( - - )} - - -