Skip to content

Commit c555506

Browse files
committed
Refactor evolution rendering buttons component
1 parent efc66a6 commit c555506

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

src/components/extended-reality/visualization/page-setup/bottom-bar/evolution/evolution-rendering-buttons.tsx

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
import {
2-
useCommitTreeStateStore,
3-
SelectedCommit,
4-
} from 'explorviz-frontend/src/stores/commit-tree-state';
1+
import { useCommitTreeStateStore } from 'explorviz-frontend/src/stores/commit-tree-state';
52
import { useRenderingServiceStore } from 'explorviz-frontend/src/stores/rendering-service';
63
import { useVisibilityServiceStore } from 'explorviz-frontend/src/stores/visibility-service';
7-
import { useShallow } from 'zustand/react/shallow';
8-
import Dropdown from 'react-bootstrap/Dropdown';
9-
import { DropdownButton } from 'react-bootstrap';
104
import { useState } from 'react';
11-
import { useToastHandlerStore } from 'explorviz-frontend/src/stores/toast-handler';
12-
13-
interface IArgs {
14-
selectedAppName: string;
15-
selectedCommits: Map<string, SelectedCommit[]>;
16-
}
5+
import { DropdownButton } from 'react-bootstrap';
6+
import Dropdown from 'react-bootstrap/Dropdown';
7+
import { useShallow } from 'zustand/react/shallow';
178

18-
export default function EvolutionRenderingButtons(args: IArgs) {
9+
export default function EvolutionRenderingButtons() {
1910
const commitTreeState = useCommitTreeStateStore(
2011
useShallow((state) => ({
2112
resetSelectedCommits: state.resetSelectedCommits,
@@ -31,8 +22,14 @@ export default function EvolutionRenderingButtons(args: IArgs) {
3122
}))
3223
);
3324

34-
const showErrorToastMessage = useToastHandlerStore(
35-
(state) => state.showErrorToastMessage
25+
const getCurrentSelectedApplicationName = useCommitTreeStateStore(
26+
(state) => state.getCurrentSelectedApplicationName
27+
);
28+
29+
const { getSelectedCommits } = useCommitTreeStateStore(
30+
useShallow((state) => ({
31+
getSelectedCommits: state.getSelectedCommits,
32+
}))
3633
);
3734

3835
const visService = useVisibilityServiceStore(
@@ -67,11 +64,6 @@ export default function EvolutionRenderingButtons(args: IArgs) {
6764
evolutionMode.renderStatic = true;
6865
evolutionMode.renderOnlyDifferences = false;
6966
} else if (x === 'difference') {
70-
if (args.selectedCommits.size < 2) {
71-
showErrorToastMessage(
72-
'Cannot show differences, less than 2 commits selected'
73-
);
74-
}
7567
evolutionMode.renderStatic = true;
7668
evolutionMode.renderOnlyDifferences = true;
7769
}
@@ -80,10 +72,12 @@ export default function EvolutionRenderingButtons(args: IArgs) {
8072

8173
return (
8274
<div className="col-md-auto">
83-
{args.selectedAppName && (
75+
{getCurrentSelectedApplicationName() && (
8476
<div className="row justify-content-md-center">
85-
{(args.selectedCommits.get(args.selectedAppName)?.length === 1 ||
86-
args.selectedCommits.get(args.selectedAppName)?.length === 2) && (
77+
{(getSelectedCommits().get(getCurrentSelectedApplicationName())
78+
?.length === 1 ||
79+
getSelectedCommits().get(getCurrentSelectedApplicationName())
80+
?.length === 2) && (
8781
<div className="col-md-auto">
8882
<div className="d-flex">
8983
<button
@@ -96,7 +90,7 @@ export default function EvolutionRenderingButtons(args: IArgs) {
9690
</div>
9791
</div>
9892
)}
99-
{args.selectedCommits.size > 0 && (
93+
{getSelectedCommits().size > 0 && (
10094
<div className="col-md-auto">
10195
<DropdownButton
10296
id="dropdown-basic-button"

src/pages/visualization.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,7 @@ export default function Visualization() {
893893
selectedAppName={currentSelectedApplicationName}
894894
/>
895895
</div>
896-
<EvolutionRenderingButtons
897-
selectedAppName={currentSelectedApplicationName}
898-
selectedCommits={getSelectedCommits()}
899-
/>
896+
<EvolutionRenderingButtons />
900897
</div>
901898
<PlotlyCommitTree
902899
appNameCommitTreeMap={

0 commit comments

Comments
 (0)