-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(frotend): Test Definition Name Input #2830
Merged
xoscar
merged 1 commit into
main
from
2768-automate-tab-support-test-definition-name-update
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went back and forth on having this to be a local state or something from a provider, but to keep it simple I just add it as a state. If we need to carry over multiple things for the techniques we can have an automate provider instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. Keep it simple.