mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-14 10:19:51 +00:00
fix(customHomePage): fixes after design review of hierarchy view (#14194)
This commit is contained in:
parent
63ad2d06d2
commit
9b8ea4b309
@ -15,6 +15,7 @@ interface Props {
|
|||||||
subtitle?: string;
|
subtitle?: string;
|
||||||
onUpsert: () => void;
|
onUpsert: () => void;
|
||||||
width?: string;
|
width?: string;
|
||||||
|
maxWidth?: string;
|
||||||
submitButtonProps?: Partial<ModalButton>;
|
submitButtonProps?: Partial<ModalButton>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ export default function BaseModuleModal({
|
|||||||
children,
|
children,
|
||||||
onUpsert,
|
onUpsert,
|
||||||
width,
|
width,
|
||||||
|
maxWidth,
|
||||||
submitButtonProps,
|
submitButtonProps,
|
||||||
}: React.PropsWithChildren<Props>) {
|
}: React.PropsWithChildren<Props>) {
|
||||||
const {
|
const {
|
||||||
@ -57,7 +59,7 @@ export default function BaseModuleModal({
|
|||||||
maskClosable={false} // to avoid accidental clicks that closes the modal
|
maskClosable={false} // to avoid accidental clicks that closes the modal
|
||||||
bodyStyle={modalBodyStyles}
|
bodyStyle={modalBodyStyles}
|
||||||
width={width || '90%'}
|
width={width || '90%'}
|
||||||
style={{ maxWidth: 1100 }}
|
style={{ maxWidth: maxWidth ?? 1100 }}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
@ -67,6 +67,7 @@ export default function HierarchyViewModal() {
|
|||||||
title={`${isEditing ? 'Edit' : 'Add'} Hierarchy View`}
|
title={`${isEditing ? 'Edit' : 'Add'} Hierarchy View`}
|
||||||
subtitle="Create a widget by selecting assets and information that will be shown to your users"
|
subtitle="Create a widget by selecting assets and information that will be shown to your users"
|
||||||
onUpsert={handleUpsertAssetCollectionModule}
|
onUpsert={handleUpsertAssetCollectionModule}
|
||||||
|
maxWidth="900px"
|
||||||
>
|
>
|
||||||
<Form form={form} initialValues={initialFormState}>
|
<Form form={form} initialValues={initialFormState}>
|
||||||
<HierarchyFormContextProvider initialValues={initialFormState}>
|
<HierarchyFormContextProvider initialValues={initialFormState}>
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const DepthMarginContainer = styled.div<{ $depth: number }>`
|
const DepthMarginContainer = styled.div<{ $depth: number }>`
|
||||||
margin-left: calc(8px * ${(props) => props.$depth});
|
margin-left: calc(16px * ${(props) => props.$depth});
|
||||||
`;
|
`;
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@ -42,6 +42,7 @@ export default function TreeNodeRenderer({ node, depth }: Props) {
|
|||||||
getHasSelectedChildren,
|
getHasSelectedChildren,
|
||||||
select,
|
select,
|
||||||
explicitlySelectChildren,
|
explicitlySelectChildren,
|
||||||
|
enableIntermediateSelectState,
|
||||||
toggleSelected,
|
toggleSelected,
|
||||||
getIsChildrenLoading,
|
getIsChildrenLoading,
|
||||||
getNumberOfNotLoadedChildren,
|
getNumberOfNotLoadedChildren,
|
||||||
@ -55,6 +56,10 @@ export default function TreeNodeRenderer({ node, depth }: Props) {
|
|||||||
const isSelectable = useMemo(() => getIsSelectable(node), [node, getIsSelectable]);
|
const isSelectable = useMemo(() => getIsSelectable(node), [node, getIsSelectable]);
|
||||||
const isSelected = useMemo(() => getIsSelected(node), [node, getIsSelected]);
|
const isSelected = useMemo(() => getIsSelected(node), [node, getIsSelected]);
|
||||||
const hasSelectedChildren = useMemo(() => getHasSelectedChildren(node), [node, getHasSelectedChildren]);
|
const hasSelectedChildren = useMemo(() => getHasSelectedChildren(node), [node, getHasSelectedChildren]);
|
||||||
|
const isIntermediatelySelected = useMemo(
|
||||||
|
() => !isSelected && hasSelectedChildren && !!enableIntermediateSelectState,
|
||||||
|
[isSelected, hasSelectedChildren, enableIntermediateSelectState],
|
||||||
|
);
|
||||||
|
|
||||||
const isChildrenLoading = useMemo(() => getIsChildrenLoading(node), [node, getIsChildrenLoading]);
|
const isChildrenLoading = useMemo(() => getIsChildrenLoading(node), [node, getIsChildrenLoading]);
|
||||||
|
|
||||||
@ -107,7 +112,7 @@ export default function TreeNodeRenderer({ node, depth }: Props) {
|
|||||||
<Checkbox
|
<Checkbox
|
||||||
isChecked={isSelected}
|
isChecked={isSelected}
|
||||||
setIsChecked={() => toggleSelected(node)}
|
setIsChecked={() => toggleSelected(node)}
|
||||||
isIntermediate={!isSelected && hasSelectedChildren}
|
isIntermediate={isIntermediatelySelected}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@ -127,8 +132,8 @@ export default function TreeNodeRenderer({ node, depth }: Props) {
|
|||||||
<Row>
|
<Row>
|
||||||
<DepthMargin depth={depth + 1} />
|
<DepthMargin depth={depth + 1} />
|
||||||
<ExpandToggler expandable={false} />
|
<ExpandToggler expandable={false} />
|
||||||
<Button onClick={() => loadChildren(node)} variant="link">
|
<Button onClick={() => loadChildren(node)} variant="link" color="gray">
|
||||||
Load {maxNumberOfChildrenToLoad} more
|
Show {maxNumberOfChildrenToLoad} more
|
||||||
</Button>
|
</Button>
|
||||||
</Row>
|
</Row>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -25,6 +25,7 @@ export default function TreeViewContextProvider({
|
|||||||
explicitlyUnselectChildren,
|
explicitlyUnselectChildren,
|
||||||
explicitlySelectParent,
|
explicitlySelectParent,
|
||||||
explicitlyUnselectParent,
|
explicitlyUnselectParent,
|
||||||
|
enableIntermediateSelectState,
|
||||||
numberOfChildrenToLoad = DEFAULT_NUMBER_OF_CHILDREN_TO_LOAD,
|
numberOfChildrenToLoad = DEFAULT_NUMBER_OF_CHILDREN_TO_LOAD,
|
||||||
}: React.PropsWithChildren<TreeViewContextProviderProps>) {
|
}: React.PropsWithChildren<TreeViewContextProviderProps>) {
|
||||||
const [internalExpandedValues, setInternalExpandedValues] = useState<string[]>(expandedValues ?? []);
|
const [internalExpandedValues, setInternalExpandedValues] = useState<string[]>(expandedValues ?? []);
|
||||||
@ -261,6 +262,7 @@ export default function TreeViewContextProvider({
|
|||||||
explicitlyUnselectChildren,
|
explicitlyUnselectChildren,
|
||||||
explicitlySelectParent,
|
explicitlySelectParent,
|
||||||
explicitlyUnselectParent,
|
explicitlyUnselectParent,
|
||||||
|
enableIntermediateSelectState,
|
||||||
|
|
||||||
// Async loading of children
|
// Async loading of children
|
||||||
getIsChildrenLoading,
|
getIsChildrenLoading,
|
||||||
|
|||||||
@ -51,6 +51,7 @@ export interface TreeViewContextType {
|
|||||||
explicitlyUnselectChildren?: boolean;
|
explicitlyUnselectChildren?: boolean;
|
||||||
explicitlySelectParent?: boolean;
|
explicitlySelectParent?: boolean;
|
||||||
explicitlyUnselectParent?: boolean;
|
explicitlyUnselectParent?: boolean;
|
||||||
|
enableIntermediateSelectState?: boolean;
|
||||||
|
|
||||||
// Async loading of children
|
// Async loading of children
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
@ -91,6 +92,8 @@ export interface TreeViewContextProviderProps {
|
|||||||
explicitlySelectParent?: boolean;
|
explicitlySelectParent?: boolean;
|
||||||
// If enabled it prevents unselecting of parent if any its children were unselected
|
// If enabled it prevents unselecting of parent if any its children were unselected
|
||||||
explicitlyUnselectParent?: boolean;
|
explicitlyUnselectParent?: boolean;
|
||||||
|
// If enabled it shows intermediate state of checkbox when the current node is not selected but it has selected nested nodes
|
||||||
|
enableIntermediateSelectState?: boolean;
|
||||||
|
|
||||||
// Optional custom renderer of nodes
|
// Optional custom renderer of nodes
|
||||||
renderNodeLabel?: (props: TreeNodeProps) => React.ReactNode;
|
renderNodeLabel?: (props: TreeNodeProps) => React.ReactNode;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user