Skip to content

Commit 0811e5c

Browse files
committed
WIP: try out simple IconCard as presentation (todo move to shared package)
1 parent 8d1d76e commit 0811e5c

File tree

2 files changed

+36
-19
lines changed
  • packages/neos-ui-references-editor/src

2 files changed

+36
-19
lines changed

packages/neos-ui-references-editor/src/application/ReferencesEditor/index.tsx

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import React from 'react';
22
import {getReferencesSummary} from '../../infrastructure/http';
33
import {usePromise} from '@neos-project/framework-promise-react';
44
import {actions, selectors, useSelector} from '@neos-project/neos-ui-redux-store';
5-
import {discardChannel$, applyChannel$} from '@neos-project/neos-ui-sagas/src/UI/Inspector';
5+
import {applyChannel$, discardChannel$} from '@neos-project/neos-ui-sagas/src/UI/Inspector';
66
import {ErrorView} from '@neos-project/neos-ui-error';
77
import {HoverActions} from '../../presentation/HoverActions';
8-
import {ReferencesItem} from '../../presentation/ReferencesItem';
98
import {IReferences} from '../../domain';
109
import {Button} from '@neos-project/react-ui-components';
1110
import {useDispatch} from 'react-redux';
@@ -14,6 +13,7 @@ import {useLatestState} from '@neos-project/framework-observable-react';
1413
import {createState} from '@neos-project/framework-observable';
1514
import {Editor} from '../../domain/Editor/Editor';
1615
import {ReferencesTreeSecondaryEditor} from '../ReferencesTreeSecondaryEditor';
16+
import {IconCard} from "@neos-project/neos-ui-link-editor-core/src/presentation";
1717

1818
export const createReferencesEditor = () => (props) => {
1919
const workspaceName = useSelector(selectors.CR.Workspaces.personalWorkspaceNameSelector);
@@ -104,37 +104,53 @@ export const createReferencesEditor = () => (props) => {
104104

105105
const onDelete = React.useCallback((referenceTargetId: string) => editor$.update(editor => editor.withRemovedReference(referenceTargetId)), [editor$]);
106106

107-
if (editor.isLoading()) {
108-
return <div>Loading {editor.getLoadingReferencesCount()}...</div>;
109-
}
110-
111-
if (fetch__referencesSummary.error) {
112-
return <ErrorView error={fetch__referencesSummary.error} />;
113-
}
114-
115107
const openSecondaryEditor = () => {
116108
if (!dimension) {
117109
// TODO handle
118110
return;
119111
}
120-
props.renderSecondaryInspector('identifiersss', () =>
112+
props.renderSecondaryInspector('ReferencesTreeSecondaryEditor', () =>
121113
<ReferencesTreeSecondaryEditor
122114
workspaceName={workspaceName}
123115
dimensionValues={dimension}
116+
// todo
124117
startingPoint={'/<Neos.Neos:Sites>/'}
125118
editor$={editor$}
126-
/>)
119+
/>
120+
)
127121
}
128122

123+
if (fetch__referencesSummary.error) {
124+
return <ErrorView error={fetch__referencesSummary.error} />;
125+
}
126+
127+
// todo spin true?
129128
return (
130129
<>
131-
{Object.values(editor.getReferences()).map(reference => {
132-
return (
133-
<HoverActions key={reference.targetNodeId} onEdit={() => onEdit(reference.targetNodeId)} onDelete={() => onDelete(reference.targetNodeId)}>
134-
<ReferencesItem reference={reference} isDraggable={(fetch__referencesSummary.value?.references?.length ?? 0) > 1} />
135-
</HoverActions>
136-
);
137-
})}
130+
{
131+
editor.isLoading() ? new Array(editor.getLoadingReferencesCount()).fill(undefined).map(() => (
132+
<IconCard
133+
icon={'spinner'}
134+
title={`loading`}
135+
subTitle={`node://${props.nodeId}`}
136+
/>)) : Object.values(editor.getReferences()).map(reference => {
137+
return (
138+
reference.presentation
139+
? <HoverActions key={reference.targetNodeId} onEdit={() => onEdit(reference.targetNodeId)} onDelete={() => onDelete(reference.targetNodeId)}>
140+
<IconCard
141+
icon={reference.presentation.icon}
142+
title={reference.presentation.label}
143+
subTitle={reference.presentation.breadcrumbs.map(({label}) => label).join(' > ')}
144+
/>
145+
</HoverActions>
146+
: <IconCard
147+
icon={'spinner'}
148+
title={`loading`}
149+
subTitle={`node://${props.nodeId}`}
150+
/>
151+
);
152+
})
153+
}
138154
<Button onClick={openSecondaryEditor}>Neues Item</Button>
139155
{
140156
editor.isReferencePropertyEditingOpen() && <ReferencesPropertiesDialog editor$={editor$} />

packages/neos-ui-references-editor/src/presentation/ReferencesItem/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface ReferencesItemProps {
99
isDraggable?: boolean;
1010
}
1111

12+
// todo remove?
1213
export const ReferencesItem = (props: ReferencesItemProps) => {
1314
return (
1415
<div className={style.container}>

0 commit comments

Comments
 (0)