Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/static/components/controls/common-controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ControlButtons extends Component {
viewMode: PropTypes.string.isRequired,
diffMode: PropTypes.string.isRequired
}),
app: PropTypes.object.isRequired,
isStatisImageAccepterEnabled: PropTypes.bool,
actions: PropTypes.object.isRequired
};
Expand All @@ -44,15 +45,15 @@ class ControlButtons extends Component {
}

render() {
const {actions, view} = this.props;
const {actions, view, app} = this.props;

return (
<React.Fragment>
<ControlSelect
size='s'
label="Show tests"
value={view.viewMode}
handler={actions.changeViewMode}
value={app.suitesPage.viewMode}
handler={(data) => actions.changeViewMode({data, page: 'suitesPage'})}
options = {this._getShowTestsOptions()}
/>
<ControlSelect
Expand Down Expand Up @@ -90,6 +91,6 @@ class ControlButtons extends Component {
}

export default connect(
({view, staticImageAccepter: {enabled}}) => ({view, isStatisImageAccepterEnabled: enabled}),
({view, app, staticImageAccepter: {enabled}}) => ({view, app, isStatisImageAccepterEnabled: enabled}),
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
)(ControlButtons);
9 changes: 6 additions & 3 deletions lib/static/components/controls/common-filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ const CommonFilters = (props) => {
<BrowserList
available={props.browsers}
selected={props.filteredBrowsers}
onChange={props.actions.selectBrowsers}
onChange={(list) => props.actions.selectBrowsers({
data: list,
page: 'suitesPage'
})}
/>
<TestNameFilterInput/>
<StrictMatchFilterInput/>
Expand All @@ -69,8 +72,8 @@ CommonFilters.propTypes = {
};

export default connect(
({view, browsers, gui, staticImageAccepter}) => ({
filteredBrowsers: view.filteredBrowsers,
({app, browsers, gui, staticImageAccepter}) => ({
filteredBrowsers: app.suitesPage.filteredBrowsers,
browsers,
gui,
staticImageAccepter
Expand Down
7 changes: 5 additions & 2 deletions lib/static/components/controls/test-name-filter-input.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const TestNameFilterInput = ({actions, testNameFilter: testNameFilterProp}) => {
const [testNameFilter, setTestNameFilter] = useState(testNameFilterProp);

const _debouncedUpdate = useCallback(debounce(
(testName) => actions.updateTestNameFilter(testName),
(testName) => actions.updateNameFilter({
data: testName,
page: 'suitesPage'
}),
500,
{maxWait: 3000}
), []);
Expand Down Expand Up @@ -40,6 +43,6 @@ TestNameFilterInput.propTypes = {
};

export default connect(
(state) => ({testNameFilter: state.view.testNameFilter}),
(state) => ({testNameFilter: state.app.suitesPage.nameFilter}),
(dispatch) => ({actions: bindActionCreators(actions, dispatch)})
)(TestNameFilterInput);
6 changes: 3 additions & 3 deletions lib/static/components/suites.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ Suites.propTypes = {
export default connect(
(state) => ({
visibleRootSuiteIds: getVisibleRootSuiteIds(state),
viewMode: state.view.viewMode,
filteredBrowsers: state.view.filteredBrowsers,
testNameFilter: state.view.testNameFilter,
viewMode: state.app.suitesPage.viewMode,
filteredBrowsers: state.app.suitesPage.filteredBrowsers,
testNameFilter: state.app.suitesPage.nameFilter,
strictMatchFilter: state.view.strictMatchFilter,
isReportEmpty: isEmpty(state.tree.browsers.byId)
}),
Expand Down
4 changes: 2 additions & 2 deletions lib/static/modules/action-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export default {
SUITES_PAGE_REVEAL_TREE_NODE: 'SUITES_PAGE_REVEAL_TREE_NODE',
SUITES_PAGE_SET_STEPS_EXPANDED: 'SUITES_PAGE_SET_STEPS_EXPANDED',
SUITES_PAGE_SET_TREE_VIEW_MODE: 'SUITES_PAGE_SET_TREE_VIEW_MODE',
SUITES_PAGE_SET_SECTION_SIZES: 'SUITES_PAGE_SET_SECTION_SIZES',
SUITES_PAGE_SET_BACKUP_SECTION_SIZES: 'SUITES_PAGE_SET_BACKUP_SECTION_SIZES',
PAGE_SET_SECTION_SIZES: 'PAGE_SET_SECTION_SIZES',
PAGE_SET_BACKUP_SECTION_SIZES: 'PAGE_SET_BACKUP_SECTION_SIZES',
VISUAL_CHECKS_PAGE_SET_CURRENT_NAMED_IMAGE: 'VISUAL_CHECKS_PAGE_SET_CURRENT_NAMED_IMAGE',
UPDATE_LOADING_PROGRESS: 'UPDATE_LOADING_PROGRESS',
UPDATE_LOADING_VISIBILITY: 'UPDATE_LOADING_VISIBILITY',
Expand Down
48 changes: 0 additions & 48 deletions lib/static/modules/actions/filter-tests.ts

This file was deleted.

43 changes: 43 additions & 0 deletions lib/static/modules/actions/filters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import actionNames from '@/static/modules/action-names';
import type {Action} from '@/static/modules/actions/types';
import {setFilteredBrowsers} from '@/static/modules/query-params';
import {BrowserItem} from '@/types';
import {ViewMode} from '@/constants';
import {Page} from '@/static/new-ui/types/store';

interface FilterPayload<T>{
page: Page;
data: T;
}

export type UpdateNameFilterAction = Action<typeof actionNames.VIEW_UPDATE_FILTER_BY_NAME, FilterPayload<string>>;
export const updateNameFilter = (payload: UpdateNameFilterAction['payload']): UpdateNameFilterAction => {
return {type: actionNames.VIEW_UPDATE_FILTER_BY_NAME, payload};
};

export type SetMatchCaseFilterAction = Action<typeof actionNames.VIEW_SET_FILTER_MATCH_CASE, FilterPayload<boolean>>;
export const setMatchCaseFilter = (payload: SetMatchCaseFilterAction['payload']): SetMatchCaseFilterAction => {
return {type: actionNames.VIEW_SET_FILTER_MATCH_CASE, payload};
};

export type SetUseRegexFilterAction = Action<typeof actionNames.VIEW_SET_FILTER_USE_REGEX, FilterPayload<boolean>>;
export const setUseRegexFilter = (payload: SetUseRegexFilterAction['payload']): SetUseRegexFilterAction => {
return {type: actionNames.VIEW_SET_FILTER_USE_REGEX, payload};
};

export type SelectBrowsersAction = Action<typeof actionNames.BROWSERS_SELECTED, FilterPayload<BrowserItem[]>>;
export const selectBrowsers = (payload: SelectBrowsersAction['payload']): SelectBrowsersAction => {
setFilteredBrowsers(payload.data);

return {type: actionNames.BROWSERS_SELECTED, payload};
};

export type ChangeViewModeAction = Action<typeof actionNames.CHANGE_VIEW_MODE, FilterPayload<ViewMode>>;
export const changeViewMode = (payload: ChangeViewModeAction['payload']): ChangeViewModeAction => ({type: actionNames.CHANGE_VIEW_MODE, payload});

export type FiltersAction =
| UpdateNameFilterAction
| SetMatchCaseFilterAction
| SetUseRegexFilterAction
| SelectBrowsersAction
| ChangeViewModeAction;
2 changes: 1 addition & 1 deletion lib/static/modules/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './custom-gui';
export * from './filter-tests';
export * from './filters';
export * from './find-same-diffs';
export * from './group-tests';
export * from './gui-server-connection';
Expand Down
20 changes: 14 additions & 6 deletions lib/static/modules/actions/suites-page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import actionNames from '@/static/modules/action-names';
import {Action} from '@/static/modules/actions/types';
import {TreeViewMode} from '@/static/new-ui/types/store';
import {Page, TreeViewMode} from '@/static/new-ui/types/store';

export type SuitesPageSetCurrentTreeNodeAction = Action<typeof actionNames.SUITES_PAGE_SET_CURRENT_SUITE, Partial<{
treeNodeId: string;
Expand Down Expand Up @@ -64,17 +64,24 @@ type SetTreeViewModeAction = Action<typeof actionNames.SUITES_PAGE_SET_TREE_VIEW
export const setTreeViewMode = (payload: SetTreeViewModeAction['payload']): SetTreeViewModeAction =>
({type: actionNames.SUITES_PAGE_SET_TREE_VIEW_MODE, payload});

type SetSectionSizesAction = Action<typeof actionNames.SUITES_PAGE_SET_SECTION_SIZES, {
type SetSectionSizesAction = Action<typeof actionNames.PAGE_SET_SECTION_SIZES, {
sizes: number[];
page: Page;
}>;
export const setSectionSizes = (payload: SetSectionSizesAction['payload']): SetSectionSizesAction =>
({type: actionNames.SUITES_PAGE_SET_SECTION_SIZES, payload});
({type: actionNames.PAGE_SET_SECTION_SIZES, payload});

type SetBackupSectionSizesAction = Action<typeof actionNames.SUITES_PAGE_SET_BACKUP_SECTION_SIZES, {
type SetBackupSectionSizesAction = Action<typeof actionNames.PAGE_SET_BACKUP_SECTION_SIZES, {
sizes: number[];
page: Page;
}>;
export const setBackupSectionSizes = (payload: SetBackupSectionSizesAction['payload']): SetBackupSectionSizesAction =>
({type: actionNames.SUITES_PAGE_SET_BACKUP_SECTION_SIZES, payload});
({type: actionNames.PAGE_SET_BACKUP_SECTION_SIZES, payload});

export type SetStrictMatchFilterAction = Action<typeof actionNames.VIEW_SET_STRICT_MATCH_FILTER, boolean>;
export const setStrictMatchFilter = (strictMatchFilter: SetStrictMatchFilterAction['payload']): SetStrictMatchFilterAction => {
return {type: actionNames.VIEW_SET_STRICT_MATCH_FILTER, payload: strictMatchFilter};
};

export type SuitesPageAction =
| SetTreeNodeExpandedStateAction
Expand All @@ -87,4 +94,5 @@ export type SuitesPageAction =
| SuitesPageSetCurrentStepAction
| SuitesPageSetCurrentHighlightStepAction
| SetSectionSizesAction
| SetBackupSectionSizesAction;
| SetBackupSectionSizesAction
| SetStrictMatchFilterAction;
4 changes: 2 additions & 2 deletions lib/static/modules/actions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {SuiteTreeStateAction} from '@/static/modules/actions/suites-tree-state';
import {ModalsAction} from '@/static/modules/actions/modals';
import {LoadingAction} from '@/static/modules/actions/loading';
import {CustomGuiAction} from '@/static/modules/actions/custom-gui';
import {FilterTestsAction} from '@/static/modules/actions/filter-tests';
import {FiltersAction} from '@/static/modules/actions/filters';
import {SettingsAction} from '@/static/modules/actions/settings';
import {ProcessingAction} from '@/static/modules/actions/processing';
import {StaticAccepterAction} from '@/static/modules/actions/static-accepter';
Expand All @@ -36,7 +36,7 @@ export type AppThunk<ReturnType = Promise<void>> = ThunkAction<ReturnType, State

export type SomeAction =
| CustomGuiAction
| FilterTestsAction
| FiltersAction
| GroupTestsAction
| GuiServerConnectionAction
| LifecycleAction
Expand Down
33 changes: 22 additions & 11 deletions lib/static/modules/default-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {DiffModes} from '../../constants/diff-modes';
import {EXPAND_ERRORS} from '../../constants/expand-modes';
import {RESULT_KEYS} from '../../constants/group-tests';
import {ToolName} from '../../constants';
import {SortDirection, State, TreeViewMode} from '@/static/new-ui/types/store';
import {Page, SortDirection, State, TreeViewMode} from '@/static/new-ui/types/store';
import {MIN_SECTION_SIZE_PERCENT} from '../new-ui/features/suites/constants';

export default Object.assign({config: configDefaults}, {
Expand Down Expand Up @@ -77,15 +77,10 @@ export default Object.assign({config: configDefaults}, {
perBrowser: {}
},
view: {
viewMode: ViewMode.ALL,
diffMode: DiffModes.THREE_UP.id,
expand: EXPAND_ERRORS,
baseHost: '',
testNameFilter: '',
useRegexFilter: false,
useMatchCaseFilter: false,
strictMatchFilter: false,
filteredBrowsers: [],
keyToGroupTestsBy: ''
},
db: undefined,
Expand All @@ -104,15 +99,27 @@ export default Object.assign({config: configDefaults}, {
isNewUi: false,
isInitialized: false,
availableFeatures: [],
suitesPage: {
[Page.suitesPage]: {
currentBrowserId: null,
currentTreeNodeId: null,
currentGroupId: null,
currentStepId: null,
currentHighlightedStepId: null
currentHighlightedStepId: null,

viewMode: ViewMode.ALL,
nameFilter: '',
useRegexFilter: false,
useMatchCaseFilter: false,
filteredBrowsers: []
},
visualChecksPage: {
currentNamedImageId: null
[Page.visualChecksPage]: {
currentNamedImageId: null,

viewMode: ViewMode.ALL,
nameFilter: '',
useRegexFilter: false,
useMatchCaseFilter: false,
filteredBrowsers: []
},
loading: {
taskTitle: 'Loading Testplane UI',
Expand Down Expand Up @@ -146,7 +153,7 @@ export default Object.assign({config: configDefaults}, {
}
},
ui: {
suitesPage: {
[Page.suitesPage]: {
treeViewMode: TreeViewMode.Tree,
retryIndexByTreeNodeId: {},
expandedSectionsById: {},
Expand All @@ -156,6 +163,10 @@ export default Object.assign({config: configDefaults}, {
backupSectionSizes: [MIN_SECTION_SIZE_PERCENT, 100 - MIN_SECTION_SIZE_PERCENT],
isSnapshotsPlayerVisible: true
},
[Page.visualChecksPage]: {
sectionSizes: [MIN_SECTION_SIZE_PERCENT, 100 - MIN_SECTION_SIZE_PERCENT],
backupSectionSizes: [MIN_SECTION_SIZE_PERCENT, 100 - MIN_SECTION_SIZE_PERCENT]
},
staticImageAccepterToolbar: {
offset: {x: 0, y: 0}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/static/modules/middlewares/local-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ export default store => next => action => {
const result = next(action);

if (shouldUpdateLocalStorage(action.type)) {
const {view} = store.getState();
const {view, app} = store.getState();
// do not save text inputs:
// for example, a user opens a new report and sees no tests in it
// as the filter is applied from the previous opening of another report
localStorageWrapper.setItem('view', {
expand: view.expand,
viewMode: view.viewMode,
diffMode: view.diffMode,
strictMatchFilter: view.strictMatchFilter
});

localStorageWrapper.setItem('app.suitesPage.viewMode', app.suitesPage.viewMode);
localStorageWrapper.setItem('app.visualChecksPage.viewMode', app.visualChecksPage.viewMode);
}

return result;
Expand Down
Loading