Skip to content

Commit

Permalink
fix(view renderer): unify detailed view rendering (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
thesophiaxu committed Dec 21, 2021
1 parent e4f0477 commit 84c6056
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ListItemText } from "@material-ui/core";
import React from "react";
import { unpad } from "unigraph-dev-common/lib/utils/entityUtils";
import { DynamicViewRenderer } from "../../global";

export const ViewItem: DynamicViewRenderer = ({data, callbacks}) => {
let unpadded: any = unpad(data);

return <React.Fragment>
<div onClick={() => window.newTab(window.layoutModel, {
type: 'tab',
config: {
uid: data?.uid,
type: data?.type?.['unigraph.id']
},
customTitle: true,
name: unpadded.name,
component: '/pages/library/object',
enableFloat: 'true'
})} style={{display: "contents"}}>
<ListItemText primary={unpadded.name}></ListItemText>
</div>
</React.Fragment>
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
import { ListItemText } from "@material-ui/core";
import React from "react";
import { useEffectOnce } from "react-use";
import { getRandomInt } from "unigraph-dev-common/lib/api/unigraph";
import { byElementIndex, unpad } from "unigraph-dev-common/lib/utils/entityUtils";
import { DynamicViewRenderer } from "../../global";
import { isJsonString } from "unigraph-dev-common/lib/utils/utils";
import { DynamicObjectListView } from "../ObjectView/DynamicObjectListView";

export const ViewItem: DynamicViewRenderer = ({data, callbacks}) => {
let unpadded: any = unpad(data);

return <React.Fragment>
<div onClick={() => window.newTab(window.layoutModel, {
type: 'tab',
config: isJsonString(unpadded?.props) ? JSON.parse(unpadded.props).config : {},
customTitle: true,
name: unpadded.name,
component: typeof unpadded.view === "string" ? unpadded.view : "/pages/" + data._value.view._value.uid,
enableFloat: 'true'
})} style={{display: "contents"}}>
<ListItemText primary={unpadded.name}></ListItemText>
</div>
</React.Fragment>
}

export const FavoriteBar = () => {

const [fav, setFav] = React.useState<any[]>([]);
Expand Down
2 changes: 1 addition & 1 deletion packages/unigraph-dev-explorer/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { pb_init } from './components/UnigraphCore/Pinboard';
import { ListObjectQuery, ListObjectView } from "./components/UnigraphCore/ListObjectView";
import { getRandomInt } from "unigraph-dev-common/lib/api/unigraph";
import { SubentityView } from "./components/UnigraphCore/SubentityView";
import { ViewItem } from "./components/UnigraphCore/FavoriteBar";
import { ViewItem } from "./components/ObjectView/ViewObjectView";

window.reloadCommands = () => {
const commandsState = window.unigraph.getState("registory/commands");
Expand Down

0 comments on commit 84c6056

Please sign in to comment.