-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1458 [Transactions] Edit & Delete implementation for Transactions (#1459
) * 1458 adding transactions edit and delete features for the transaction run page * 1458 fixing drag & drop for transactions * 1458 removing console log 🥴
- Loading branch information
Showing
34 changed files
with
627 additions
and
153 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
web/src/components/EditTransaction/EditTransaction.styled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {Typography} from 'antd'; | ||
import styled from 'styled-components'; | ||
|
||
export const Title = styled(Typography.Title)` | ||
&& { | ||
font-size: ${({theme}) => theme.size.lg}; | ||
margin-bottom: 25px; | ||
font-weight: 700; | ||
} | ||
`; | ||
|
||
export const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
`; | ||
|
||
export const FormContainer = styled.div` | ||
padding: 24px; | ||
`; | ||
|
||
export const ButtonsContainer = styled.div` | ||
display: flex; | ||
justify-content: flex-end; | ||
gap: 8px; | ||
margin-top: 23px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {Button, Form} from 'antd'; | ||
import {useCallback, useState} from 'react'; | ||
import {TDraftTransaction, TTransaction} from 'types/Transaction.types'; | ||
import {useTransaction} from 'providers/Transaction/Transaction.provider'; | ||
import useValidateTransactionDraft from 'hooks/useValidateTransactionDraft'; | ||
|
||
import * as S from './EditTransaction.styled'; | ||
import EditTransactionForm from '../EditTransactionForm'; | ||
|
||
interface IProps { | ||
transaction: TTransaction; | ||
} | ||
|
||
const EditTransaction = ({transaction}: IProps) => { | ||
const [form] = Form.useForm<TDraftTransaction>(); | ||
const {onEdit, isEditLoading} = useTransaction(); | ||
const [isFormValid, setIsFormValid] = useState(true); | ||
|
||
const onChange = useValidateTransactionDraft({setIsValid: setIsFormValid}); | ||
|
||
const handleOnSubmit = useCallback( | ||
async (values: TDraftTransaction) => { | ||
onEdit(values); | ||
}, | ||
[onEdit] | ||
); | ||
|
||
return ( | ||
<S.Wrapper data-cy="edit-transaction-form"> | ||
<S.FormContainer> | ||
<S.Title>Edit Transaction</S.Title> | ||
<EditTransactionForm form={form} transaction={transaction} onSubmit={handleOnSubmit} onValidation={onChange} /> | ||
<S.ButtonsContainer> | ||
<Button data-cy="edit-transaction-reset" onClick={() => form.resetFields()}> | ||
Reset | ||
</Button> | ||
<Button | ||
data-cy="edit-transaction-submit" | ||
loading={isEditLoading} | ||
disabled={!isFormValid} | ||
type="primary" | ||
onClick={() => form.submit()} | ||
> | ||
Save & Run | ||
</Button> | ||
</S.ButtonsContainer> | ||
</S.FormContainer> | ||
</S.Wrapper> | ||
); | ||
}; | ||
|
||
export default EditTransaction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line no-restricted-exports | ||
export {default} from './EditTransaction'; |
11 changes: 11 additions & 0 deletions
11
web/src/components/EditTransactionForm/EditTransactionForm.styled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const FormContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 23px; | ||
.ant-form-item { | ||
margin: 0; | ||
} | ||
`; |
37 changes: 37 additions & 0 deletions
37
web/src/components/EditTransactionForm/EditTransactionForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {Form} from 'antd'; | ||
import {TDraftTransaction, TDraftTransactionForm, TTransaction} from 'types/Transaction.types'; | ||
import BasicDetailsForm from '../CreateTestPlugins/Default/steps/BasicDetails/BasicDetailsForm'; | ||
import TestsSelectionForm from '../TransactionPlugin/steps/TestsSelection/TestsSelectionForm'; | ||
import * as S from './EditTransactionForm.styled'; | ||
|
||
export const FORM_ID = 'edit-test'; | ||
|
||
interface IProps { | ||
form: TDraftTransactionForm; | ||
transaction: TTransaction; | ||
onSubmit(values: TDraftTransaction): Promise<void>; | ||
onValidation(allValues: any, values: TDraftTransaction): void; | ||
} | ||
|
||
const EditTransactionForm = ({form, onSubmit, transaction, onValidation}: IProps) => { | ||
return ( | ||
<Form<TDraftTransaction> | ||
autoComplete="off" | ||
data-cy="edit-test-modal" | ||
form={form} | ||
layout="vertical" | ||
name={FORM_ID} | ||
onFinish={onSubmit} | ||
onValuesChange={onValidation} | ||
initialValues={transaction} | ||
> | ||
<S.FormContainer> | ||
<BasicDetailsForm isEditing /> | ||
|
||
<TestsSelectionForm /> | ||
</S.FormContainer> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default EditTransactionForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line no-restricted-exports | ||
export {default} from './EditTransactionForm'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
web/src/components/TransactionRunLayout/TransactionRunLayout.styled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import {Typography} from 'antd'; | ||
import emptyStateIcon from 'assets/SpanAssertionsEmptyState.svg'; | ||
import styled from 'styled-components'; | ||
|
||
export const TestDetailsHeader = styled.div` | ||
display: flex; | ||
width: 100%; | ||
justify-content: space-between; | ||
margin: 32px 0 24px; | ||
`; | ||
|
||
export const Wrapper = styled.div<{detail?: boolean}>` | ||
display: flex; | ||
flex-grow: 1; | ||
flex-direction: column; | ||
background: ${({theme}) => theme.color.white}; | ||
`; | ||
|
||
export const EmptyStateIcon = styled.img.attrs({ | ||
src: emptyStateIcon, | ||
})``; | ||
|
||
export const EmptyStateContainer = styled.div` | ||
align-items: center; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 14px; | ||
justify-content: center; | ||
margin: 100px 0; | ||
`; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
height: 100%; | ||
width: 100%; | ||
`; | ||
|
||
export const Text = styled(Typography.Title).attrs({level: 3})<{opacity?: number}>` | ||
&& { | ||
font-size: 12px; | ||
color: ${({opacity}) => `rgba(3, 24, 73, ${opacity || 1})`}; | ||
margin: 0 !important; | ||
} | ||
`; | ||
|
||
export const TagContainer = styled.div` | ||
display: flex; | ||
white-space: nowrap; | ||
overflow: auto; | ||
`; | ||
|
||
export const Title = styled(Typography.Title).attrs({level: 3})` | ||
&& { | ||
margin: 0; | ||
} | ||
`; | ||
|
||
export const Stack = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
flex-direction: column; | ||
`; | ||
|
||
export const Info = styled.div` | ||
flex: 1; | ||
`; | ||
|
||
export const Section = styled.div` | ||
flex: 1; | ||
`; | ||
|
||
export const SectionLeft = styled.div` | ||
background-color: ${({theme}) => theme.color.white}; | ||
overflow-y: auto; | ||
z-index: 1; | ||
flex-basis: 50%; | ||
`; | ||
|
||
export const SectionRight = styled.div` | ||
background-color: ${({theme}) => theme.color.white}; | ||
border-left: 1px solid rgba(3, 24, 73, 0.1); | ||
overflow-y: auto; | ||
z-index: 2; | ||
padding: 24px; | ||
flex-basis: 50%; | ||
`; |
33 changes: 33 additions & 0 deletions
33
web/src/components/TransactionRunLayout/TransactionRunLayout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {useNavigate} from 'react-router-dom'; | ||
import TransactionHeader from 'components/TransactionHeader'; | ||
import {TTransaction, TTransactionRun} from 'types/Transaction.types'; | ||
import * as S from './TransactionRunLayout.styled'; | ||
import EditTransaction from '../EditTransaction'; | ||
import TransactionRunResult from '../TransactionRunResult/TransactionRunResult'; | ||
|
||
interface IProps { | ||
transaction: TTransaction; | ||
transactionRun: TTransactionRun; | ||
} | ||
|
||
const TransactionRunDetailLayout = ({transaction, transaction: {id: transactionId}, transactionRun}: IProps) => { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<> | ||
<TransactionHeader onBack={() => navigate(`/transaction/${transactionId}`)} /> | ||
<S.Wrapper> | ||
<S.Container> | ||
<S.SectionLeft> | ||
<EditTransaction transaction={transaction} /> | ||
</S.SectionLeft> | ||
<S.SectionRight> | ||
<TransactionRunResult transactionRun={transactionRun} /> | ||
</S.SectionRight> | ||
</S.Container> | ||
</S.Wrapper> | ||
</> | ||
); | ||
}; | ||
|
||
export default TransactionRunDetailLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line no-restricted-exports | ||
export {default} from './TransactionRunLayout'; |
Oops, something went wrong.