Skip to content
Snippets Groups Projects
Commit 0e55d011 authored by Loïc Correnson's avatar Loïc Correnson
Browse files

Merge branch 'fix/ivette/default-views' into 'master'

[Ivette] Fixes default view at first launch.

Closes #1412

See merge request frama-c/frama-c!4814
parents 6be52e81 6a0995e4
No related branches found
No related tags found
No related merge requests found
...@@ -29,73 +29,9 @@ ...@@ -29,73 +29,9 @@
@module ivette/display @module ivette/display
*/ */
import React from 'react'; import { LayoutPosition } from 'ivette';
import { VIEW, COMPONENT, LayoutPosition } from 'ivette';
import * as State from './state';
import * as Laboratory from './laboratory'; import * as Laboratory from './laboratory';
export interface ItemProps {
id: string;
selected?: boolean;
}
/**
A sidebar item for controlling an Ivette view.
*/
export function ViemItem(props: ItemProps): JSX.Element | null {
const { id, selected = false } = props;
const view = State.useElement(VIEW, id);
const state = Laboratory.useState();
if (!view) return null;
const status = Laboratory.getViewStatus(state, id);
return (
<Laboratory.ViewItem
view={view}
selected={selected}
{...status}
/>
);
}
/**
A sidebar item for controlling an Ivette component.
*/
export function ComponentItem(props: ItemProps): JSX.Element | null {
const { id, selected = false } = props;
const comp = State.useElement(COMPONENT, id);
const state = Laboratory.useState();
if (!comp) return null;
const status = Laboratory.getComponentStatus(state, id);
return (
<Laboratory.ComponentItem
comp={comp}
selected={selected}
{...status}
/>
);
}
export interface GroupItemsProps {
id: string;
selected?: string;
}
/**
A bundle of sidebar items for controlling an Ivette group of components.
*/
export function GroupItems(props: GroupItemsProps): JSX.Element | null {
const items =
State.useElements(COMPONENT)
.filter(Laboratory.inGroup(props))
.map(({ id }) => (
<ComponentItem
key={id}
id={id}
selected={id === props.selected} />
));
return <>{items}</>;
}
/** Switch display to specified view. */ /** Switch display to specified view. */
export function switchToView(id: string): void { export function switchToView(id: string): void {
Laboratory.switchToView(id); Laboratory.switchToView(id);
......
...@@ -620,8 +620,8 @@ function updateIndex(settings: LabSettings): void { ...@@ -620,8 +620,8 @@ function updateIndex(settings: LabSettings): void {
if (theTab) { if (theTab) {
applyTab(tabKeyOf(theTab.view, theTab.custom)); applyTab(tabKeyOf(theTab.view, theTab.custom));
} else { } else {
const console = VIEW.getElement('fc.kernel.console'); const views = VIEW.getElements();
if (console !== undefined) applyView(console); views.forEach(view => { if (view.defaultView) applyView(view); });
} }
setCurrentNone(); setCurrentNone();
} }
......
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