Skip to content

Commit 02f1462

Browse files
PatrickvBeekzsofiaVagi
authored andcommitted
Add feature toggle to the settings tab, make Search Panel responsive
1 parent 0dff158 commit 02f1462

File tree

9 files changed

+138
-109
lines changed

9 files changed

+138
-109
lines changed

packages/redux-devtools-app/src/actions/index.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1+
import { LiftedAction, LiftedState } from '@redux-devtools/core';
12
import { SchemeName, ThemeName } from '@redux-devtools/ui';
2-
import { AuthStates, States } from 'socketcluster-client/lib/clientsocket';
3+
import { Action } from 'redux';
34
import { REHYDRATE } from 'redux-persist';
5+
import { AuthStates, States } from 'socketcluster-client/lib/clientsocket';
46
import {
57
CHANGE_SECTION,
8+
CHANGE_STATE_TREE_SETTINGS,
69
CHANGE_THEME,
7-
SELECT_INSTANCE,
8-
SELECT_MONITOR,
9-
UPDATE_MONITOR_STATE,
10+
CLEAR_NOTIFICATION,
11+
ERROR,
12+
EXPORT,
13+
GET_REPORT_ERROR,
14+
GET_REPORT_REQUEST,
15+
GET_REPORT_SUCCESS,
1016
LIFTED_ACTION,
1117
MONITOR_ACTION,
12-
EXPORT,
13-
TOGGLE_SYNC,
14-
TOGGLE_SLIDER,
18+
REMOVE_INSTANCE,
19+
SELECT_INSTANCE,
20+
SELECT_MONITOR,
21+
SET_PERSIST,
22+
SET_STATE,
23+
SHOW_NOTIFICATION,
1524
TOGGLE_DISPATCHER,
1625
TOGGLE_PERSIST,
17-
GET_REPORT_REQUEST,
18-
SHOW_NOTIFICATION,
19-
CLEAR_NOTIFICATION,
20-
UPDATE_STATE,
26+
TOGGLE_SLIDER,
27+
TOGGLE_SYNC,
28+
UPDATE_MONITOR_STATE,
2129
UPDATE_REPORTS,
22-
REMOVE_INSTANCE,
23-
SET_STATE,
24-
GET_REPORT_ERROR,
25-
GET_REPORT_SUCCESS,
26-
ERROR,
27-
SET_PERSIST,
28-
CHANGE_STATE_TREE_SETTINGS,
30+
UPDATE_STATE,
2931
} from '../constants/actionTypes';
3032
import {
3133
AUTH_ERROR,
@@ -43,12 +45,9 @@ import {
4345
SUBSCRIBE_SUCCESS,
4446
UNSUBSCRIBE,
4547
} from '../constants/socketActionTypes';
46-
import { Action } from 'redux';
4748
import { Features, State } from '../reducers/instances';
4849
import { MonitorStateMonitorState } from '../reducers/monitor';
49-
import { LiftedAction } from '@redux-devtools/core';
5050
import { Data } from '../reducers/reports';
51-
import { LiftedState } from '@redux-devtools/core';
5251

5352
let monitorReducer: (
5453
monitorProps: unknown,
@@ -86,6 +85,7 @@ export function changeTheme(data: ChangeThemeData): ChangeThemeAction {
8685
interface ChangeStateTreeSettingsFormData {
8786
readonly sortAlphabetically: boolean;
8887
readonly disableCollection: boolean;
88+
readonly enableSearchPanel: boolean;
8989
}
9090

9191
interface ChangeStateTreeSettingsData {
@@ -96,6 +96,7 @@ export interface ChangeStateTreeSettingsAction {
9696
readonly type: typeof CHANGE_STATE_TREE_SETTINGS;
9797
readonly sortAlphabetically: boolean;
9898
readonly disableCollection: boolean;
99+
readonly enableSearchPanel: boolean;
99100
}
100101

101102
export function changeStateTreeSettings(

packages/redux-devtools-app/src/components/Settings/StateTree.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { Component } from 'react';
2-
import { connect, ResolveThunks } from 'react-redux';
31
import { Container, Form } from '@redux-devtools/ui';
2+
import React, { Component } from 'react';
3+
import { ResolveThunks, connect } from 'react-redux';
44
import { changeStateTreeSettings } from '../../actions';
55
import { StoreState } from '../../reducers';
66

@@ -14,6 +14,7 @@ export class StateTree extends Component<Props> {
1414
const formData = {
1515
sortAlphabetically: stateTree.sortAlphabetically,
1616
disableCollection: stateTree.disableCollection,
17+
enableSearchPanel: stateTree.enableSearchPanel,
1718
};
1819

1920
return (
@@ -30,6 +31,10 @@ export class StateTree extends Component<Props> {
3031
title: 'Disable collapsing of nodes',
3132
type: 'boolean',
3233
},
34+
enableSearchPanel: {
35+
title: 'Show search panel in State tab',
36+
type: 'boolean',
37+
},
3338
},
3439
}}
3540
formData={formData}

packages/redux-devtools-app/src/containers/DevTools.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React, { Component } from 'react';
2-
import { withTheme } from 'styled-components';
31
import { LiftedAction, LiftedState } from '@redux-devtools/core';
2+
import { ThemeFromProvider } from '@redux-devtools/ui';
3+
import React, { Component } from 'react';
44
import { Action } from 'redux';
5-
import getMonitor from '../utils/getMonitor';
5+
import { withTheme } from 'styled-components';
66
import { InitMonitorAction } from '../actions';
77
import { Features, State } from '../reducers/instances';
88
import { MonitorStateMonitorState } from '../reducers/monitor';
9-
import { ThemeFromProvider } from '@redux-devtools/ui';
109
import { StateTreeSettings } from '../reducers/stateTreeSettings';
10+
import getMonitor from '../utils/getMonitor';
1111

1212
interface Props {
1313
monitor: string;
@@ -118,6 +118,7 @@ class DevTools extends Component<Props> {
118118
disableStateTreeCollection={
119119
this.props.stateTreeSettings.disableCollection
120120
}
121+
enableSearchPanel={this.props.stateTreeSettings.enableSearchPanel}
121122
/>
122123
</div>
123124
);

packages/redux-devtools-app/src/reducers/stateTreeSettings.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
1-
import { CHANGE_STATE_TREE_SETTINGS } from '../constants/actionTypes';
21
import { StoreAction } from '../actions';
2+
import { CHANGE_STATE_TREE_SETTINGS } from '../constants/actionTypes';
33

44
export interface StateTreeSettings {
55
readonly sortAlphabetically: boolean;
66
readonly disableCollection: boolean;
7+
readonly enableSearchPanel: boolean;
78
}
89

910
export function stateTreeSettings(
1011
state: StateTreeSettings = {
1112
sortAlphabetically: false,
1213
disableCollection: false,
14+
enableSearchPanel: false,
1315
},
1416
action: StoreAction
1517
) {
1618
if (action.type === CHANGE_STATE_TREE_SETTINGS) {
1719
return {
1820
sortAlphabetically: action.sortAlphabetically,
1921
disableCollection: action.disableCollection,
22+
enableSearchPanel: action.enableSearchPanel,
2023
};
2124
}
2225
return state;

packages/redux-devtools-inspector-monitor/src/ActionPreview.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
import { PerformAction } from '@redux-devtools/core';
2+
import { Delta } from 'jsondiffpatch';
13
import React, { Component } from 'react';
2-
import { Base16Theme } from 'redux-devtools-themes';
3-
import { Action } from 'redux';
44
import type { StylingFunction } from 'react-base16-styling';
55
import type { LabelRenderer } from 'react-json-tree';
6-
import { PerformAction } from '@redux-devtools/core';
7-
import { Delta } from 'jsondiffpatch';
8-
import { DEFAULT_STATE, DevtoolsInspectorState } from './redux';
6+
import { Action } from 'redux';
7+
import { Base16Theme } from 'redux-devtools-themes';
98
import ActionPreviewHeader from './ActionPreviewHeader';
9+
import { DEFAULT_STATE, DevtoolsInspectorState } from './redux';
10+
import ActionTab from './tabs/ActionTab';
1011
import DiffTab from './tabs/DiffTab';
1112
import StateTab from './tabs/StateTab';
12-
import ActionTab from './tabs/ActionTab';
1313

1414
export interface TabComponentProps<S, A extends Action<unknown>> {
1515
labelRenderer: LabelRenderer;
@@ -23,6 +23,7 @@ export interface TabComponentProps<S, A extends Action<unknown>> {
2323
isWideLayout: boolean;
2424
sortStateTreeAlphabetically: boolean;
2525
disableStateTreeCollection: boolean;
26+
enableSearchPanel: boolean;
2627
dataTypeKey: string | symbol | undefined;
2728
delta: Delta | null | undefined | false;
2829
action: A;
@@ -74,6 +75,7 @@ interface Props<S, A extends Action<unknown>> {
7475
onSelectTab: (tabName: string) => void;
7576
sortStateTreeAlphabetically: boolean;
7677
disableStateTreeCollection: boolean;
78+
enableSearchPanel: boolean;
7779
}
7880

7981
class ActionPreview<S, A extends Action<unknown>> extends Component<
@@ -107,6 +109,7 @@ class ActionPreview<S, A extends Action<unknown>> extends Component<
107109
updateMonitorState,
108110
sortStateTreeAlphabetically,
109111
disableStateTreeCollection,
112+
enableSearchPanel,
110113
} = this.props;
111114

112115
const renderedTabs: Tab<S, A>[] =
@@ -141,6 +144,7 @@ class ActionPreview<S, A extends Action<unknown>> extends Component<
141144
isWideLayout,
142145
sortStateTreeAlphabetically,
143146
disableStateTreeCollection,
147+
enableSearchPanel,
144148
dataTypeKey,
145149
delta,
146150
action,

packages/redux-devtools-inspector-monitor/src/DevtoolsInspector.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import React, { PureComponent } from 'react';
2-
import PropTypes from 'prop-types';
3-
import { Base16Theme } from 'redux-devtools-themes';
4-
import {
5-
getBase16Theme,
6-
invertTheme,
7-
StylingFunction,
8-
} from 'react-base16-styling';
91
import {
102
ActionCreators,
113
LiftedAction,
124
LiftedState,
135
} from '@redux-devtools/core';
14-
import { Action, Dispatch } from 'redux';
156
import { Delta, DiffContext } from 'jsondiffpatch';
7+
import PropTypes from 'prop-types';
8+
import React, { PureComponent } from 'react';
169
import {
17-
createStylingFromTheme,
18-
base16Themes,
19-
} from './utils/createStylingFromTheme';
10+
StylingFunction,
11+
getBase16Theme,
12+
invertTheme,
13+
} from 'react-base16-styling';
14+
import { Action, Dispatch } from 'redux';
15+
import { Base16Theme } from 'redux-devtools-themes';
2016
import ActionList from './ActionList';
2117
import ActionPreview, { Tab } from './ActionPreview';
22-
import getInspectedState from './utils/getInspectedState';
2318
import createDiffPatcher from './createDiffPatcher';
2419
import {
2520
DevtoolsInspectorAction,
2621
DevtoolsInspectorState,
2722
reducer,
2823
updateMonitorState,
2924
} from './redux';
25+
import {
26+
base16Themes,
27+
createStylingFromTheme,
28+
} from './utils/createStylingFromTheme';
29+
import getInspectedState from './utils/getInspectedState';
3030

3131
const {
3232
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -153,6 +153,7 @@ export interface ExternalProps<S, A extends Action<unknown>> {
153153
invertTheme: boolean;
154154
sortStateTreeAlphabetically: boolean;
155155
disableStateTreeCollection: boolean;
156+
enableSearchPanel: boolean;
156157
dataTypeKey?: string | symbol;
157158
tabs: Tab<S, A>[] | ((tabs: Tab<S, A>[]) => Tab<S, A>[]);
158159
}
@@ -181,6 +182,7 @@ export interface DevtoolsInspectorProps<S, A extends Action<unknown>>
181182
hideActionButtons?: boolean;
182183
sortStateTreeAlphabetically: boolean;
183184
disableStateTreeCollection: boolean;
185+
enableSearchPanel: boolean;
184186
invertTheme: boolean;
185187
dataTypeKey?: string | symbol;
186188
tabs: Tab<S, A>[] | ((tabs: Tab<S, A>[]) => Tab<S, A>[]);
@@ -226,6 +228,7 @@ class DevtoolsInspector<S, A extends Action<unknown>> extends PureComponent<
226228
invertTheme: PropTypes.bool,
227229
sortStateTreeAlphabetically: PropTypes.bool,
228230
disableStateTreeCollection: PropTypes.bool,
231+
enableSearchPanel: PropTypes.bool,
229232
skippedActionIds: PropTypes.array,
230233
dataTypeKey: PropTypes.any,
231234
tabs: PropTypes.oneOfType([PropTypes.array, PropTypes.func]),
@@ -313,6 +316,7 @@ class DevtoolsInspector<S, A extends Action<unknown>> extends PureComponent<
313316
hideActionButtons,
314317
sortStateTreeAlphabetically,
315318
disableStateTreeCollection,
319+
enableSearchPanel,
316320
} = this.props;
317321
const { selectedActionId, startActionId, searchValue, tabName } =
318322
monitorState;
@@ -374,6 +378,7 @@ class DevtoolsInspector<S, A extends Action<unknown>> extends PureComponent<
374378
dataTypeKey,
375379
sortStateTreeAlphabetically,
376380
disableStateTreeCollection,
381+
enableSearchPanel,
377382
}}
378383
monitorState={this.props.monitorState}
379384
updateMonitorState={this.updateMonitorState}

packages/redux-devtools-inspector-monitor/src/searchPanel/SearchPanel.tsx

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -114,41 +114,43 @@ function SearchPanel({
114114
{searchStatus === 'pending' && 'Searching...'}
115115
{searchStatus === 'done' && (
116116
<>
117-
<JumpSearchResultButton
118-
buttonDirection={BUTTON_DIRECTION.LEFT}
119-
buttonDisabled={!results || results.length < 2}
120-
styling={styling}
121-
jumpToNewResult={() => {
122-
if (!results) {
123-
return;
124-
}
125-
const newIndex =
126-
resultIndex - 1 < 0 ? results.length - 1 : resultIndex - 1;
127-
setResultIndex(newIndex);
128-
onSubmit({
129-
searchResult: results[newIndex] || [],
130-
searchInProgress: true,
131-
});
132-
}}
133-
/>
134-
<JumpSearchResultButton
135-
buttonDirection={BUTTON_DIRECTION.RIGHT}
136-
buttonDisabled={!results || results.length < 2}
137-
styling={styling}
138-
jumpToNewResult={() => {
139-
if (!results) {
140-
return;
141-
}
142-
const newIndex = (resultIndex + 1) % results.length || 0;
143-
setResultIndex(newIndex);
144-
onSubmit({
145-
searchResult: results[newIndex] || [],
146-
searchInProgress: true,
147-
});
148-
}}
149-
/>
150-
{results &&
151-
`${results.length ? resultIndex + 1 : 0}/${results.length}`}
117+
<div {...styling('jumpResultContainer')}>
118+
<JumpSearchResultButton
119+
buttonDirection={BUTTON_DIRECTION.LEFT}
120+
buttonDisabled={!results || results.length < 2}
121+
styling={styling}
122+
jumpToNewResult={() => {
123+
if (!results) {
124+
return;
125+
}
126+
const newIndex =
127+
resultIndex - 1 < 0 ? results.length - 1 : resultIndex - 1;
128+
setResultIndex(newIndex);
129+
onSubmit({
130+
searchResult: results[newIndex] || [],
131+
searchInProgress: true,
132+
});
133+
}}
134+
/>
135+
<JumpSearchResultButton
136+
buttonDirection={BUTTON_DIRECTION.RIGHT}
137+
buttonDisabled={!results || results.length < 2}
138+
styling={styling}
139+
jumpToNewResult={() => {
140+
if (!results) {
141+
return;
142+
}
143+
const newIndex = (resultIndex + 1) % results.length || 0;
144+
setResultIndex(newIndex);
145+
onSubmit({
146+
searchResult: results[newIndex] || [],
147+
searchInProgress: true,
148+
});
149+
}}
150+
/>
151+
{results &&
152+
`${results.length ? resultIndex + 1 : 0}/${results.length}`}
153+
</div>
152154
<button {...styling('searchButton')} onClick={() => reset()}>
153155
Reset
154156
</button>

0 commit comments

Comments
 (0)