mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 07:46:00 +00:00
macro app object refactor
This commit is contained in:
@@ -29,7 +29,15 @@ const GroupDiv = styled.div`
|
||||
font-weight: bold;
|
||||
`;
|
||||
|
||||
function AppObjectListItem({ AppObjectComponent, data, filter, onObjectClick, isExpandable, SubItems }) {
|
||||
function AppObjectListItem({
|
||||
AppObjectComponent,
|
||||
data,
|
||||
filter,
|
||||
onObjectClick,
|
||||
isExpandable,
|
||||
SubItems,
|
||||
getCommonProps,
|
||||
}) {
|
||||
const [isExpanded, setIsExpanded] = React.useState(false);
|
||||
|
||||
const expandable = data && isExpandable && isExpandable(data);
|
||||
@@ -44,7 +52,7 @@ function AppObjectListItem({ AppObjectComponent, data, filter, onObjectClick, is
|
||||
// const { matcher } = appobj;
|
||||
// if (matcher && !matcher(filter)) return null;
|
||||
|
||||
const commonProps = {
|
||||
let commonProps = {
|
||||
prefix: SubItems ? (
|
||||
<ExpandIconHolder2>
|
||||
{expandable ? <ExpandIcon isExpanded={isExpanded} /> : <ExpandIcon isBlank />}
|
||||
@@ -59,6 +67,10 @@ function AppObjectListItem({ AppObjectComponent, data, filter, onObjectClick, is
|
||||
commonProps.onClick3 = onObjectClick;
|
||||
}
|
||||
|
||||
if (getCommonProps) {
|
||||
commonProps = { ...commonProps, ...getCommonProps(data) };
|
||||
}
|
||||
|
||||
let res = <AppObjectComponent data={data} commonProps={commonProps} />;
|
||||
if (SubItems && isExpanded) {
|
||||
res = (
|
||||
@@ -98,6 +110,7 @@ export function AppObjectList({
|
||||
groupFunc = undefined,
|
||||
groupOrdered = undefined,
|
||||
isExpandable = undefined,
|
||||
getCommonProps = undefined,
|
||||
}) {
|
||||
const createComponent = (data) => (
|
||||
<AppObjectListItem
|
||||
@@ -108,6 +121,7 @@ export function AppObjectList({
|
||||
onObjectClick={onObjectClick}
|
||||
SubItems={SubItems}
|
||||
isExpandable={isExpandable}
|
||||
getCommonProps={getCommonProps}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user