import React, { PureComponent, ReactNode } from 'react'; import type { Interpolation, Theme } from '@emotion/react'; import { RtkResourceInfo, RtkQueryMonitorState } from '../types'; import { isQuerySelected } from '../utils/rtk-query'; const queryStatusCss: Interpolation = (theme) => ({ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', height: 22, padding: '0 6px', borderRadius: '3px', fontSize: '0.7em', lineHeight: '1em', flexShrink: 0, fontWeight: 700, backgroundColor: theme.ACTION_TIME_BACK_COLOR, color: theme.ACTION_TIME_COLOR, }); export interface QueryListProps { resInfos: RtkResourceInfo[]; selectedQueryKey: RtkQueryMonitorState['selectedQueryKey']; onSelectQuery: (query: RtkResourceInfo) => void; } export class QueryList extends PureComponent { static isItemSelected( selectedQueryKey: QueryListProps['selectedQueryKey'], queryInfo: RtkResourceInfo, ): boolean { return ( !!selectedQueryKey && selectedQueryKey.queryKey === queryInfo.queryKey && selectedQueryKey.reducerPath === queryInfo.reducerPath ); } static formatQuery(resInfo: RtkResourceInfo): string { const key = resInfo.type === 'query' ? resInfo.queryKey : `${resInfo.state.endpointName ?? ''} ${resInfo.queryKey}`; return key; } render(): ReactNode { const { resInfos, selectedQueryKey, onSelectQuery } = this.props; return ( ); } }