mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Dispatch on node id convention as we don't carry around the node type information * place groups previously misplaced into its proper array * don't render (always invisible) groups, which are free of own contents
This commit is contained in:
parent
3fe5c954bf
commit
40cf0978ba
4 changed files with 29 additions and 6 deletions
|
@ -12,7 +12,7 @@ import { matrixToAngle, multiply, rotateZ, translate } from '../../lib/aeroelast
|
|||
import { arrayToMap, flatten, identity } from '../../lib/aeroelastic/functional';
|
||||
import { getLocalTransformMatrix } from '../../lib/aeroelastic/layout_functions';
|
||||
|
||||
const isGroupId = id => id.startsWith('group');
|
||||
export const isGroupId = id => id.startsWith('group');
|
||||
|
||||
const headerData = id =>
|
||||
isGroupId(id)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import React, { PureComponent } from 'react';
|
||||
import { ElementWrapper } from '../../element_wrapper';
|
||||
import { staticWorkpadPagePropTypes } from '../prop_types';
|
||||
import { isGroupId } from '../integration_utils';
|
||||
|
||||
export class StaticWorkpadPage extends PureComponent {
|
||||
static propTypes = staticWorkpadPagePropTypes;
|
||||
|
@ -23,9 +24,11 @@ export class StaticWorkpadPage extends PureComponent {
|
|||
data-shared-items-container
|
||||
style={{ ...pageStyle, ...animationStyle, height, width }}
|
||||
>
|
||||
{elements.map(element => (
|
||||
<ElementWrapper key={element.id} element={element} />
|
||||
))}
|
||||
{elements
|
||||
.filter(node => !isGroupId(node.id))
|
||||
.map(element => (
|
||||
<ElementWrapper key={element.id} element={element} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import { routerProvider } from '../../lib/router_provider';
|
|||
import { getDefaultPage } from '../defaults';
|
||||
import * as actions from '../actions/pages';
|
||||
import { getSelectedPageIndex } from '../selectors/workpad';
|
||||
import { isGroupId } from '../../components/workpad_page/integration_utils';
|
||||
|
||||
const setPageIndex = (workpadState, index) =>
|
||||
index < 0 || !workpadState.pages[index] || getSelectedPageIndex(workpadState) === index
|
||||
|
@ -36,8 +37,8 @@ function clonePage(page) {
|
|||
return {
|
||||
...page,
|
||||
id: getId('page'),
|
||||
groups: newNodes.filter(n => n.position.type === 'group'),
|
||||
elements: newNodes.filter(n => n.position.type !== 'group'),
|
||||
groups: newNodes.filter(n => isGroupId(n.id)),
|
||||
elements: newNodes.filter(n => !isGroupId(n.id)),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,25 @@ export function workpad(server) {
|
|||
|
||||
return savedObjectsClient
|
||||
.get(CANVAS_TYPE, id)
|
||||
.then(obj => {
|
||||
if (
|
||||
// not sure if we need to be this defensive
|
||||
obj.type === 'canvas-workpad' &&
|
||||
obj.attributes &&
|
||||
obj.attributes.pages &&
|
||||
obj.attributes.pages.length
|
||||
) {
|
||||
obj.attributes.pages.forEach(page => {
|
||||
const elements = (page.elements || []).filter(({ id }) => !id.startsWith('group'));
|
||||
const groups = (page.groups || []).concat(
|
||||
(page.elements || []).filter(({ id }) => id.startsWith('group'))
|
||||
);
|
||||
page.elements = elements;
|
||||
page.groups = groups;
|
||||
});
|
||||
}
|
||||
return obj;
|
||||
})
|
||||
.then(obj => ({ id: obj.id, ...obj.attributes }))
|
||||
.then(formatResponse)
|
||||
.catch(formatResponse);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue