piral-dashboard
Advanced tools
Comparing version 0.10.0-pre.837 to 0.10.0-pre.838
@@ -1,5 +0,4 @@ | ||
import { Atom } from '@dbeining/react-atom'; | ||
import { GlobalState } from 'piral-core'; | ||
import { GlobalStateContext } from 'piral-core'; | ||
import { TileRegistration } from './types'; | ||
export declare function registerTile(ctx: Atom<GlobalState>, name: string, value: TileRegistration): void; | ||
export declare function unregisterTile(ctx: Atom<GlobalState>, name: string): void; | ||
export declare function registerTile(ctx: GlobalStateContext, name: string, value: TileRegistration): void; | ||
export declare function unregisterTile(ctx: GlobalStateContext, name: string): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_atom_1 = require("@dbeining/react-atom"); | ||
const piral_core_1 = require("piral-core"); | ||
function registerTile(ctx, name, value) { | ||
react_atom_1.swap(ctx, state => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { tiles: piral_core_1.withKey(state.registry.tiles, name, value) }) }))); | ||
ctx.dispatch(state => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { tiles: piral_core_1.withKey(state.registry.tiles, name, value) }) }))); | ||
} | ||
exports.registerTile = registerTile; | ||
function unregisterTile(ctx, name) { | ||
react_atom_1.swap(ctx, state => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { tiles: piral_core_1.withoutKey(state.registry.tiles, name) }) }))); | ||
ctx.dispatch(state => (Object.assign(Object.assign({}, state), { registry: Object.assign(Object.assign({}, state.registry), { tiles: piral_core_1.withoutKey(state.registry.tiles, name) }) }))); | ||
} | ||
exports.unregisterTile = unregisterTile; | ||
//# sourceMappingURL=actions.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const actions = require("./actions"); | ||
const react_atom_1 = require("@dbeining/react-atom"); | ||
const piral_core_1 = require("piral-core"); | ||
@@ -29,3 +28,3 @@ const default_1 = require("./default"); | ||
context.defineActions(actions); | ||
react_atom_1.swap(context.state, state => (Object.assign(Object.assign({}, state), { components: Object.assign(Object.assign({}, state.components), { DashboardTile: default_1.DefaultTile, DashboardContainer: default_1.DefaultContainer }), registry: Object.assign(Object.assign({}, state.registry), { tiles: getTiles(tiles, defaultPreferences) }) }))); | ||
context.dispatch(state => (Object.assign(Object.assign({}, state), { components: Object.assign(Object.assign({}, state.components), { DashboardTile: default_1.DefaultTile, DashboardContainer: default_1.DefaultContainer }), registry: Object.assign(Object.assign({}, state.registry), { tiles: getTiles(tiles, defaultPreferences) }) }))); | ||
return (api, target) => { | ||
@@ -32,0 +31,0 @@ const pilet = target.name; |
{ | ||
"name": "piral-dashboard", | ||
"version": "0.10.0-pre.837", | ||
"version": "0.10.0-pre.838", | ||
"description": "Plugin for creating a centralized dashboard in Piral.", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"piral-core": "^0.10.0-pre.837" | ||
"piral-core": "^0.10.0-pre.838" | ||
}, | ||
@@ -46,3 +46,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "5e8fd9a6f76c1505c459b18a5a06fcbeaa77f1a8" | ||
"gitHead": "5d2f55dafff3ceb751877958c5691dfbf995ae84" | ||
} |
import { Atom, deref } from '@dbeining/react-atom'; | ||
import { registerTile, unregisterTile } from './actions'; | ||
import { createActions, createListener } from 'piral-core'; | ||
@@ -13,3 +14,4 @@ describe('Dashboard Actions Module', () => { | ||
}); | ||
registerTile(state, 'foo', 10); | ||
const ctx = createActions(state, createListener({})); | ||
registerTile(ctx, 'foo', 10); | ||
expect(deref(state)).toEqual({ | ||
@@ -24,3 +26,3 @@ foo: 5, | ||
}); | ||
unregisterTile(state, 'foo'); | ||
unregisterTile(ctx, 'foo'); | ||
expect(deref(state)).toEqual({ | ||
@@ -27,0 +29,0 @@ foo: 5, |
@@ -1,7 +0,6 @@ | ||
import { Atom, swap } from '@dbeining/react-atom'; | ||
import { GlobalState, withKey, withoutKey } from 'piral-core'; | ||
import { withKey, withoutKey, GlobalStateContext } from 'piral-core'; | ||
import { TileRegistration } from './types'; | ||
export function registerTile(ctx: Atom<GlobalState>, name: string, value: TileRegistration) { | ||
swap(ctx, state => ({ | ||
export function registerTile(ctx: GlobalStateContext, name: string, value: TileRegistration) { | ||
ctx.dispatch(state => ({ | ||
...state, | ||
@@ -15,4 +14,4 @@ registry: { | ||
export function unregisterTile(ctx: Atom<GlobalState>, name: string) { | ||
swap(ctx, state => ({ | ||
export function unregisterTile(ctx: GlobalStateContext, name: string) { | ||
ctx.dispatch(state => ({ | ||
...state, | ||
@@ -19,0 +18,0 @@ registry: { |
@@ -1,2 +0,2 @@ | ||
import { Atom } from '@dbeining/react-atom'; | ||
import { Atom, swap } from '@dbeining/react-atom'; | ||
import { createElement, SFC } from 'react'; | ||
@@ -9,2 +9,3 @@ import { createDashboardApi } from './create'; | ||
function createMockContainer() { | ||
const state = Atom.of({}); | ||
return { | ||
@@ -16,3 +17,6 @@ context: { | ||
defineActions() {}, | ||
state: Atom.of({}), | ||
state, | ||
dispatch(update) { | ||
swap(state, update); | ||
}, | ||
} as any, | ||
@@ -19,0 +23,0 @@ api: {} as any, |
import * as actions from './actions'; | ||
import { ComponentType } from 'react'; | ||
import { swap } from '@dbeining/react-atom'; | ||
import { buildName, withApi, Extend, Dict } from 'piral-core'; | ||
@@ -66,3 +65,3 @@ import { DefaultTile, DefaultContainer } from './default'; | ||
swap(context.state, state => ({ | ||
context.dispatch(state => ({ | ||
...state, | ||
@@ -69,0 +68,0 @@ components: { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
704
32988