Skip to content
Snippets Groups Projects
Commit 16357f83 authored by Loïc Correnson's avatar Loïc Correnson Committed by Allan Blanchard
Browse files

[wp/ivette] selected goals feedback

parent c9dcc47d
No related branches found
No related tags found
No related merge requests found
...@@ -84,10 +84,11 @@ function filterGoal( ...@@ -84,10 +84,11 @@ function filterGoal(
export interface GoalTableProps { export interface GoalTableProps {
scope: string | undefined; scope: string | undefined;
failed: boolean; failed: boolean;
onFilter: (goals: number, total: number) => void;
} }
export function GoalTable(props: GoalTableProps): JSX.Element { export function GoalTable(props: GoalTableProps): JSX.Element {
const { scope, failed } = props; const { scope, failed, onFilter } = props;
const model = States.useSyncArrayModel(WP.goals); const model = States.useSyncArrayModel(WP.goals);
const [_, updateAstSelection] = States.useSelection(); const [_, updateAstSelection] = States.useSelection();
const [wpoSelection, setWpoSelection] = React.useState(WP.goalDefault); const [wpoSelection, setWpoSelection] = React.useState(WP.goalDefault);
...@@ -106,7 +107,10 @@ export function GoalTable(props: GoalTableProps): JSX.Element { ...@@ -106,7 +107,10 @@ export function GoalTable(props: GoalTableProps): JSX.Element {
} else { } else {
model.setFilter(); model.setFilter();
} }
}, [model, scope, failed]); const goals = model.getRowCount();
const total = model.getTotalRowCount();
onFilter(goals, total);
}, [model, scope, failed, onFilter]);
return ( return (
<Table <Table
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
import React from 'react'; import React from 'react';
import * as Dome from 'dome'; import * as Dome from 'dome';
import { Label } from 'dome/controls/labels';
import { IconButton } from 'dome/controls/buttons'; import { IconButton } from 'dome/controls/buttons';
import * as Ivette from 'ivette'; import * as Ivette from 'ivette';
import * as States from 'frama-c/states'; import * as States from 'frama-c/states';
...@@ -40,18 +41,27 @@ function WPGoals(): JSX.Element { ...@@ -40,18 +41,27 @@ function WPGoals(): JSX.Element {
const [scoped, flipScoped] = Dome.useFlipSettings('frama-c.wp.goals.scoped'); const [scoped, flipScoped] = Dome.useFlipSettings('frama-c.wp.goals.scoped');
const [failed, flipFailed] = Dome.useFlipSettings('frama-c.wp.goals.failed'); const [failed, flipFailed] = Dome.useFlipSettings('frama-c.wp.goals.failed');
const [selection] = States.useSelection(); const [selection] = States.useSelection();
const [goals,setGoals] = React.useState(0);
const [total,setTotal] = React.useState(0);
const onFilter = React.useCallback((goals, total) => {
setGoals(goals);
setTotal(total);
}, [setGoals, setTotal]);
const fct = selection?.current?.fct; const fct = selection?.current?.fct;
const scope = scoped ? fct : undefined; const scope = scoped ? fct : undefined;
return ( return (
<> <>
<Ivette.TitleBar> <Ivette.TitleBar>
<Label display={goals < total}>
{goals} / {total}
</Label>
<IconButton icon='COMPONENT' title='Current Scope Only' <IconButton icon='COMPONENT' title='Current Scope Only'
enabled={!!fct} enabled={!!fct}
selected={scoped} onClick={flipScoped} /> selected={scoped} onClick={flipScoped} />
<IconButton icon='CIRC.QUESTION' title='Unresolved Goals Only' <IconButton icon='CIRC.QUESTION' title='Unresolved Goals Only'
selected={failed} onClick={flipFailed} /> selected={failed} onClick={flipFailed} />
</Ivette.TitleBar> </Ivette.TitleBar>
<GoalTable scope={scope} failed={failed} /> <GoalTable scope={scope} failed={failed} onFilter={onFilter} />
</> </>
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment