-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(frontend): switching current span during spec creation (#2205)
* feature(frontend): switching current span during spec creation * enabling span switching * showing the unsaved changes prompt when the forms are valid * fixing unit tests * resetting output form
- Loading branch information
Showing
14 changed files
with
310 additions
and
92 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
web/src/components/CurrentSpanSelector/CurrentSpanSelector.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,16 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
margin-top: 2px; | ||
`; | ||
|
||
export const FloatingText = styled.div` | ||
background-color: ${({theme}) => theme.color.interactive}; | ||
color: ${({theme}) => theme.color.white}; | ||
border-radius: 12px; | ||
padding: 2px 6px; | ||
font-size: ${({theme}) => theme.size.xs}; | ||
cursor: pointer; | ||
`; |
59 changes: 59 additions & 0 deletions
59
web/src/components/CurrentSpanSelector/CurrentSpanSelector.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,59 @@ | ||
import {useCallback} from 'react'; | ||
import {LoadingOutlined} from '@ant-design/icons'; | ||
import SpanService from 'services/Span.service'; | ||
import {useTest} from 'providers/Test/Test.provider'; | ||
import {useTestRun} from 'providers/TestRun/TestRun.provider'; | ||
import {useAppSelector} from 'redux/hooks'; | ||
import SpanSelectors from 'selectors/Span.selectors'; | ||
import {useSpan} from 'providers/Span/Span.provider'; | ||
import TestOutput from 'models/TestOutput.model'; | ||
import {useTestOutput} from 'providers/TestOutput/TestOutput.provider'; | ||
import {useTestSpecForm} from '../TestSpecForm/TestSpecForm.provider'; | ||
import * as S from './CurrentSpanSelector.styled'; | ||
|
||
interface IProps { | ||
spanId: string; | ||
} | ||
|
||
const CurrentSpanSelector = ({spanId}: IProps) => { | ||
const {open, isOpen: isTestSpecFormOpen} = useTestSpecForm(); | ||
const {onOpen} = useTestOutput(); | ||
const { | ||
run: {id: runId}, | ||
} = useTestRun(); | ||
const { | ||
test: {id: testId}, | ||
} = useTest(); | ||
const {isTriggerSelectorLoading} = useSpan(); | ||
const span = useAppSelector(state => SpanSelectors.selectSpanById(state, spanId, testId, runId)); | ||
|
||
const handleOnClick = useCallback(() => { | ||
const selector = SpanService.getSelectorInformation(span!); | ||
|
||
if (isTestSpecFormOpen) | ||
open({ | ||
isEditing: false, | ||
selector, | ||
defaultValues: { | ||
selector, | ||
}, | ||
}); | ||
else onOpen(TestOutput({selector: {query: selector}})); | ||
}, [isTestSpecFormOpen, onOpen, open, span]); | ||
|
||
return ( | ||
<S.Container className="matched"> | ||
<S.FloatingText onClick={() => !isTriggerSelectorLoading && handleOnClick()}> | ||
{isTriggerSelectorLoading ? ( | ||
<> | ||
Updating selected span <LoadingOutlined /> | ||
</> | ||
) : ( | ||
<>Select as current span</> | ||
)} | ||
</S.FloatingText> | ||
</S.Container> | ||
); | ||
}; | ||
|
||
export default CurrentSpanSelector; |
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 './CurrentSpanSelector'; |
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
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
Oops, something went wrong.