mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* Playing around * This is getting interesting * Updates * Updated * Observable experiments * This is tricky * VizPanel panel renderer * New model progress * Maybe this could be something * Updated * Rename * updates * Updated * Query runners? not sure * Updated * updates * flex box layout starting to work * Testing * Tested an action * Parent context sort of working * Progress * Progress * Updated * Starting to work * Things are working * Scene list, nested scene demo * Progress on repeats * Moving things * Pretty big progress * More things working * Great progress * Progress * Name changing * Minor tweaks * Simplified sizing * Move toggleDirection to SceneFlexLayout * add feature flag (#50990) * removed new useObservable hook * Rename folder and feature toggle to scenes * Caching scenes so you can go back to another scene without having to re-query data * Fix issue with subs on re-mount * Fixing test * Added SceneCanvasText to play around with layout elements with size based on content * Scene: Edit mode and component edit wrapper that handles selection (#51078) * First step for scene variables * Started playing around with a scene edit mode * Better way to set component * Progress on edit mode * Update * Progress on edit mode * Progress on editor * Progress on editor * Updates * More working * Progress * Minor update * removed unnessary file * Moving things around * Updated * Making time range separate from time picker * minor rename of methods * The most basic variable start * Minor renames * Fixed interpolate issue if not found at closest level * An embryo of event model and url sync handling * Update url sync types * Removed unnessary any type arg Co-authored-by: Ryan McKinley <ryantxu@gmail.com> Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { SceneObjectBase } from './SceneObjectBase';
|
|
import { SceneObject, SceneObjectList, SceneObjectState } from './types';
|
|
|
|
interface TestSceneState extends SceneObjectState {
|
|
name?: string;
|
|
nested?: SceneObject<TestSceneState>;
|
|
children?: SceneObjectList;
|
|
actions?: SceneObjectList;
|
|
}
|
|
|
|
class TestScene extends SceneObjectBase<TestSceneState> {}
|
|
|
|
describe('SceneObject', () => {
|
|
it('Can clone', () => {
|
|
const scene = new TestScene({
|
|
nested: new TestScene({
|
|
name: 'nested',
|
|
}),
|
|
children: [
|
|
new TestScene({
|
|
name: 'layout child',
|
|
}),
|
|
],
|
|
});
|
|
|
|
scene.state.nested?.onMount();
|
|
|
|
const clone = scene.clone();
|
|
expect(clone).not.toBe(scene);
|
|
expect(clone.state.nested).not.toBe(scene.state.nested);
|
|
expect(clone.state.nested?.isMounted).toBe(undefined);
|
|
expect(clone.state.children![0]).not.toBe(scene.state.children![0]);
|
|
});
|
|
|
|
it('SceneObject should have parent when added to container', () => {
|
|
const scene = new TestScene({
|
|
nested: new TestScene({
|
|
name: 'nested',
|
|
}),
|
|
children: [
|
|
new TestScene({
|
|
name: 'layout child',
|
|
}),
|
|
],
|
|
actions: [
|
|
new TestScene({
|
|
name: 'layout child',
|
|
}),
|
|
],
|
|
});
|
|
|
|
expect(scene.parent).toBe(undefined);
|
|
expect(scene.state.nested?.parent).toBe(scene);
|
|
expect(scene.state.children![0].parent).toBe(scene);
|
|
expect(scene.state.actions![0].parent).toBe(scene);
|
|
});
|
|
|
|
it('Can clone with state change', () => {
|
|
const scene = new TestScene({
|
|
nested: new TestScene({
|
|
name: 'nested',
|
|
}),
|
|
});
|
|
|
|
const clone = scene.clone({ name: 'new name' });
|
|
expect(clone.state.name).toBe('new name');
|
|
});
|
|
});
|