-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(frotend): Test Definition Name Input (#2830)
- Loading branch information
Showing
10 changed files
with
107 additions
and
22 deletions.
There are no files selected for viewing
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,25 @@ | ||
import {EditOutlined} from '@ant-design/icons'; | ||
import {Button} from 'antd'; | ||
import styled from 'styled-components'; | ||
|
||
export const Overlay = styled.div` | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
cursor: pointer; | ||
`; | ||
|
||
export const SaveButton = styled(Button)``; | ||
|
||
export const InputContainer = styled.div` | ||
display: grid; | ||
grid-template-columns: 45% 64px; | ||
align-items: center; | ||
max-width: 80%; | ||
`; | ||
|
||
export const EditIcon = styled(EditOutlined)` | ||
&& { | ||
color: ${({theme}) => theme.color.primary}; | ||
} | ||
`; |
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,38 @@ | ||
import {useState} from 'react'; | ||
import {Input} from 'antd'; | ||
import {noop} from 'lodash'; | ||
import * as S from './InputOverlay.styled'; | ||
|
||
interface IProps { | ||
onChange?(value: string): void; | ||
value?: string; | ||
} | ||
|
||
const InputOverlay = ({onChange = noop, value = ''}: IProps) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [inputValue, setInputValue] = useState(value); | ||
|
||
return isOpen ? ( | ||
<S.InputContainer> | ||
<Input onChange={event => setInputValue(event.target.value)} value={inputValue} /> | ||
<S.SaveButton | ||
ghost | ||
type="primary" | ||
onClick={() => { | ||
setIsOpen(false); | ||
onChange(inputValue); | ||
}} | ||
> | ||
Save | ||
</S.SaveButton> | ||
</S.InputContainer> | ||
) : ( | ||
<S.Overlay | ||
onClick={() => setIsOpen(true)} | ||
> | ||
{inputValue} <S.EditIcon /> | ||
</S.Overlay> | ||
); | ||
}; | ||
|
||
export default InputOverlay; |
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 './InputOverlay'; |
28 changes: 17 additions & 11 deletions
28
web/src/components/RunDetailAutomate/RunDetailAutomate.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 |
---|---|---|
@@ -1,23 +1,29 @@ | ||
import {snakeCase} from 'lodash'; | ||
import Test from 'models/Test.model'; | ||
import {useState} from 'react'; | ||
import TestRun from 'models/TestRun.model'; | ||
import * as S from './RunDetailAutomate.styled'; | ||
import TestDefinition from '../RunDetailAutomateDefinition'; | ||
import RunDetailAutomateDefinition from '../RunDetailAutomateDefinition'; | ||
import RunDetailAutomateMethods from '../RunDetailAutomateMethods/RunDetailAutomateMethods'; | ||
|
||
interface IProps { | ||
test: Test; | ||
run: TestRun; | ||
} | ||
|
||
const RunDetailAutomate = ({test, run}: IProps) => ( | ||
<S.Container> | ||
<S.SectionLeft> | ||
<TestDefinition test={test} /> | ||
</S.SectionLeft> | ||
<S.SectionRight> | ||
<RunDetailAutomateMethods test={test} run={run} /> | ||
</S.SectionRight> | ||
</S.Container> | ||
); | ||
const RunDetailAutomate = ({test, run}: IProps) => { | ||
const [fileName, setFileName] = useState<string>(`${snakeCase(test.name)}.yaml`); | ||
|
||
return ( | ||
<S.Container> | ||
<S.SectionLeft> | ||
<RunDetailAutomateDefinition onFileNameChange={setFileName} fileName={fileName} test={test} /> | ||
</S.SectionLeft> | ||
<S.SectionRight> | ||
<RunDetailAutomateMethods fileName={fileName} test={test} run={run} /> | ||
</S.SectionRight> | ||
</S.Container> | ||
); | ||
}; | ||
|
||
export default RunDetailAutomate; |
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
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