Skip to content

Commit

Permalink
fix(frontend): remove settings confirmation modal (#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeepc committed Mar 24, 2023
1 parent 1bb98af commit ca77eb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
3 changes: 1 addition & 2 deletions web/cypress/support/commands.ts
Expand Up @@ -82,7 +82,7 @@ Cypress.Commands.add('createTestWithAuth', (authMethod: string, keys: string[]):
cy.selectTestFromDemoList();
cy.get('[data-cy=auth-type-select]').click();
cy.get(`[data-cy=auth-type-select-option-${authMethod}]`).click();
keys.forEach(key => cy.get(`[data-cy=${authMethod}-${key}]`).type(key));
keys.forEach(key => cy.get(`[data-cy=${authMethod}-${key}] [contenteditable]`).first().type('key'));
return cy.wrap(PokeshopDemo[0].name);
});

Expand Down Expand Up @@ -265,7 +265,6 @@ Cypress.Commands.add('enableDemo', () => {
cy.get('#demo_pokeshop_enabled').click();
cy.get('#demo_pokeshop_pokeshop_httpEndpoint').type('http://demo-pokemon-api.demo.svc.cluster.local');
cy.get('[data-cy=demo-form-save-button]').click();
cy.get('[data-cy=confirmation-modal] .ant-btn-primary').click();
}

cy.visit(`/`);
Expand Down
19 changes: 5 additions & 14 deletions web/src/providers/Settings/Settings.provider.tsx
Expand Up @@ -3,7 +3,6 @@ import {createContext, useCallback, useContext, useMemo} from 'react';

import {useCreateSettingMutation, useUpdateSettingMutation} from 'redux/apis/TraceTest.api';
import {TDraftResource} from 'types/Settings.types';
import {useConfirmationModal} from '../ConfirmationModal/ConfirmationModal.provider';
import {useNotification} from '../Notification/Notification.provider';

interface IContext {
Expand All @@ -23,7 +22,6 @@ const SettingsProvider = ({children}: IProps) => {
const {showNotification} = useNotification();
const [createSetting, {isLoading: isLoadingCreate}] = useCreateSettingMutation();
const [updateSetting, {isLoading: isLoadingUpdate}] = useUpdateSettingMutation();
const {onOpen: onOpenConfirmation} = useConfirmationModal();

const onSaveResource = useCallback(
async (resource: TDraftResource) => {
Expand All @@ -37,19 +35,12 @@ const SettingsProvider = ({children}: IProps) => {
);

const onSubmit = useCallback(
(resources: TDraftResource[]) => {
onOpenConfirmation({
title: <p>Are you sure you want to save this Setting?</p>,
heading: 'Save Confirmation',
okText: 'Save',
onConfirm: async () => {
await Promise.all(resources.map(resource => onSaveResource(resource)));

showNotification({type: 'success', title: 'Settings saved', description: 'Your settings were saved'});
},
});
async (resources: TDraftResource[]) => {
await Promise.all(resources.map(resource => onSaveResource(resource)));

showNotification({type: 'success', title: 'Settings saved', description: 'Your settings were saved'});
},
[onOpenConfirmation, onSaveResource, showNotification]
[onSaveResource, showNotification]
);

const value = useMemo<IContext>(
Expand Down

0 comments on commit ca77eb0

Please sign in to comment.