Skip to content
Snippets Groups Projects
Commit 43eeab58 authored by Allan Blanchard's avatar Allan Blanchard
Browse files

[ivette/wp] first basic GUI

parent c71f76b1
No related branches found
No related tags found
No related merge requests found
...@@ -152,7 +152,7 @@ export const getAvailableProvers: Server.GetRequest<null,prover[]>= getAvailable ...@@ -152,7 +152,7 @@ export const getAvailableProvers: Server.GetRequest<null,prover[]>= getAvailable
/** Data for array rows [`goals`](#goals) */ /** Data for array rows [`goals`](#goals) */
export interface goalsData { export interface goalsData {
/** Entry identifier. */ /** Entry identifier. */
wpo: Json.key<'#wpo'>; wpo: goal;
/** Property Marker */ /** Property Marker */
property: marker; property: marker;
/** Informal name */ /** Informal name */
...@@ -178,7 +178,7 @@ export interface goalsData { ...@@ -178,7 +178,7 @@ export interface goalsData {
/** Decoder for `goalsData` */ /** Decoder for `goalsData` */
export const jGoalsData: Json.Decoder<goalsData> = export const jGoalsData: Json.Decoder<goalsData> =
Json.jObject({ Json.jObject({
wpo: Json.jKey<'#wpo'>('#wpo'), wpo: jGoal,
property: jMarker, property: jMarker,
name: Json.jString, name: Json.jString,
fct: Json.jOption(jFct), fct: Json.jOption(jFct),
...@@ -194,10 +194,10 @@ export const jGoalsData: Json.Decoder<goalsData> = ...@@ -194,10 +194,10 @@ export const jGoalsData: Json.Decoder<goalsData> =
/** Natural order for `goalsData` */ /** Natural order for `goalsData` */
export const byGoalsData: Compare.Order<goalsData> = export const byGoalsData: Compare.Order<goalsData> =
Compare.byFields Compare.byFields
<{ wpo: Json.key<'#wpo'>, property: marker, name: string, fct?: fct, <{ wpo: goal, property: marker, name: string, fct?: fct, bhv?: string,
bhv?: string, thy?: string, smoke: boolean, passed: boolean, thy?: string, smoke: boolean, passed: boolean, stats: stats,
stats: stats, script?: string, saved: boolean }>({ script?: string, saved: boolean }>({
wpo: Compare.string, wpo: byGoal,
property: byMarker, property: byMarker,
name: Compare.string, name: Compare.string,
fct: Compare.defined(byFct), fct: Compare.defined(byFct),
...@@ -227,15 +227,14 @@ export const reloadGoals: Server.GetRequest<null,null>= reloadGoals_internal; ...@@ -227,15 +227,14 @@ export const reloadGoals: Server.GetRequest<null,null>= reloadGoals_internal;
const fetchGoals_internal: Server.GetRequest< const fetchGoals_internal: Server.GetRequest<
number, number,
{ reload: boolean, removed: Json.key<'#wpo'>[], updated: goalsData[], { reload: boolean, removed: goal[], updated: goalsData[], pending: number }
pending: number }
> = { > = {
kind: Server.RqKind.GET, kind: Server.RqKind.GET,
name: 'plugins.wp.fetchGoals', name: 'plugins.wp.fetchGoals',
input: Json.jNumber, input: Json.jNumber,
output: Json.jObject({ output: Json.jObject({
reload: Json.jBoolean, reload: Json.jBoolean,
removed: Json.jArray(Json.jKey<'#wpo'>('#wpo')), removed: Json.jArray(jGoal),
updated: Json.jArray(jGoalsData), updated: Json.jArray(jGoalsData),
pending: Json.jNumber, pending: Json.jNumber,
}), }),
...@@ -244,11 +243,10 @@ const fetchGoals_internal: Server.GetRequest< ...@@ -244,11 +243,10 @@ const fetchGoals_internal: Server.GetRequest<
/** Data fetcher for array [`goals`](#goals) */ /** Data fetcher for array [`goals`](#goals) */
export const fetchGoals: Server.GetRequest< export const fetchGoals: Server.GetRequest<
number, number,
{ reload: boolean, removed: Json.key<'#wpo'>[], updated: goalsData[], { reload: boolean, removed: goal[], updated: goalsData[], pending: number }
pending: number }
>= fetchGoals_internal; >= fetchGoals_internal;
const goals_internal: State.Array<Json.key<'#wpo'>,goalsData> = { const goals_internal: State.Array<goal,goalsData> = {
name: 'plugins.wp.goals', name: 'plugins.wp.goals',
getkey: ((d:goalsData) => d.wpo), getkey: ((d:goalsData) => d.wpo),
signal: signalGoals, signal: signalGoals,
...@@ -257,13 +255,13 @@ const goals_internal: State.Array<Json.key<'#wpo'>,goalsData> = { ...@@ -257,13 +255,13 @@ const goals_internal: State.Array<Json.key<'#wpo'>,goalsData> = {
order: byGoalsData, order: byGoalsData,
}; };
/** Generated Goals */ /** Generated Goals */
export const goals: State.Array<Json.key<'#wpo'>,goalsData> = goals_internal; export const goals: State.Array<goal,goalsData> = goals_internal;
/** Default value for `goalsData` */ /** Default value for `goalsData` */
export const goalsDataDefault: goalsData = export const goalsDataDefault: goalsData =
{ wpo: Json.jKey<'#wpo'>('#wpo')(''), property: markerDefault, name: '', { wpo: goalDefault, property: markerDefault, name: '', fct: undefined,
fct: undefined, bhv: undefined, thy: undefined, smoke: false, bhv: undefined, thy: undefined, smoke: false, passed: false,
passed: false, stats: statsDefault, script: undefined, saved: false }; stats: statsDefault, script: undefined, saved: false };
/** Proof Server Activity */ /** Proof Server Activity */
export const serverActivity: Server.Signal = { export const serverActivity: Server.Signal = {
......
...@@ -21,23 +21,55 @@ ...@@ -21,23 +21,55 @@
/* ************************************************************************ */ /* ************************************************************************ */
import React from 'react'; import React from 'react';
import { Table, Column } from 'dome/table/views'; import { Icon } from 'dome/controls/icons';
import { Table, Column, Renderer } from 'dome/table/views';
import * as Ivette from 'ivette'; import * as Ivette from 'ivette';
import * as States from 'frama-c/states'; import * as States from 'frama-c/states';
import * as WP from 'frama-c/plugins/wp/api'; import * as WP from 'frama-c/plugins/wp/api';
const renderPassed: Renderer<boolean> =
(passed: boolean): JSX.Element =>
(<Icon
id={passed ? 'CIRC.CHECK' : 'CIRC.QUESTION'}
fill={passed ? `var(--positive-button-color)` : `var(--negative-button-color)`}
/>);
function WPGoals(): JSX.Element { function WPGoals(): JSX.Element {
const model = States.useSyncArrayModel(WP.goals); const model = States.useSyncArrayModel(WP.goals);
// TODO: from AST selection, find WPO
const [_astSelection, updateAstSelection] = States.useSelection();
const [wpoSelection, setWpoSelection] = React.useState(WP.goalDefault);
const onWpoSelection = React.useCallback(
({ wpo, property: marker, fct }: WP.goalsData) => {
const location = { fct, marker };
updateAstSelection({ location });
setWpoSelection(wpo);
}, [updateAstSelection],
);
return ( return (
<Table model={model} settings='wp.goals'> <Table
model={model}
settings='wp.goals'
onSelection={onWpoSelection}
selection={wpoSelection}
>
<Column id='fct' label='Function' />
<Column id='name' label='Names' /> <Column id='name' label='Names' />
<Column
id='passed'
label='Success'
render={renderPassed}
/>
</Table> </Table>
); );
} }
Ivette.registerComponent({ Ivette.registerComponent({
id: 'frama-c.plugins.wp.vcs', id: 'frama-c.plugins.wp.goals',
group: 'frama-c.plugins', group: 'frama-c.plugins',
rank: 10, rank: 10,
label: 'WP Goals', label: 'WP Goals',
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
import * as Ivette from 'ivette'; import * as Ivette from 'ivette';
import './vcs'; import './goals';
import './style.css'; import './style.css';
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -38,7 +38,7 @@ Ivette.registerView({ ...@@ -38,7 +38,7 @@ Ivette.registerView({
label: 'WP View', label: 'WP View',
layout: [ layout: [
['frama-c.astview', 'frama-c.astinfo'], ['frama-c.astview', 'frama-c.astinfo'],
'frama-c.plugins.wp.vcs', 'frama-c.plugins.wp.goals',
], ],
}); });
......
...@@ -214,7 +214,7 @@ let _ = S.register_array ~package ~name:"goals" ...@@ -214,7 +214,7 @@ let _ = S.register_array ~package ~name:"goals"
~descr:(Md.plain "Generated Goals") ~descr:(Md.plain "Generated Goals")
~key:(fun g -> g.Wpo.po_gid) ~key:(fun g -> g.Wpo.po_gid)
~keyName:"wpo" ~keyName:"wpo"
~keyType:(Jkey "wpo") ~keyType:Goal.jtype
~iter:Wpo.iter_on_goals ~iter:Wpo.iter_on_goals
~add_update_hook:Wpo.add_modified_hook ~add_update_hook:Wpo.add_modified_hook
~add_remove_hook:Wpo.add_removed_hook ~add_remove_hook:Wpo.add_removed_hook
......
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