diff --git a/src/components/ProfilingControlStack.tsx b/src/components/ProfilingControlStack.tsx index b2123ca1..b076cdf3 100644 --- a/src/components/ProfilingControlStack.tsx +++ b/src/components/ProfilingControlStack.tsx @@ -34,7 +34,7 @@ export function ProfilingControlStack() { const [level, setLevel] = useState() const [slowms, setSlowms] = useState(0) const [sampleRate, setSampleRate] = useState(0) - const { data: profile, revalidate, isValidating } = useCommandProfile() + const { data: profile, error, revalidate, isValidating } = useCommandProfile() const handleSetProfile = useCallback( async () => database && level !== undefined @@ -141,7 +141,7 @@ export function ProfilingControlStack() { styles={{ root: { height: 52, alignItems: 'center' }, }}> - {hosts.length > 1 ? ( + {hosts.length > 1 && !error ? ( <> ) : null} - - { - setLevel(option?.key as ProfilingLevel) - }} - styles={{ root: { width: 80 } }} - options={[ - { key: ProfilingLevel.OFF, text: 'Off' }, - { key: ProfilingLevel.SLOW, text: 'Slow' }, - { key: ProfilingLevel.ALL, text: 'All' }, - ]} - /> + {error ? null : ( + <> + + { + setLevel(option?.key as ProfilingLevel) + }} + styles={{ root: { width: 80 } }} + options={[ + { key: ProfilingLevel.OFF, text: 'Off' }, + { key: ProfilingLevel.SLOW, text: 'Slow' }, + { key: ProfilingLevel.ALL, text: 'All' }, + ]} + /> + + )} {level === ProfilingLevel.SLOW ? ( <> +
+ +
)}
diff --git a/src/components/ProfilingList.tsx b/src/components/ProfilingList.tsx index 35eca531..564beb62 100644 --- a/src/components/ProfilingList.tsx +++ b/src/components/ProfilingList.tsx @@ -1,15 +1,28 @@ -import { Stack, ContextualMenu, DirectionalHint } from '@fluentui/react' -import React, { useState } from 'react' +import { ContextualMenu, DirectionalHint, IColumn } from '@fluentui/react' +import React, { useState, useCallback } from 'react' import { useSelector, useDispatch } from 'react-redux' import { useCommandSystemProfileFind } from '@/hooks/use-command' import { actions } from '@/stores' -import { ProfilingCard } from './ProfilingCard' +import { DisplayMode, MongoData } from '@/types' import { LargeMessage } from './LargeMessage' -import { EditorModal } from './EditorModal' +import { Table } from './Table' +import { TableCell } from './TableCell' +import { ProfilingModal } from './ProfilingModal' + +const order = [ + 'op', + 'millis', + 'ts', + 'keysExamined', + 'docsExamined', + 'numYield', + 'planSummary', +] export function ProfilingList() { const { data, error } = useCommandSystemProfileFind() + const collection = useSelector((state) => state.root.collection) const invokedProfiling = useSelector( (state) => state.profiling.invokedProfiling, ) @@ -17,6 +30,35 @@ export function ProfilingList() { const isMenuHidden = useSelector((state) => state.profiling.isMenuHidden) const dispatch = useDispatch() const [target, setTarget] = useState() + const handleItemContextMenu = useCallback( + (ev: MouseEvent, item?: { [key: string]: MongoData }) => { + setTarget(ev) + if (item) { + dispatch(actions.profiling.setInvokedProfiling(item)) + } + dispatch(actions.profiling.setIsMenuHidden(false)) + }, + [dispatch], + ) + const handleItemInvoked = useCallback( + (item) => { + if (item) { + dispatch(actions.profiling.setInvokedProfiling(item)) + } + dispatch(actions.profiling.setIsEditorOpen(true)) + }, + [dispatch], + ) + const handleRenderItemColumn = useCallback( + ( + item?: { [key: string]: MongoData }, + _index?: number, + column?: IColumn, + ) => { + return + }, + [], + ) if (error) { return ( @@ -31,15 +73,16 @@ export function ProfilingList() { } return ( <> - { - dispatch(actions.profiling.setIsEditorOpen(false)) - }} - /> + {invokedProfiling ? ( + { + dispatch(actions.profiling.setIsEditorOpen(false)) + }} + /> + ) : null}