-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new-ui): add ability to accept and undo screenshots
- Loading branch information
Showing
11 changed files
with
274 additions
and
74 deletions.
There are no files selected for viewing
2 changes: 0 additions & 2 deletions
2
lib/static/new-ui/components/AssertViewResult/index.module.css
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,5 +1,3 @@ | ||
.screenshot { | ||
margin: 8px 0; | ||
padding-left: calc(var(--indent) * 24px); | ||
padding-right: 1px; | ||
} |
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
9 changes: 9 additions & 0 deletions
9
lib/static/new-ui/components/AssertViewStatus/index.module.css
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,9 @@ | ||
.container { | ||
display: flex; | ||
gap: 4px; | ||
align-items: center; | ||
|
||
color: var(--g-color-private-cool-grey-700-solid); | ||
font-size: 15px; | ||
font-weight: 450; | ||
} |
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,29 @@ | ||
import React, {ReactNode} from 'react'; | ||
import {ImageEntity, ImageEntityError} from '@/static/new-ui/types/store'; | ||
import {TestStatus} from '@/constants'; | ||
import {Icon} from '@gravity-ui/uikit'; | ||
import {ArrowsRotateLeft, CircleCheck, CircleDashed, CircleExclamation} from '@gravity-ui/icons'; | ||
import {isNoRefImageError} from '@/common-utils'; | ||
import styles from './index.module.css'; | ||
|
||
interface AssertViewStatusProps { | ||
image: ImageEntity | null; | ||
} | ||
|
||
export function AssertViewStatus({image}: AssertViewStatusProps): ReactNode { | ||
let status = <><Icon data={CircleDashed} width={16}/><span>Failed to compare</span></>; | ||
|
||
if (image === null) { | ||
status = <><Icon data={CircleDashed} width={16}/><span>Image is absent</span></>; | ||
} else if (image.status === TestStatus.SUCCESS) { | ||
status = <><Icon data={CircleCheck} width={16}/><span>Images match</span></>; | ||
} else if (isNoRefImageError((image as ImageEntityError).error)) { | ||
status = <><Icon data={CircleExclamation} width={16}/><span>Reference not found</span></>; | ||
} else if (image.status === TestStatus.FAIL) { | ||
status = <><Icon data={CircleExclamation} width={16}/><span>Difference detected</span></>; | ||
} else if (image.status === TestStatus.UPDATED) { | ||
status = <><Icon data={ArrowsRotateLeft} width={16}/><span>Reference updated</span></>; | ||
} | ||
|
||
return <div className={styles.container}>{status}</div>; | ||
} |
21 changes: 21 additions & 0 deletions
21
lib/static/new-ui/components/CompactAttemptPicker/index.module.css
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,21 @@ | ||
.container { | ||
display: flex; | ||
gap: 4px; | ||
} | ||
|
||
.attempt-select { | ||
font-size: 15px; | ||
} | ||
|
||
.attempt-number { | ||
font-weight: 450; | ||
} | ||
|
||
.attempt-option { | ||
display: flex; | ||
gap: 8px; | ||
} | ||
|
||
.attempt-select-popup { | ||
max-height: 40vh; | ||
} |
68 changes: 68 additions & 0 deletions
68
lib/static/new-ui/components/CompactAttemptPicker/index.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,68 @@ | ||
import {ChevronLeft, ChevronRight} from '@gravity-ui/icons'; | ||
import {Button, Icon, Select} from '@gravity-ui/uikit'; | ||
import React, {ReactNode} from 'react'; | ||
import {useDispatch, useSelector} from 'react-redux'; | ||
|
||
import styles from './index.module.css'; | ||
import {State} from '@/static/new-ui/types/store'; | ||
import {getCurrentNamedImage} from '@/static/new-ui/features/visual-checks/selectors'; | ||
import {getIconByStatus} from '@/static/new-ui/utils'; | ||
import {changeTestRetry} from '@/static/modules/actions'; | ||
|
||
export function CompactAttemptPicker(): ReactNode { | ||
const dispatch = useDispatch(); | ||
const currentImage = useSelector(getCurrentNamedImage); | ||
const currentBrowserId = currentImage?.browserId; | ||
const currentBrowser = useSelector((state: State) => currentBrowserId && state.tree.browsers.byId[currentBrowserId]); | ||
const resultsById = useSelector((state: State) => state.tree.results.byId); | ||
|
||
const totalAttemptsCount = currentBrowser ? currentBrowser.resultIds.length : null; | ||
const currentAttemptIndex = useSelector((state: State) => currentBrowser ? state.tree.browsers.stateById[currentBrowser.id].retryIndex : null); | ||
|
||
const onUpdate = ([value]: string[]): void => { | ||
if (currentBrowserId) { | ||
dispatch(changeTestRetry({browserId: currentBrowserId, retryIndex: Number(value)})); | ||
} | ||
}; | ||
|
||
const onPreviousClick = (): void => { | ||
if (currentBrowserId && currentAttemptIndex !== null && currentAttemptIndex > 0) { | ||
dispatch(changeTestRetry({browserId: currentBrowserId, retryIndex: currentAttemptIndex - 1})); | ||
} | ||
}; | ||
|
||
const onNextClick = (): void => { | ||
if (currentBrowserId && currentAttemptIndex !== null && totalAttemptsCount !== null && currentAttemptIndex < totalAttemptsCount - 1) { | ||
dispatch(changeTestRetry({browserId: currentBrowserId, retryIndex: currentAttemptIndex + 1})); | ||
} | ||
}; | ||
|
||
if (!currentBrowser) { | ||
return null; | ||
} | ||
|
||
return <div className={styles.container}> | ||
<Button view={'outlined'} onClick={onPreviousClick}><Icon data={ChevronLeft}/></Button> | ||
<Select renderControl={({onClick, onKeyDown, ref}): React.JSX.Element => { | ||
return <Button className={styles.attemptSelect} onClick={onClick} extraProps={{onKeyDown}} ref={ref} view={'flat'}> | ||
Attempt <span className={styles.attemptNumber}> | ||
{currentAttemptIndex !== null ? currentAttemptIndex + 1 : '–'} | ||
</span> of <span className={styles.attemptNumber}>{totalAttemptsCount ?? '–'}</span> | ||
</Button>; | ||
}} | ||
renderOption={(option): React.JSX.Element => { | ||
const attemptStatus = resultsById[option.data.resultId].status; | ||
return <div className={styles.attemptOption}> | ||
{getIconByStatus(attemptStatus)} | ||
<span>{option.content}</span> | ||
</div>; | ||
}} popupClassName={styles.attemptSelectPopup} | ||
onUpdate={onUpdate} | ||
> | ||
{currentBrowser.resultIds.map((resultId, index) => { | ||
return <Select.Option key={index} value={index.toString()} content={`Attempt #${index + 1}`} data={{resultId}}></Select.Option>; | ||
})} | ||
</Select> | ||
<Button view={'outlined'} onClick={onNextClick}><Icon data={ChevronRight}/></Button> | ||
</div>; | ||
} |
17 changes: 9 additions & 8 deletions
17
lib/static/new-ui/features/suites/components/ScreenshotsTreeViewItem/index.module.css
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.