forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransient.js
More file actions
79 lines (65 loc) · 2.41 KB
/
transient.js
File metadata and controls
79 lines (65 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { handleActions } from 'redux-actions';
import { set, del } from 'object-path-immutable';
export const transientReducer = handleActions(
{
// clear all the resolved args when restoring the history
// TODO: we shouldn't need to reset the resolved args for history
['restoreHistory']: (transientState) => set(transientState, 'resolvedArgs', {}),
['removeElements']: (transientState, { payload: { elementIds } }) => {
const { selectedToplevelNodes } = transientState;
return del(
{
...transientState,
selectedToplevelNodes: selectedToplevelNodes.filter((n) => elementIds.indexOf(n) < 0),
},
['resolvedArgs', elementIds]
);
},
['setFirstLoad']: (transientState, { payload }) => {
return set(transientState, 'isFirstLoad', Boolean(payload));
},
['setFullscreen']: (transientState, { payload }) => {
return set(transientState, 'fullscreen', Boolean(payload));
},
['setElementStats']: (transientState, { payload }) => {
return set(transientState, 'elementStats', payload);
},
['selectToplevelNodes']: (transientState, { payload }) => {
return {
...transientState,
selectedToplevelNodes: payload,
};
},
['setZoomScale']: (transientState, { payload }) => {
return {
...transientState,
zoomScale: payload || 1,
};
},
['setPage']: (transientState) => {
return { ...transientState, selectedToplevelNodes: [] };
},
['addPage']: (transientState) => {
return { ...transientState, selectedToplevelNodes: [] };
},
['duplicatePage']: (transientState) => {
return { ...transientState, selectedToplevelNodes: [] };
},
['setRefreshInterval']: (transientState, { payload }) => {
return { ...transientState, refresh: { interval: Number(payload) || 0 } };
},
['enableAutoplay']: (transientState, { payload }) => {
return set(transientState, 'autoplay.enabled', Boolean(payload) || false);
},
['setAutoplayInterval']: (transientState, { payload }) => {
return set(transientState, 'autoplay.interval', Number(payload) || 0);
},
},
{}
);