Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('FlamegraphComponent', () => {

render(
<FlamegraphComponent
updateFitMode={() => ({})}
selectedItem={Maybe.nothing()}
setActiveItem={() => ({})}
showCredit
Expand All @@ -46,6 +47,7 @@ describe('FlamegraphComponent', () => {

render(
<FlamegraphComponent
updateFitMode={() => ({})}
selectedItem={Maybe.nothing()}
setActiveItem={() => ({})}
showCredit
Expand Down Expand Up @@ -83,6 +85,7 @@ describe('FlamegraphComponent', () => {

render(
<FlamegraphComponent
updateFitMode={() => ({})}
selectedItem={Maybe.nothing()}
setActiveItem={() => ({})}
showCredit
Expand Down Expand Up @@ -117,6 +120,7 @@ describe('FlamegraphComponent', () => {

const { rerender } = render(
<FlamegraphComponent
updateFitMode={() => ({})}
selectedItem={Maybe.nothing()}
setActiveItem={() => ({})}
showCredit
Expand Down Expand Up @@ -152,6 +156,7 @@ describe('FlamegraphComponent', () => {

rerender(
<FlamegraphComponent
updateFitMode={() => ({})}
selectedItem={Maybe.nothing()}
setActiveItem={() => ({})}
showCredit
Expand Down Expand Up @@ -187,6 +192,7 @@ describe('FlamegraphComponent', () => {

render(
<FlamegraphComponent
updateFitMode={() => ({})}
selectedItem={Maybe.nothing()}
setActiveItem={() => ({})}
showCredit
Expand Down Expand Up @@ -228,6 +234,7 @@ describe('FlamegraphComponent', () => {
it('renders when type is single', () => {
render(
<FlamegraphComponent
updateFitMode={() => ({})}
selectedItem={Maybe.nothing()}
setActiveItem={() => ({})}
showCredit
Expand Down Expand Up @@ -255,6 +262,7 @@ describe('FlamegraphComponent', () => {
const flamebearer = TestData.DiffTree;
render(
<FlamegraphComponent
updateFitMode={() => ({})}
selectedItem={Maybe.nothing()}
setActiveItem={() => ({})}
showCredit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ import ContextMenuHighlight from './ContextMenuHighlight';
import FlamegraphTooltip from '../../Tooltip/FlamegraphTooltip';
import ContextMenu from './ContextMenu';
import LogoLink from './LogoLink';
import { SandwichIcon } from '../../Icons';
import { SandwichIcon, HeadFirstIcon, TailFirstIcon } from '../../Icons';
import { PX_PER_LEVEL } from './constants';
import Header from './Header';
import { FlamegraphPalette } from './colorPalette';
import type { ViewTypes } from './viewTypes';
import { FitModes, HeadMode, TailMode } from '../../fitMode/fitMode';
import indexStyles from './styles.module.scss';

interface FlamegraphProps {
flamebearer: Flamebearer;
focusedNode: ConstructorParameters<typeof Flamegraph>[2];
fitMode: ConstructorParameters<typeof Flamegraph>[3];
updateFitMode: (f: FitModes) => void;
highlightQuery: ConstructorParameters<typeof Flamegraph>[4];
zoom: ConstructorParameters<typeof Flamegraph>[5];
showCredit: boolean;
Expand Down Expand Up @@ -63,6 +65,7 @@ export default function FlameGraphComponent(props: FlamegraphProps) {
flamebearer,
focusedNode,
fitMode,
updateFitMode,
highlightQuery,
zoom,
toolbarVisible,
Expand Down Expand Up @@ -238,6 +241,26 @@ export default function FlameGraphComponent(props: FlamegraphProps) {
);
};

const FitModeItem = () => {
const isHeadFirst = fitMode === HeadMode;

const handleClick = () => {
const newValues = isHeadFirst ? TailMode : HeadMode;
updateFitMode(newValues);
};

return (
<MenuItem
className={indexStyles.fitModeItem}
key="fit-mode"
onClick={handleClick}
>
{isHeadFirst ? <TailFirstIcon /> : <HeadFirstIcon />}
Show text {isHeadFirst ? 'tail first' : 'head first'}
</MenuItem>
);
};

return [
<MenuItem key="reset" disabled={!dirty} onClick={onReset}>
<FontAwesomeIcon icon={faRedo} />
Expand All @@ -247,9 +270,10 @@ export default function FlameGraphComponent(props: FlamegraphProps) {
CopyItem(),
HighlightSimilarNodesItem(),
OpenInSandwichViewItem(),
FitModeItem(),
];
},
[flamegraph, selectedItem]
[flamegraph, selectedItem, fitMode]
);

const constructCanvas = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
flex: 1;
position: relative;

.fitModeItem svg,
.sandwichItem svg {
width: 1em;
margin-right: 10px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ class FlameGraphRenderer extends Component<
selectedItem={this.state.selectedItem}
updateView={this.updateView}
fitMode={this.state.fitMode}
updateFitMode={this.updateFitMode}
zoom={this.state.flamegraphConfigs.zoom}
focusedNode={this.state.flamegraphConfigs.focusedNode}
onZoom={this.onFlamegraphZoom}
Expand Down Expand Up @@ -481,6 +482,7 @@ class FlameGraphRenderer extends Component<
setActiveItem={this.setActiveItem}
selectedItem={this.state.selectedItem}
fitMode={this.state.fitMode}
updateFitMode={this.updateFitMode}
zoom={this.state.flamegraphConfigs.zoom}
focusedNode={this.state.flamegraphConfigs.focusedNode}
onZoom={this.onFlamegraphZoom}
Expand Down