Skip to content

Commit

Permalink
chore: Removing Tracking Backend Deletion (#3467)
Browse files Browse the repository at this point in the history
* chore: Removing Tracking Backend Deletion

* chore: Removing Tracking Backend Deletion
  • Loading branch information
xoscar authored Dec 20, 2023
1 parent a1d45f5 commit c5b4c1e
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 101 deletions.
11 changes: 0 additions & 11 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1074,17 +1074,6 @@ paths:
description: "invalid data store, some data was sent in incorrect format."
500:
description: "problem with updating data store"
delete:
tags:
- resource-api
parameters:
- $ref: "./parameters.yaml#/components/parameters/dataStoreId"
summary: "Delete a Data Store"
description: "Delete a Data Store"
operationId: deleteDataStore
responses:
"204":
description: OK

# VariableSets
/variableSets:
Expand Down
1 change: 1 addition & 0 deletions server/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func registerDataStoreResource(repository *datastore.Repository, router *mux.Rou
datastore.ResourceName,
datastore.ResourceNamePlural,
repository,
resourcemanager.DisableDelete(),
resourcemanager.WithTracer(tracer),
resourcemanager.DisableDelete(),
)
Expand Down
6 changes: 1 addition & 5 deletions web/src/components/Settings/DataStore/DataStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Form} from 'antd';
import {useDataStore} from 'providers/DataStore/DataStore.provider';
import {useSettingsValues} from 'providers/SettingsValues/SettingsValues.provider';
import {useCallback} from 'react';
import {TDraftDataStore, ConfigMode} from 'types/DataStore.types';
import {TDraftDataStore} from 'types/DataStore.types';
import DataStoreForm from '../DataStoreForm';
import * as S from './DataStore.styled';

Expand All @@ -15,9 +15,7 @@ const DataStore = () => {
onSaveConfig,
isTestConnectionLoading,
onTestConnection,
onDeleteConfig,
} = useDataStore();
const isConfigReady = dataStoreConfig.mode === ConfigMode.READY;
const [form] = Form.useForm<TDraftDataStore>();

const handleOnSubmit = useCallback(
Expand All @@ -40,9 +38,7 @@ const DataStore = () => {
dataStoreConfig={dataStoreConfig}
onSubmit={handleOnSubmit}
onTestConnection={handleTestConnection}
isConfigReady={isConfigReady}
isTestConnectionLoading={isTestConnectionLoading}
onDeleteConfig={onDeleteConfig}
isLoading={isLoading}
isFormValid={isFormValid}
onIsFormValid={onIsFormValid}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const Description = styled(Typography.Text)`

export const ButtonsContainer = styled.div`
display: flex;
justify-content: space-between;
justify-content: flex-end;
gap: 8px;
margin-top: 23px;
padding: 16px 22px;
Expand All @@ -83,11 +83,6 @@ export const ButtonsContainer = styled.div`
background: white;
`;

export const SaveContainer = styled.div`
display: flex;
gap: 8px;
`;

export const InfoIcon = styled(CheckCircleOutlined)`
color: ${({theme}) => theme.color.text};
cursor: pointer;
Expand Down
45 changes: 12 additions & 33 deletions web/src/components/Settings/DataStoreForm/DataStoreForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {useCallback, useEffect, useMemo} from 'react';
import AllowButton, {Operation} from 'components/AllowButton';
import DataStoreService from 'services/DataStore.service';
import {TDraftDataStore, TDataStoreForm, SupportedDataStores} from 'types/DataStore.types';
import {SupportedDataStoresToName} from 'constants/DataStore.constants';
import DataStoreConfig from 'models/DataStoreConfig.model';
import {DataStoreSelection} from 'components/Inputs';
import DataStoreComponentFactory from '../DataStorePlugin/DataStoreComponentFactory';
Expand All @@ -17,9 +16,7 @@ interface IProps {
onSubmit(values: TDraftDataStore): Promise<void>;
onIsFormValid(isValid: boolean): void;
onTestConnection(): void;
isConfigReady: boolean;
isTestConnectionLoading: boolean;
onDeleteConfig(): void;
isLoading: boolean;
isFormValid: boolean;
}
Expand All @@ -30,9 +27,7 @@ const DataStoreForm = ({
dataStoreConfig,
onIsFormValid,
onTestConnection,
isConfigReady,
isTestConnectionLoading,
onDeleteConfig,
isLoading,
isFormValid,
}: IProps) => {
Expand Down Expand Up @@ -84,34 +79,18 @@ const DataStoreForm = ({
{dataStoreType && <DataStoreComponentFactory dataStoreType={dataStoreType} />}
</S.TopContainer>
<S.ButtonsContainer>
{isConfigReady ? (
<AllowButton
operation={Operation.Configure}
disabled={isLoading}
type="primary"
ghost
onClick={onDeleteConfig}
danger
>
{`Delete ${SupportedDataStoresToName[dataStoreConfig.defaultDataStore.type]} Tracing Backend`}
</AllowButton>
) : (
<div />
)}
<S.SaveContainer>
<Button loading={isTestConnectionLoading} type="primary" ghost onClick={onTestConnection}>
Test Connection
</Button>
<AllowButton
operation={Operation.Configure}
disabled={!isFormValid}
loading={isLoading}
type="primary"
onClick={() => form.submit()}
>
Save and Set as Tracing Backend
</AllowButton>
</S.SaveContainer>
<Button loading={isTestConnectionLoading} type="primary" ghost onClick={onTestConnection}>
Test Connection
</Button>
<AllowButton
operation={Operation.Configure}
disabled={!isFormValid}
loading={isLoading}
type="primary"
onClick={() => form.submit()}
>
Save and Set as DataStore
</AllowButton>
</S.ButtonsContainer>
</S.FactoryContainer>
</S.FormContainer>
Expand Down
28 changes: 2 additions & 26 deletions web/src/providers/DataStore/DataStore.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface IContext {
isFormValid: boolean;
isLoading: boolean;
isTestConnectionLoading: boolean;
onDeleteConfig(): void;
onSaveConfig(draft: TDraftDataStore, defaultDataStore: DataStore): void;
onTestConnection(draft: TDraftDataStore, defaultDataStore: DataStore): void;
onIsFormValid(isValid: boolean): void;
Expand All @@ -29,7 +28,6 @@ export const Context = createContext<IContext>({
onSaveConfig: noop,
onIsFormValid: noop,
onTestConnection: noop,
onDeleteConfig: noop,
});

interface IProps {
Expand All @@ -39,10 +37,9 @@ interface IProps {
export const useDataStore = () => useContext(Context);

const DataStoreProvider = ({children}: IProps) => {
const {useTestConnectionMutation, useUpdateDataStoreMutation, useDeleteDataStoreMutation} = TracetestAPI.instance;
const {useTestConnectionMutation, useUpdateDataStoreMutation} = TracetestAPI.instance;
const {isFetching} = useSettingsValues();
const [updateDataStore, {isLoading: isLoadingUpdate}] = useUpdateDataStoreMutation();
const [deleteDataStore] = useDeleteDataStoreMutation();
const [testConnection, {isLoading: isTestConnectionLoading}] = useTestConnectionMutation();
const [isFormValid, setIsFormValid] = useState(false);
const {showSuccessNotification, showTestConnectionNotification} = useDataStoreNotification();
Expand Down Expand Up @@ -78,18 +75,6 @@ const DataStoreProvider = ({children}: IProps) => {
[onOpen, showSuccessNotification, updateDataStore]
);

const onDeleteConfig = useCallback(async () => {
onOpen({
title:
"Tracetest will remove the Tracing Backend configuration information and enter the 'No-Tracing Mode'. You can still run tests against the responses until you configure a new Tracing Backend.",
heading: 'Save Confirmation',
okText: 'Save',
onConfirm: async () => {
await deleteDataStore().unwrap();
},
});
}, [deleteDataStore, onOpen]);

const onIsFormValid = useCallback((isValid: boolean) => {
setIsFormValid(isValid);
}, []);
Expand Down Expand Up @@ -125,17 +110,8 @@ const DataStoreProvider = ({children}: IProps) => {
onSaveConfig,
onIsFormValid,
onTestConnection,
onDeleteConfig,
}),
[
isLoadingUpdate,
isFormValid,
isTestConnectionLoading,
onSaveConfig,
onIsFormValid,
onTestConnection,
onDeleteConfig,
]
[isLoadingUpdate, isFormValid, isTestConnectionLoading, onSaveConfig, onIsFormValid, onTestConnection]
);

return <Context.Provider value={value}>{isFetching ? null : children}</Context.Provider>;
Expand Down
8 changes: 0 additions & 8 deletions web/src/redux/apis/Tracetest/endpoints/DataStore.endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ export const dataStoreEndpoints = (builder: TTestApiEndpointBuilder) => ({
}),
invalidatesTags: [{type: TracetestApiTags.DATA_STORE, id: 'datastore'}],
}),
deleteDataStore: builder.mutation<undefined, void>({
query: () => ({
url: `/datastores/current`,
method: HTTP_METHOD.DELETE,
headers: {'content-type': 'application/json'},
}),
invalidatesTags: [{type: TracetestApiTags.DATA_STORE, id: 'datastore'}],
}),
testConnection: builder.mutation<TConnectionResult, TTestConnectionRequest>({
query: connectionTest => ({
url: `/config/connection`,
Expand Down
2 changes: 0 additions & 2 deletions web/src/redux/apis/Tracetest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import TracetestAPI from './Tracetest.api';
export {default} from './Tracetest.api';

const {
useDeleteDataStoreMutation,
useGetDataStoreQuery,
useTestConnectionMutation,
useUpdateDataStoreMutation,
Expand Down Expand Up @@ -69,7 +68,6 @@ const {
} = TracetestAPI.instance;

export {
useDeleteDataStoreMutation,
useGetDataStoreQuery,
useTestConnectionMutation,
useUpdateDataStoreMutation,
Expand Down
10 changes: 0 additions & 10 deletions web/src/types/Generated.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ export interface paths {
get: operations["getDataStore"];
/** Update a Data Store */
put: operations["updateDataStore"];
/** Delete a Data Store */
delete: operations["deleteDataStore"];
};
"/variableSets": {
/** List VariableSets available in Tracetest. */
Expand Down Expand Up @@ -969,14 +967,6 @@ export interface operations {
};
};
};
/** Delete a Data Store */
deleteDataStore: {
parameters: {};
responses: {
/** OK */
204: never;
};
};
/** List VariableSets available in Tracetest. */
listVariableSets: {
parameters: {};
Expand Down

0 comments on commit c5b4c1e

Please sign in to comment.