// Copyright 2022 The Parca Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. import {Profiler, ProfilerOnRenderCallback} from 'react'; import {QueryServiceClient} from '@parca/client'; import {ConditionalWrapper} from '@parca/components'; import ProfileFlameChart from '../../../ProfileFlameChart'; import ProfileFlameGraph from '../../../ProfileFlameGraph'; import {CurrentPathFrame} from '../../../ProfileFlameGraph/FlameGraphArrow/utils'; import {ProfileSource} from '../../../ProfileSource'; import Sandwich from '../../../Sandwich'; import {SourceView} from '../../../SourceView'; import {Table} from '../../../Table'; import type { FlamegraphData, SamplesData, SandwichData, SourceData, TopTableData, VisualizationType, } from '../../types/visualization'; interface GetDashboardItemProps { type: VisualizationType; isHalfScreen: boolean; dimensions: DOMRect | undefined; flamegraphData: FlamegraphData; samplesData?: SamplesData; topTableData?: TopTableData; sandwichData: SandwichData; sourceData?: SourceData; profileSource: ProfileSource; total: bigint; filtered: bigint; curPathArrow: CurrentPathFrame[]; setNewCurPathArrow: (path: CurrentPathFrame[]) => void; perf?: { onRender?: ProfilerOnRenderCallback; }; queryClient: QueryServiceClient; onSwitchToFifteenMinutes?: () => void; } export const getDashboardItem = ({ type, isHalfScreen, dimensions, flamegraphData, samplesData, topTableData, sourceData, sandwichData, profileSource, total, filtered, curPathArrow, setNewCurPathArrow, perf, queryClient, onSwitchToFifteenMinutes, }: GetDashboardItemProps): JSX.Element => { switch (type) { case 'flamegraph': return ( {}), }} > ); case 'flamechart': return ( ); case 'table': return topTableData != null ? ( ) : ( <> ); case 'sandwich': return topTableData != null ? ( ) : ( <> ); case 'source': return sourceData != null ? ( ) : ( <> ); default: return <>; } };