// 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 React, {useRef, useState} from 'react'; import {AnimatePresence, motion} from 'framer-motion'; import {useQueryState} from 'nuqs'; import {TEST_IDS, testId} from '@parca/test-utils'; import {ProfileSource} from '../ProfileSource'; import {useDashboard} from '../ProfileView/context/DashboardContext'; import {useVisualizationState} from '../ProfileView/hooks/useVisualizationState'; import {SandwichData} from '../ProfileView/types/visualization'; import {stringParam} from '../hooks/urlParsers'; import {CalleesSection} from './components/CalleesSection'; import {CallersSection} from './components/CallersSection'; interface Props { profileSource: ProfileSource; sandwichData: SandwichData; } const Sandwich = React.memo(function Sandwich({ sandwichData, profileSource, }: Props): React.JSX.Element { const {dashboardItems} = useDashboard(); const [sandwichFunctionName] = useQueryState('sandwich_function_name', stringParam); const callersRef = React.useRef(null); const calleesRef = React.useRef(null); const [isExpanded, setIsExpanded] = useState(false); const defaultMaxFrames = 10; const callersCalleesContainerRef = useRef(null); const {curPathArrow, setCurPathArrow} = useVisualizationState(); return (
{sandwichFunctionName != null ? (
) : (

{dashboardItems.includes('table') ? ( 'Please select a function to view its callers and callees.' ) : ( <> Use the right-click menu on the Flame{' '} {dashboardItems.includes('flamegraph') ? 'Graph' : 'Chart'} to choose a function to view its callers and callees. )}

)}
); }); export default Sandwich;