Skip to content

Commit

Permalink
feat(ViewCreator): default to resolve target if it's a reference
Browse files Browse the repository at this point in the history
  • Loading branch information
soofstad committed Oct 30, 2023
1 parent d056deb commit ddaf686
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"uiRecipes": [
{
"name": "Form",
"name": "Edit",
"type": "CORE:UiRecipe",
"plugin": "@development-framework/dm-core-plugins/form"
},
Expand Down
2 changes: 1 addition & 1 deletion example/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.4'

services:
dmss:
image: datamodelingtool.azurecr.io/dmss:v1.6.4
image: datamodelingtool.azurecr.io/dmss:v1.7.1
platform: linux/amd64
restart: unless-stopped
environment:
Expand Down
10 changes: 5 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
"@types/node": "^16.11.58",
"@types/react": "^18.2.8",
"@types/react-dom": "^18.2.7",
"@types/react-plotly.js": "^2.6.0",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.26",
"@types/react-plotly.js": "^2.6.0",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"@vitejs/plugin-react-swc": "^3.3.2",
"cross-env": "7.0.3",
"eslint": "^8.42.0",
"eslint-plugin-react": "^7.33.2",
"serve": "14.2.1",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vite-plugin-checker": "^0.6.1",
"vite-plugin-svgr": "^3.2.0",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.34.3",
"eslint-plugin-react": "^7.33.2",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3"
"vitest": "^0.34.3"
},
"scripts": {
"start": "cross-env REACT_APP_DM_JOB_URL=http://localhost:5001 vite",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TGenericObject,
useDocument,
} from '@development-framework/dm-core'
// @ts-ignore
import Plot from 'react-plotly.js'

const ESSPlotPlugin = (props: { document: TGenericObject }) => {
Expand Down
11 changes: 7 additions & 4 deletions packages/dm-core/src/components/ViewCreator/ViewCreator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,19 @@ export const ViewCreator = (props: TViewCreator): React.ReactElement => {
const [isLoading, setIsLoading] = useState<boolean>(true)
const [error, setError] = useState<Error>()
const [attribute, setAttribute] = useState<TAttribute>()
const [directAddress, setDirectAddress] = useState<string>(idReference)

const reference = getTarget(idReference, viewConfig)

useEffect(() => {
dmssAPI
.attributeGet({
address: reference,
resolve: props.viewConfig.resolve,
})
.then((response: AxiosResponse) => {
setAttribute(response.data)
setAttribute(response.data.attribute)
setDirectAddress(response.data.address)
})
.catch((error) => setError(error))
.finally(() => setIsLoading(false))
Expand All @@ -77,7 +80,7 @@ export const ViewCreator = (props: TViewCreator): React.ReactElement => {
if (isInlineRecipeViewConfig(viewConfig)) {
return (
<InlineRecipeView
idReference={reference}
idReference={directAddress}
type={attribute.attributeType}
viewConfig={viewConfig}
onOpen={onOpen}
Expand All @@ -89,7 +92,7 @@ export const ViewCreator = (props: TViewCreator): React.ReactElement => {
return (
<EntityView
type={attribute.attributeType}
idReference={reference}
idReference={directAddress}
recipeName={viewConfig.recipe}
onOpen={onOpen}
dimensions={attribute.dimensions}
Expand All @@ -98,7 +101,7 @@ export const ViewCreator = (props: TViewCreator): React.ReactElement => {
} else if (isViewConfig(viewConfig)) {
return (
<EntityView
idReference={reference}
idReference={directAddress}
type={attribute.attributeType}
onOpen={onOpen}
dimensions={attribute.dimensions}
Expand Down
1 change: 1 addition & 0 deletions packages/dm-core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export type TUserIdMapping = { userId: string; username: string }
export type TViewConfig = {
type: string
scope?: string
resolve?: boolean
label?: string
eds_icon?: string
roles?: string[]
Expand Down

0 comments on commit ddaf686

Please sign in to comment.