mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-22 14:09:46 +03:00
Fix rtk-query-monitor types
This commit is contained in:
parent
1ad63b5ce5
commit
9817a664e9
|
@ -1,6 +1,7 @@
|
||||||
import { createSelector, Selector } from '@reduxjs/toolkit';
|
import { createSelector, Selector } from '@reduxjs/toolkit';
|
||||||
import React, { ReactNode, PureComponent } from 'react';
|
import React, { ReactNode, PureComponent } from 'react';
|
||||||
import { Action, AnyAction } from 'redux';
|
import { Action, AnyAction } from 'redux';
|
||||||
|
import type { KeyPath, ShouldExpandNodeInitially } from 'react-json-tree';
|
||||||
import { QueryPreviewTabs } from '../types';
|
import { QueryPreviewTabs } from '../types';
|
||||||
import { renderTabPanelButtonId, renderTabPanelId } from '../utils/a11y';
|
import { renderTabPanelButtonId, renderTabPanelId } from '../utils/a11y';
|
||||||
import { emptyRecord, identity } from '../utils/object';
|
import { emptyRecord, identity } from '../utils/object';
|
||||||
|
@ -43,7 +44,7 @@ export class QueryPreviewActions extends PureComponent<QueryPreviewActionsProps>
|
||||||
return output;
|
return output;
|
||||||
});
|
});
|
||||||
|
|
||||||
isLastActionNode = (keyPath: (string | number)[], layer: number): boolean => {
|
isLastActionNode = (keyPath: KeyPath, layer: number): boolean => {
|
||||||
if (layer >= 1) {
|
if (layer >= 1) {
|
||||||
const len = this.props.actionsOfQuery.length;
|
const len = this.props.actionsOfQuery.length;
|
||||||
const actionKey = keyPath[keyPath.length - 1];
|
const actionKey = keyPath[keyPath.length - 1];
|
||||||
|
@ -58,11 +59,11 @@ export class QueryPreviewActions extends PureComponent<QueryPreviewActionsProps>
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
shouldExpandNodeInitially = (
|
shouldExpandNodeInitially: ShouldExpandNodeInitially = (
|
||||||
keyPath: (string | number)[],
|
keyPath,
|
||||||
value: unknown,
|
value,
|
||||||
layer: number
|
layer
|
||||||
): boolean => {
|
) => {
|
||||||
if (layer === 1) {
|
if (layer === 1) {
|
||||||
return this.isLastActionNode(keyPath, layer);
|
return this.isLastActionNode(keyPath, layer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { ReactNode, PureComponent } from 'react';
|
import React, { ReactNode, PureComponent } from 'react';
|
||||||
|
import type { ShouldExpandNodeInitially } from 'react-json-tree';
|
||||||
import { ApiStats, QueryPreviewTabs, RtkQueryApiState } from '../types';
|
import { ApiStats, QueryPreviewTabs, RtkQueryApiState } from '../types';
|
||||||
import { StyleUtilsContext } from '../styles/createStylingFromTheme';
|
import { StyleUtilsContext } from '../styles/createStylingFromTheme';
|
||||||
import { TreeView, TreeViewProps } from './TreeView';
|
import { TreeView, TreeViewProps } from './TreeView';
|
||||||
|
@ -17,11 +18,11 @@ const rootProps: TreeViewProps['rootProps'] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export class QueryPreviewApi extends PureComponent<QueryPreviewApiProps> {
|
export class QueryPreviewApi extends PureComponent<QueryPreviewApiProps> {
|
||||||
shouldExpandApiStateNode = (
|
shouldExpandApiStateNode: ShouldExpandNodeInitially = (
|
||||||
keyPath: (string | number)[],
|
keyPath,
|
||||||
value: unknown,
|
value,
|
||||||
layer: number
|
layer
|
||||||
): boolean => {
|
) => {
|
||||||
const lastKey = keyPath[keyPath.length - 1];
|
const lastKey = keyPath[keyPath.length - 1];
|
||||||
|
|
||||||
return layer <= 1 && lastKey !== 'config';
|
return layer <= 1 && lastKey !== 'config';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import React, { ReactNode, PureComponent } from 'react';
|
import React, { ReactNode, PureComponent } from 'react';
|
||||||
|
import type { ShouldExpandNodeInitially } from 'react-json-tree';
|
||||||
import { QueryPreviewTabs, RtkResourceInfo } from '../types';
|
import { QueryPreviewTabs, RtkResourceInfo } from '../types';
|
||||||
import { renderTabPanelButtonId, renderTabPanelId } from '../utils/a11y';
|
import { renderTabPanelButtonId, renderTabPanelId } from '../utils/a11y';
|
||||||
import { TreeView, TreeViewProps } from './TreeView';
|
import { TreeView, TreeViewProps } from './TreeView';
|
||||||
|
@ -15,11 +16,11 @@ const rootProps: TreeViewProps['rootProps'] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export class QueryPreviewData extends PureComponent<QueryPreviewDataProps> {
|
export class QueryPreviewData extends PureComponent<QueryPreviewDataProps> {
|
||||||
shouldExpandNodeInitially = (
|
shouldExpandNodeInitially: ShouldExpandNodeInitially = (
|
||||||
keyPath: (string | number)[],
|
keyPath,
|
||||||
value: unknown,
|
value,
|
||||||
layer: number
|
layer
|
||||||
): boolean => {
|
) => {
|
||||||
return layer <= 1;
|
return layer <= 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { createSelector, Selector } from '@reduxjs/toolkit';
|
import { createSelector, Selector } from '@reduxjs/toolkit';
|
||||||
import { QueryStatus } from '@reduxjs/toolkit/dist/query';
|
import { QueryStatus } from '@reduxjs/toolkit/dist/query';
|
||||||
import React, { ReactNode, PureComponent } from 'react';
|
import React, { ReactNode, PureComponent } from 'react';
|
||||||
|
import type { ShouldExpandNodeInitially } from 'react-json-tree';
|
||||||
import { QueryPreviewTabs, RtkResourceInfo, RTKStatusFlags } from '../types';
|
import { QueryPreviewTabs, RtkResourceInfo, RTKStatusFlags } from '../types';
|
||||||
import { renderTabPanelButtonId, renderTabPanelId } from '../utils/a11y';
|
import { renderTabPanelButtonId, renderTabPanelId } from '../utils/a11y';
|
||||||
import { formatMs } from '../utils/formatters';
|
import { formatMs } from '../utils/formatters';
|
||||||
|
@ -35,11 +36,11 @@ export interface QueryPreviewInfoProps {
|
||||||
isWideLayout: boolean;
|
isWideLayout: boolean;
|
||||||
}
|
}
|
||||||
export class QueryPreviewInfo extends PureComponent<QueryPreviewInfoProps> {
|
export class QueryPreviewInfo extends PureComponent<QueryPreviewInfoProps> {
|
||||||
shouldExpandNodeInitially = (
|
shouldExpandNodeInitially: ShouldExpandNodeInitially = (
|
||||||
keyPath: (string | number)[],
|
keyPath,
|
||||||
value: unknown,
|
value,
|
||||||
layer: number
|
layer
|
||||||
): boolean => {
|
) => {
|
||||||
const lastKey = keyPath[keyPath.length - 1];
|
const lastKey = keyPath[keyPath.length - 1];
|
||||||
|
|
||||||
return layer <= 1 && lastKey !== 'query' && lastKey !== 'mutation';
|
return layer <= 1 && lastKey !== 'query' && lastKey !== 'mutation';
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode } from 'react';
|
||||||
import { StylingFunction } from 'react-base16-styling';
|
import { StylingFunction } from 'react-base16-styling';
|
||||||
|
import type { LabelRenderer } from 'react-json-tree';
|
||||||
import { isCollection, isIndexed, isKeyed } from 'immutable';
|
import { isCollection, isIndexed, isKeyed } from 'immutable';
|
||||||
import isIterable from '../utils/isIterable';
|
import isIterable from '../utils/isIterable';
|
||||||
|
|
||||||
|
@ -91,12 +92,10 @@ export function getItemString(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTreeItemLabelRenderer(styling: StylingFunction) {
|
export function createTreeItemLabelRenderer(
|
||||||
return function labelRenderer(
|
styling: StylingFunction
|
||||||
[key]: (string | number)[],
|
): LabelRenderer {
|
||||||
nodeType: string,
|
return function labelRenderer([key], nodeType, expanded) {
|
||||||
expanded: boolean
|
|
||||||
): ReactNode {
|
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
<span {...styling('treeItemKey')}>{key}</span>
|
<span {...styling('treeItemKey')}>{key}</span>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user