Skip to content

Commit

Permalink
chore(new-ui): implement new suite title and basics of visual checks …
Browse files Browse the repository at this point in the history
…mode (#603)

* chore(new-ui): implement new suite title and basics of visual checks mode

* chore(new-ui): fix assertView indents

* chore(new-ui): fix missing suites when suite both has nested browsers and suites

* chore(new-ui): fix image attempt picking logic and image status color

* chore(new-ui): update gravity ui
  • Loading branch information
shadowusr authored Oct 8, 2024
1 parent 486d44e commit 2aba0dd
Show file tree
Hide file tree
Showing 45 changed files with 610 additions and 239 deletions.
3 changes: 2 additions & 1 deletion lib/static/modules/action-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ export default {
TOGGLE_BROWSER_CHECKBOX: 'TOGGLE_BROWSER_CHECKBOX',
SUITES_PAGE_SET_CURRENT_SUITE: 'SUITES_PAGE_SET_CURRENT_SUITE',
SUITES_PAGE_SET_SECTION_EXPANDED: 'SUITES_PAGE_SET_SECTION_EXPANDED',
SUITES_PAGE_SET_STEPS_EXPANDED: 'SUITES_PAGE_SET_STEPS_EXPANDED'
SUITES_PAGE_SET_STEPS_EXPANDED: 'SUITES_PAGE_SET_STEPS_EXPANDED',
VISUAL_CHECKS_PAGE_SET_CURRENT_NAMED_IMAGE: 'VISUAL_CHECKS_PAGE_SET_CURRENT_NAMED_IMAGE'
} as const;
1 change: 1 addition & 0 deletions lib/static/modules/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import performanceMarks from '../../../constants/performance-marks';
export * from './static-accepter';
export * from './suites-page';
export * from './suites';
export * from './visual-checks-page';

export const createNotification = (id, status, message, props = {}) => {
const notificationProps = {
Expand Down
13 changes: 13 additions & 0 deletions lib/static/modules/actions/visual-checks-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import actionNames from '@/static/modules/action-names';
import {Action} from '@/static/modules/actions/types';

export type VisualChecksPageSetCurrentNamedImageAction = Action<typeof actionNames.VISUAL_CHECKS_PAGE_SET_CURRENT_NAMED_IMAGE, {
namedImageId: string;
}>;

export const visualChecksPageSetCurrentNamedImage = (namedImageId: string): VisualChecksPageSetCurrentNamedImageAction => {
return {type: actionNames.VISUAL_CHECKS_PAGE_SET_CURRENT_NAMED_IMAGE, payload: {namedImageId}};
};

export type VisualChecksPageAction =
| VisualChecksPageSetCurrentNamedImageAction;
7 changes: 6 additions & 1 deletion lib/static/modules/default-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ export default Object.assign({config: configDefaults}, {
},
app: {
isInitialized: false,
currentSuiteId: null
suitesPage: {
currentBrowserId: null
},
visualChecksPage: {
currentNamedImageId: null
}
},
ui: {
suitesPage: {
Expand Down
2 changes: 2 additions & 0 deletions lib/static/modules/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import stopping from './stopping';
import progressBar from './bottom-progress-bar';
import staticImageAccepter from './static-image-accepter';
import suitesPage from './suites-page';
import visualChecksPage from './visual-checks-page';
import isInitialized from './is-initialized';

// The order of specifying reducers is important.
Expand Down Expand Up @@ -60,5 +61,6 @@ export default reduceReducers(
plugins,
progressBar,
suitesPage,
visualChecksPage,
isInitialized
);
2 changes: 1 addition & 1 deletion lib/static/modules/reducers/suites-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {applyStateUpdate} from '@/static/modules/utils/state';
export default (state: State, action: SuitesPageAction): State => {
switch (action.type) {
case actionNames.SUITES_PAGE_SET_CURRENT_SUITE:
return applyStateUpdate(state, {app: {currentSuiteId: action.payload.suiteId}}) as State;
return applyStateUpdate(state, {app: {suitesPage: {currentBrowserId: action.payload.suiteId}}}) as State;
case actionNames.SUITES_PAGE_SET_SECTION_EXPANDED: {
return applyStateUpdate(state, {
ui: {
Expand Down
13 changes: 13 additions & 0 deletions lib/static/modules/reducers/visual-checks-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {State} from '@/static/new-ui/types/store';
import actionNames from '@/static/modules/action-names';
import {applyStateUpdate} from '@/static/modules/utils/state';
import {VisualChecksPageAction} from '@/static/modules/actions';

export default (state: State, action: VisualChecksPageAction): State => {
switch (action.type) {
case actionNames.VISUAL_CHECKS_PAGE_SET_CURRENT_NAMED_IMAGE:
return applyStateUpdate(state, {app: {visualChecksPage: {currentNamedImageId: action.payload.namedImageId}}}) as State;
default:
return state;
}
};
2 changes: 1 addition & 1 deletion lib/static/new-ui/components/AttemptPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function AttemptPickerInternal(props: AttemptPickerInternalProps): ReactNode {
export const AttemptPicker = connect((state: State) => {
let resultIds: string[] = [];
let currentResultId = '';
const browserId = state.app.currentSuiteId;
const browserId = state.app.suitesPage.currentBrowserId;

if (browserId && state.tree.browsers.byId[browserId]) {
resultIds = state.tree.browsers.byId[browserId].resultIds;
Expand Down
11 changes: 11 additions & 0 deletions lib/static/new-ui/components/Card/TextHintCard.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.card {
background-color: #fff;
display: flex;
align-items: center;
justify-content: center;
}

.hint {
color: var(--g-color-private-black-400);
font-weight: 500;
}
15 changes: 15 additions & 0 deletions lib/static/new-ui/components/Card/TextHintCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import classNames from 'classnames';
import React, {ReactNode} from 'react';

import {Card, CardProps} from '.';
import styles from './TextHintCard.module.css';

interface TextHintCardProps extends CardProps {
hint: string;
}

export function TextHintCard(props: TextHintCardProps): ReactNode {
return <Card className={classNames(styles.card, props.className)}>
<span className={styles.hint}>{props.hint}</span>
</Card>;
}
8 changes: 8 additions & 0 deletions lib/static/new-ui/components/Card/UiCard.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.card {
background-color: #fff;
display: flex;
flex-direction: column;
padding: 0 20px 20px 20px;
overflow: scroll;
position: relative;
}
9 changes: 9 additions & 0 deletions lib/static/new-ui/components/Card/UiCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import classNames from 'classnames';
import React, {ReactNode} from 'react';

import {Card, CardProps} from '.';
import styles from './UiCard.module.css';

export function UiCard(props: CardProps): ReactNode {
return <Card className={classNames(styles.card, props.className)}>{props.children}</Card>;
}
6 changes: 2 additions & 4 deletions lib/static/new-ui/components/Card/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
position: relative;
}

.card {
box-shadow: rgb(255, 255, 255) 0 0 0 0, rgba(9, 9, 11, 0.05) 0 0 0 1px, rgba(0, 0, 0, 0.05) 0 1px 2px 0;
}

.wrapper {
overflow: hidden;
box-shadow: rgb(255, 255, 255) 0 0 0 0, rgba(9, 9, 11, 0.05) 0 0 0 1px, rgba(0, 0, 0, 0.05) 0 1px 2px 0;
border-radius: 10px;
}
4 changes: 2 additions & 2 deletions lib/static/new-ui/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import classNames from 'classnames';

import styles from './index.module.css';

interface CardProps {
export interface CardProps {
className?: string;
children?: React.ReactNode;
}

export function Card(props: CardProps): React.ReactNode {
return <div className={styles.wrapper}>
<div className={classNames(styles.commonCard, styles.card, props.className)}>
<div className={classNames(styles.commonCard, props.className)}>
{props.children}
</div>
</div>;
Expand Down
73 changes: 73 additions & 0 deletions lib/static/new-ui/components/SuiteTitle/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.container {
display: flex;
align-items: baseline;
justify-content: space-between;
}

@container (max-width: 500px) {
.container {
flex-wrap: wrap-reverse;
}
}

.breadcrumbs {
font-weight: 500;
color: var(--g-color-private-black-400);
font-size: 15px;
display: flex;
flex-wrap: wrap;
}

.separator {
margin: 0 4px;
display: inline-block;
width: 16px;
position: relative;
}

.invisible-space {
position: absolute;
z-index: -1;
left: 0;
}

.content {
margin-top: 8px;
display: flex;
flex-direction: column;
row-gap: 8px;
}

.title-container {
display: flex;
align-items: center;
flex-wrap: wrap;
column-gap: 8px;
row-gap: 4px;
}

.labels-container {
display: flex;
flex-wrap: wrap;
gap: 8px;
}

.label :global(.g-label__content) {
display: flex;
align-items: center;
flex-wrap: nowrap;
gap: 4px;
font-size: 15px;
}

.pagination-container {
display: flex;
align-items: baseline;
gap: 4px;
}

.counter {
font-weight: 500;
color: var(--g-color-private-black-400);
font-size: 15px;
}
59 changes: 59 additions & 0 deletions lib/static/new-ui/components/SuiteTitle/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import classNames from 'classnames';
import React, {ReactNode} from 'react';
import {Button, Icon, Label} from '@gravity-ui/uikit';
import {Camera, ChevronRight, PlanetEarth, ChevronUp, ChevronDown} from '@gravity-ui/icons';

import styles from './index.module.css';

interface SuiteTitleProps {
className?: string;
}

interface SuiteTitlePropsInternal extends SuiteTitleProps {
suitePath: string[];
browserName: string;
stateName?: string;
index: number;
totalItems: number;
onPrevious: () => void;
onNext: () => void;
}

export function SuiteTitle(props: SuiteTitlePropsInternal): ReactNode {
const suiteName = props.suitePath[props.suitePath.length - 1];
const suitePath = props.suitePath.slice(0, -1);

return <div className={classNames(styles.container, props.className)}>
<div className={styles.content}>
<div className={classNames(styles.breadcrumbs)}>
{suitePath.map((item, index) => (
<div key={index} className={styles.breadcrumbsItem}>
{item}
{index !== suitePath.length - 1 &&
<div className={styles.separator}>
<ChevronRight height={12}/>
<span className={styles.invisibleSpace}>&nbsp;</span>
</div>}
</div>
))}
</div>
<div className={styles.titleContainer}>
<h2 className={classNames('text-display-1')}>
{suiteName ?? 'Unknown Suite'}
</h2>
<div className={styles.labelsContainer}>
<Label theme={'normal'} size={'xs'} className={styles.label}><PlanetEarth/>{props.browserName}
</Label>
{props.stateName && <Label theme='utility' size={'xs'} className={classNames(styles.label)}><Camera/>{props.stateName}</Label>}
</div>
</div>
</div>
<div className={styles.paginationContainer}>
<span className={styles.counter}>{props.index === -1 ? '–' : props.index + 1}/{props.totalItems}</span>
<Button view={'flat'} disabled={props.index <= 0} onClick={props.onPrevious}><Icon
data={ChevronUp}/></Button>
<Button view={'flat'} disabled={props.index < 0 || props.index === props.totalItems - 1} onClick={props.onNext}><Icon
data={ChevronDown}/></Button>
</div>
</div>;
}
5 changes: 4 additions & 1 deletion lib/static/new-ui/components/TreeViewItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ interface TreeListItemProps<T> {
}

export function TreeViewItem<T>(props: TreeListItemProps<T>): ReactNode {
const indent = props.list.structure.itemsState[props.id].indentation;
const hasChildren = (props.list.structure.itemsById[props.id] as {hasChildren?: boolean}).hasChildren;

return <Box
spacing={{pt: 1}}
>
Expand All @@ -34,7 +37,7 @@ export function TreeViewItem<T>(props: TreeListItemProps<T>): ReactNode {
[styles['tree-view-item--error']]: props.isFailed
}])}
activeOnHover={true}
style={{'--indent': props.list.structure.itemsState[props.id].indentation} as React.CSSProperties}
style={{'--indent': indent + Number(!hasChildren)} as React.CSSProperties}
{...getItemRenderState({
id: props.id,
list: props.list,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.icon {
opacity: .6;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {isString} from 'lodash';
import React, {ReactNode} from 'react';

import styles from './BrowserIcon.module.css';

const valueToIcon = {
google: 'chrome',
chrome: 'chrome',
Expand All @@ -19,7 +21,7 @@ const valueToIcon = {
} as const;

export function BrowserIcon({name: browser}: {name: string}): ReactNode {
const getIcon = (iconName: string): ReactNode => <i className={`fa fa-${iconName}`} aria-hidden="true" />;
const getIcon = (iconName: string): ReactNode => <i className={`fa fa-${iconName} ${styles.icon}`} aria-hidden="true" />;

if (!isString(browser)) {
return getIcon('browser');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Globe} from '@gravity-ui/icons';
import {Button, Flex, Select, SelectRenderControlProps, SelectRenderOption} from '@gravity-ui/uikit';
import {PlanetEarth} from '@gravity-ui/icons';
import {Button, Flex, Icon, Select, SelectRenderControlProps, SelectRenderOption} from '@gravity-ui/uikit';
import React, {useState, useEffect, ReactNode} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
Expand Down Expand Up @@ -109,8 +109,8 @@ function BrowsersSelectInternal({browsers, filteredBrowsers, actions}: BrowsersS
};

const renderControl = ({onClick, onKeyDown, ref}: SelectRenderControlProps): React.JSX.Element => {
return <Button ref={ref} onClick={onClick} extraProps={{onKeyDown}} view={'outlined'} style={{width: 28}}>
<Globe/>
return <Button ref={ref} onClick={onClick} extraProps={{onKeyDown}} view={'outlined'}>
<Icon data={PlanetEarth}/>
</Button>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function CollapsibleSectionInternal(props: CollapsibleSectionInternalProp
}

export const CollapsibleSection = connect((state: State, props: CollapsibleSectionProps) => {
const browserId = state.app.currentSuiteId;
const browserId = state.app.suitesPage.currentBrowserId;
let sectionId = '';

if (browserId && state.tree.browsers.byId[browserId]) {
Expand Down
Loading

0 comments on commit 2aba0dd

Please sign in to comment.