mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-27 08:30:02 +03:00
feat(rtk-query): do not display tree node preview
Other changes: * improve visibility of demo devTools on small devices * tweak QueryPreviewInfo labels
This commit is contained in:
parent
990521bba4
commit
0319b810c9
|
@ -7,11 +7,11 @@ const largeScreenQuery = window.matchMedia('(min-width: 1024px)');
|
||||||
|
|
||||||
export default createDevTools(
|
export default createDevTools(
|
||||||
<DockMonitor
|
<DockMonitor
|
||||||
fluid
|
|
||||||
toggleVisibilityKey="ctrl-h"
|
toggleVisibilityKey="ctrl-h"
|
||||||
changePositionKey="ctrl-q"
|
changePositionKey="ctrl-q"
|
||||||
changeMonitorKey="ctrl-m"
|
changeMonitorKey="ctrl-m"
|
||||||
defaultSize={largeScreenQuery.matches ? 0.34 : 0.55}
|
fluid
|
||||||
|
defaultSize={largeScreenQuery.matches ? 0.44 : 0.55}
|
||||||
>
|
>
|
||||||
<RtkQueryMonitor />
|
<RtkQueryMonitor />
|
||||||
</DockMonitor>
|
</DockMonitor>
|
||||||
|
|
|
@ -52,10 +52,10 @@ const AddPost = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex p={5}>
|
<Flex p={'5px 0'} flexDirection="row" flexWrap="wrap" maxWidth={'85%'}>
|
||||||
<Box flex={10}>
|
<Box flex={'5 0 auto'} padding="0 5px 0 0">
|
||||||
<FormControl isInvalid={Boolean(post.name.length < 3 && post.name)}>
|
<FormControl flexDirection="column" isInvalid={Boolean(post.name.length < 3 && post.name)}>
|
||||||
<FormLabel htmlFor="name">Post name</FormLabel>
|
<FormLabel htmlFor="name">Post name</FormLabel>
|
||||||
<Input
|
<Input
|
||||||
id="name"
|
id="name"
|
||||||
name="name"
|
name="name"
|
||||||
|
@ -65,7 +65,6 @@ const AddPost = () => {
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Box>
|
</Box>
|
||||||
<Spacer />
|
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<Button
|
||||||
mt={8}
|
mt={8}
|
||||||
|
|
|
@ -35,7 +35,7 @@ h6 {
|
||||||
|
|
||||||
section {
|
section {
|
||||||
display: block;
|
display: block;
|
||||||
max-width: 67vw;
|
max-width: 65%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pokemon-list {
|
.pokemon-list {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { TreeView } from './TreeView';
|
||||||
|
|
||||||
type QueryTimings = {
|
type QueryTimings = {
|
||||||
startedAt: string;
|
startedAt: string;
|
||||||
latestFetchAt: string;
|
loadedAt: string;
|
||||||
duration: string;
|
duration: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ export class QueryPreviewInfo extends PureComponent<QueryPreviewInfoProps> {
|
||||||
? new Date(query.startedTimeStamp).toISOString()
|
? new Date(query.startedTimeStamp).toISOString()
|
||||||
: '-';
|
: '-';
|
||||||
|
|
||||||
const latestFetchAt = query.fulfilledTimeStamp
|
const loadedAt = query.fulfilledTimeStamp
|
||||||
? new Date(query.fulfilledTimeStamp).toISOString()
|
? new Date(query.fulfilledTimeStamp).toISOString()
|
||||||
: '-';
|
: '-';
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export class QueryPreviewInfo extends PureComponent<QueryPreviewInfoProps> {
|
||||||
|
|
||||||
const timings = {
|
const timings = {
|
||||||
startedAt,
|
startedAt,
|
||||||
latestFetchAt,
|
loadedAt,
|
||||||
duration: '-',
|
duration: '-',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,14 @@ export class TreeView extends React.PureComponent<TreeViewProps> {
|
||||||
ReturnType<typeof createTreeItemLabelRenderer>
|
ReturnType<typeof createTreeItemLabelRenderer>
|
||||||
>(identity, createTreeItemLabelRenderer);
|
>(identity, createTreeItemLabelRenderer);
|
||||||
|
|
||||||
readonly selectGetItemString = createSelector(
|
readonly selectGetItemString = createSelector<
|
||||||
[
|
StylingFunction,
|
||||||
(styling: StylingFunction, _: boolean) => styling,
|
StylingFunction,
|
||||||
(_: StylingFunction, isWideLayout: boolean) => isWideLayout,
|
(type: string, data: unknown) => ReactNode
|
||||||
],
|
>(
|
||||||
(styling, isWideLayout) => (type: string, data: any) =>
|
identity,
|
||||||
getItemString(styling, type, data, DATA_TYPE_KEY, isWideLayout)
|
(styling) => (type, data) =>
|
||||||
|
getItemString(styling, type, data, DATA_TYPE_KEY, false)
|
||||||
);
|
);
|
||||||
|
|
||||||
readonly selectTheme = createSelector<
|
readonly selectTheme = createSelector<
|
||||||
|
@ -63,7 +64,6 @@ export class TreeView extends React.PureComponent<TreeViewProps> {
|
||||||
|
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
const {
|
const {
|
||||||
isWideLayout,
|
|
||||||
data,
|
data,
|
||||||
before,
|
before,
|
||||||
after,
|
after,
|
||||||
|
@ -86,7 +86,7 @@ export class TreeView extends React.PureComponent<TreeViewProps> {
|
||||||
labelRenderer={this.selectLabelRenderer(styling)}
|
labelRenderer={this.selectLabelRenderer(styling)}
|
||||||
theme={this.selectTheme(base16Theme)}
|
theme={this.selectTheme(base16Theme)}
|
||||||
invertTheme={invertTheme}
|
invertTheme={invertTheme}
|
||||||
getItemString={this.selectGetItemString(styling, isWideLayout)}
|
getItemString={this.selectGetItemString(styling)}
|
||||||
hideRoot={hideRoot}
|
hideRoot={hideRoot}
|
||||||
/>
|
/>
|
||||||
{after}
|
{after}
|
||||||
|
|
|
@ -77,7 +77,7 @@ class RtkQueryInspector<S, A extends Action<unknown>> extends PureComponent<
|
||||||
updateSizeMode = (): void => {
|
updateSizeMode = (): void => {
|
||||||
if (this.inspectorRef.current) {
|
if (this.inspectorRef.current) {
|
||||||
const isWideLayout =
|
const isWideLayout =
|
||||||
this.inspectorRef.current.offsetWidth > RtkQueryInspector.wideLayout;
|
this.inspectorRef.current.offsetWidth >= RtkQueryInspector.wideLayout;
|
||||||
|
|
||||||
if (isWideLayout !== this.state.isWideLayout) {
|
if (isWideLayout !== this.state.isWideLayout) {
|
||||||
this.setState({ isWideLayout });
|
this.setState({ isWideLayout });
|
||||||
|
|
|
@ -40,12 +40,12 @@ function getShortTypeString(val: unknown, diff: boolean | undefined) {
|
||||||
function getText(
|
function getText(
|
||||||
type: string,
|
type: string,
|
||||||
data: any,
|
data: any,
|
||||||
isWideLayout: boolean,
|
previewContent: boolean,
|
||||||
isDiff: boolean | undefined
|
isDiff: boolean | undefined
|
||||||
) {
|
) {
|
||||||
if (type === 'Object') {
|
if (type === 'Object') {
|
||||||
const keys = Object.keys(data);
|
const keys = Object.keys(data);
|
||||||
if (!isWideLayout) return keys.length ? '{…}' : '{}';
|
if (!previewContent) return keys.length ? '{…}' : '{}';
|
||||||
|
|
||||||
const str = keys
|
const str = keys
|
||||||
.slice(0, 3)
|
.slice(0, 3)
|
||||||
|
@ -57,7 +57,7 @@ function getText(
|
||||||
|
|
||||||
return `{ ${str} }`;
|
return `{ ${str} }`;
|
||||||
} else if (type === 'Array') {
|
} else if (type === 'Array') {
|
||||||
if (!isWideLayout) return data.length ? '[…]' : '[]';
|
if (!previewContent) return data.length ? '[…]' : '[]';
|
||||||
|
|
||||||
const str = data
|
const str = data
|
||||||
.slice(0, 4)
|
.slice(0, 4)
|
||||||
|
@ -76,7 +76,7 @@ export function getItemString(
|
||||||
type: string,
|
type: string,
|
||||||
data: any,
|
data: any,
|
||||||
dataTypeKey: string | symbol | undefined,
|
dataTypeKey: string | symbol | undefined,
|
||||||
isWideLayout: boolean,
|
previewContent: boolean,
|
||||||
isDiff?: boolean
|
isDiff?: boolean
|
||||||
): ReactNode {
|
): ReactNode {
|
||||||
return (
|
return (
|
||||||
|
@ -85,7 +85,7 @@ export function getItemString(
|
||||||
{dataTypeKey && data[dataTypeKey]
|
{dataTypeKey && data[dataTypeKey]
|
||||||
? `${data[dataTypeKey] as string} `
|
? `${data[dataTypeKey] as string} `
|
||||||
: ''}
|
: ''}
|
||||||
{getText(type, data, isWideLayout, isDiff)}
|
{getText(type, data, previewContent, isDiff)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user