diff --git a/doc/1.0.0-beta.3.org b/doc/1.0.0-beta.3.org index 492d9e5f0..e3283e113 100755 --- a/doc/1.0.0-beta.3.org +++ b/doc/1.0.0-beta.3.org @@ -38,19 +38,22 @@ TODO perf: only -1? -* TODO feat: Selected UI Controls 's name should = label +* DONE feat: Selected UI Controls 's name should = label +TODO fix +TODO update label to displayName -* TODO fix: import action: not need empty before! +TODO update ui +TODO fix find children +TODO pass bdd test + + +* TODO fix: import action: not need empty before! -* TODO solve ci sometimes fail: Actions->Install error -* TODO make ci pass in README -* TODO github->codecov should contain platform/assemble-space -* TODO Github: lanaguage remove Javascript @@ -132,6 +135,12 @@ TODO 延迟/预加载 monaco-editor +* TODO solve ci sometimes fail: Actions->Install error +* TODO make ci pass in README +* TODO github->codecov should contain platform/assemble-space +* TODO Github: lanaguage remove Javascript + + * TODO 更新logo for website, github org, production, loading diff --git a/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/selected_ui_controls/components/SelectedUIControls.res b/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/selected_ui_controls/components/SelectedUIControls.res index d1a660cfd..f764f6e1b 100755 --- a/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/selected_ui_controls/components/SelectedUIControls.res +++ b/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/selected_ui_controls/components/SelectedUIControls.res @@ -18,16 +18,55 @@ module Method = { ) } - let rec convertToTreeData = selectedUIControls => { + let _findLabel = ( + id, + selectedUIControlInspectorData: ElementAssembleStoreType.selectedUIControlInspectorData, + ): option => { + ( + HierachyUtils.findSelectedUIControlData( + None, + ( + (data: ElementAssembleStoreType.uiControlInspectorData) => data.id, + (data: ElementAssembleStoreType.uiControlInspectorData) => data.children, + ), + selectedUIControlInspectorData, + id, + ) + ->Meta3dCommonlib.OptionSt.getExn + ).specific + ->Meta3dCommonlib.ArraySt.find(({name}) => name == "label") + ->Meta3dCommonlib.OptionSt.map(({value}) => + SpecificUtils.getSpecificDataValue(value)->Obj.magic + ) + } + + let rec convertToTreeData = ( + service: service, + selectedUIControls, + selectedUIControlInspectorData: ElementAssembleStoreType.selectedUIControlInspectorData, + ) => { selectedUIControls ->Meta3dCommonlib.ListSt.map(( {id, protocolIconBase64, displayName, children}: ElementAssembleStoreType.uiControl, ): Tree.treeData => { { - title: displayName, + title: + {service.ui.buildText(. + ~_type=#default, + ~children={ + React.string( + _findLabel( + id, + selectedUIControlInspectorData, + )->Meta3dCommonlib.OptionSt.getWithDefault(displayName), + ) + }, + (), + )} + , key: id, icon: , - children: convertToTreeData(children), + children: convertToTreeData(service, children, selectedUIControlInspectorData), } }) ->Meta3dCommonlib.ListSt.toArray @@ -37,7 +76,9 @@ module Method = { [ ( { - title: "root", + title: { + React.string({j`root`}) + }, key: getRootKey(), children: allTreeData, icon: React.null, @@ -154,9 +195,13 @@ module Method = { let useSelector = ({apAssembleState, elementAssembleState}: AssembleSpaceStoreType.state) => { let {apInspectorData} = apAssembleState - let {selectedUIControls, parentUIControlId} = elementAssembleState + let { + selectedUIControls, + selectedUIControlInspectorData, + parentUIControlId, + } = elementAssembleState - (apInspectorData.isDebug, selectedUIControls) + (apInspectorData.isDebug, selectedUIControls, selectedUIControlInspectorData) } } @@ -179,7 +224,9 @@ let make = ( let (autoExpandParent, setAutoExpandParent) = service.react.useState(_ => true) let (isShowUIControls, setIsShowUIControls) = service.react.useState(_ => false) - let (isDebug, selectedUIControls) = service.react.useSelector(. Method.useSelector) + let (isDebug, selectedUIControls, selectedUIControlInspectorData) = service.react.useSelector(. + Method.useSelector, + ) <> @@ -201,7 +248,9 @@ let make = (
Obj.magic}> Method.convertToTreeData->Method.addRootTreeNode} + treeData={selectedUIControls + ->Method.convertToTreeData(service, _, selectedUIControlInspectorData) + ->Method.addRootTreeNode} expandedKeys onExpand={expandedKeysValue => Method.onExpand((setExpandedKeys, setAutoExpandParent), expandedKeysValue)} diff --git a/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/ui_control_Inspector/components/UIControlInspector.res b/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/ui_control_Inspector/components/UIControlInspector.res index 1f60d8392..85f5db1c3 100755 --- a/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/ui_control_Inspector/components/UIControlInspector.res +++ b/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/ui_control_Inspector/components/UIControlInspector.res @@ -372,13 +372,6 @@ module Method = { ) } - let getSpecificDataValue = (specificDataValue: ElementAssembleStoreType.specificDataValue) => { - switch specificDataValue { - | SpecicFieldDataValue(value) => value - // | _ => None - } - } - // let _getSpecificDataValueElementFieldValue = ( // specificDataValue: ElementAssembleStoreType.specificDataValue, // ) => { @@ -400,7 +393,7 @@ module Method = { | #string => SpecificUtils.convertValueToString(type_)} + value={SpecificUtils.getSpecificDataValue(value)->SpecificUtils.convertValueToString(type_)} onChange={e => { _setSpecificData( dispatch, @@ -450,17 +443,17 @@ module Method = { // preview=true // src={ - // getSpecificDataValue(value)->SpecificUtils.convertValueToString(type_)} + // SpecificUtils.getSpecificDataValue(value)->SpecificUtils.convertValueToString(type_)} // width=40 // height=40 // /> // }} - {getSpecificDataValue(value)->Obj.magic->Meta3dCommonlib.NullableSt.isNullable + {SpecificUtils.getSpecificDataValue(value)->Obj.magic->Meta3dCommonlib.NullableSt.isNullable ? React.null : SpecificUtils.convertValueToString(type_)} + src={SpecificUtils.getSpecificDataValue(value)->SpecificUtils.convertValueToString(type_)} width=40 height=40 />} @@ -470,7 +463,7 @@ module Method = { ? React.null : SpecificUtils.convertValueToString(type_)} + value={SpecificUtils.getSpecificDataValue(value)->SpecificUtils.convertValueToString(type_)} onChange={e => { ErrorUtils.swallowCatchedError(() => { _setSpecificData( @@ -499,7 +492,7 @@ module Method = { value->SpecificUtils.convertStringToValue(type_)->CommonType.SpecicFieldDataValue, type_, ), - getSpecificDataValue(value)->SpecificUtils.convertValueToString(type_), + SpecificUtils.getSpecificDataValue(value)->SpecificUtils.convertValueToString(type_), ["true", "false"], ) | #select => SelectUtils.buildSelectWithKeysAndWithoutEmpty(selectedValue => { @@ -510,25 +503,25 @@ module Method = { i, { "selected": selectedValue, - "data": (getSpecificDataValue(value)->Obj.magic)["data"], + "data": (SpecificUtils.getSpecificDataValue(value)->Obj.magic)["data"], } ->Obj.magic ->CommonType.SpecicFieldDataValue, type_, ) }, ( - getSpecificDataValue(value)->Obj.magic + SpecificUtils.getSpecificDataValue(value)->Obj.magic )["selected"], ( - getSpecificDataValue(value)->Obj.magic + SpecificUtils.getSpecificDataValue(value)->Obj.magic )["data"]->Meta3dCommonlib.ArraySt.map( valueData => valueData["key"], - ), (getSpecificDataValue(value)->Obj.magic)["data"]->Meta3dCommonlib.ArraySt.map( + ), (SpecificUtils.getSpecificDataValue(value)->Obj.magic)["data"]->Meta3dCommonlib.ArraySt.map( valueData => valueData["value"], )) | #number => Obj.magic} + value={SpecificUtils.getSpecificDataValue(value)->Obj.magic} step="0.0001" onChange={value => { _setSpecificData( diff --git a/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/utils/CustomDomUtils.res b/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/utils/CustomDomUtils.res index 08ea9135b..1e2c18372 100755 --- a/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/utils/CustomDomUtils.res +++ b/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/utils/CustomDomUtils.res @@ -52,7 +52,7 @@ module Method = { customs ->Meta3dCommonlib.ListSt.map(({name}: CommonType.custom): Tree.treeData => { { - title: name, + title: {React.string(name)}, key: name, icon: React.null, children: [], diff --git a/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/utils/SpecificUtils.res b/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/utils/SpecificUtils.res index 092055243..f183582af 100755 --- a/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/utils/SpecificUtils.res +++ b/platform/frontend/src/external_layer/ui/app/assemble_space/components/element_assemble/utils/SpecificUtils.res @@ -100,3 +100,10 @@ let convertStringToValue = ( valueStr, ) } + +let getSpecificDataValue = (specificDataValue: ElementAssembleStoreType.specificDataValue) => { + switch specificDataValue { + | SpecicFieldDataValue(value) => value + // | _ => None + } +} diff --git a/platform/frontend/src/external_layer/ui/app/utils/utils/externals/antd/Antd__Collapse.res b/platform/frontend/src/external_layer/ui/app/utils/utils/externals/antd/Antd__Collapse.res index 7abede557..b626d7759 100755 --- a/platform/frontend/src/external_layer/ui/app/utils/utils/externals/antd/Antd__Collapse.res +++ b/platform/frontend/src/external_layer/ui/app/utils/utils/externals/antd/Antd__Collapse.res @@ -10,9 +10,6 @@ external make: ( module Panel = { @module("antd") @scope("Collapse") @react.component - external make: ( - ~header: string=?, - ~key: string=?, - ~children: React.element=?, - ) => React.element = "Panel" + external make: (~header: string=?, ~key: string=?, ~children: React.element=?) => React.element = + "Panel" } diff --git a/platform/frontend/src/external_layer/ui/app/utils/utils/externals/antd/Antd__Tree.res b/platform/frontend/src/external_layer/ui/app/utils/utils/externals/antd/Antd__Tree.res index fb5c371e3..119b251b5 100755 --- a/platform/frontend/src/external_layer/ui/app/utils/utils/externals/antd/Antd__Tree.res +++ b/platform/frontend/src/external_layer/ui/app/utils/utils/externals/antd/Antd__Tree.res @@ -3,7 +3,7 @@ type key = string type ref type rec treeData = { - title: string, + title: React.element, key: key, // icon: Js.Nullable.t, icon: React.element, diff --git a/platform/frontend/test/features/selectedUIControls.feature b/platform/frontend/test/features/selectedUIControls.feature new file mode 100644 index 000000000..b65631b10 --- /dev/null +++ b/platform/frontend/test/features/selectedUIControls.feature @@ -0,0 +1,14 @@ +Feature: SelectedUIControls + As a SelectedUIControls + I want to select ui control + So that I can add them to view + + Background: prepare + Given prepare + + Scenario: convert to tree data + Given prepare selected ui controls + And prepare selected ui control inspector data + When convert to tree data + Then title should show label of selected ui control inspector data first then fallback to displayName of selected ui controls + diff --git a/platform/frontend/test/step-definitions/__snapshots__/selectedUIControls.steps.bs.js.snap b/platform/frontend/test/step-definitions/__snapshots__/selectedUIControls.steps.bs.js.snap new file mode 100644 index 000000000..75683a2e4 --- /dev/null +++ b/platform/frontend/test/step-definitions/__snapshots__/selectedUIControls.steps.bs.js.snap @@ -0,0 +1,269 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SelectedUIControls convert to tree data 1`] = ` +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + u1 + +
+
+
+
+
+
+
+
+
+
+
+
+
+`; + +exports[`UIControls show uiControls list 1`] = ` +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + u1 + +
+
+
+
+
+
+
+
+
+
+
+
+
+`; diff --git a/platform/frontend/test/step-definitions/selectedUIControls.steps.res b/platform/frontend/test/step-definitions/selectedUIControls.steps.res new file mode 100755 index 000000000..3013a9945 --- /dev/null +++ b/platform/frontend/test/step-definitions/selectedUIControls.steps.res @@ -0,0 +1,109 @@ +open Meta3dBsJestCucumber +open Cucumber +open Expect +open Operators + +open Sinon + +open Js.Promise + +let feature = loadFeature("./test/features/selectedUIControls.feature") + +defineFeature(feature, test => { + let sandbox = ref(Obj.magic(1)) + + let _prepare = given => { + given("prepare", () => { + sandbox := createSandbox() + }) + } + + test(."convert to tree data", ({given, \"when", \"and", then}) => { + let id1 = "i1" + let id2 = "i2" + let displayName2 = "d2" + let label1 = "label1" + let result = ref(Obj.magic(1)) + let selectedUIControls = ref(Obj.magic(1)) + let selectedUIControlInspectorData = ref(Obj.magic(1)) + let useSelectorStub = ref(Obj.magic(1)) + + _prepare(given) + + given( + "prepare selected ui controls", + () => { + selectedUIControls := + list{ + SelectedUIControlsTool.buildSelectedUIControl( + ~children=list{ + SelectedUIControlsTool.buildSelectedUIControl( + ~displayName=displayName2, + ~children=list{}, + ~id=id2, + (), + ), + }, + ~id=id1, + (), + ), + } + }, + ) + + \"and"( + "prepare selected ui control inspector data", + () => { + selectedUIControlInspectorData := + list{ + UIControlInspectorTool.buildUIControlInspectorData( + ~specific=[ + UIControlInspectorTool.buildSpecific( + ~name="label", + ~type_=#string, + ~value=label1->Obj.magic->CommonType.SpecicFieldDataValue, + (), + ), + ], + ~id=id1, + ~children=list{UIControlInspectorTool.buildUIControlInspectorData(~id=id2, ())}, + (), + ), + } + }, + ) + + \"when"( + "convert to tree data", + () => { + result := + SelectedUIControlsTool.convertToTreeData( + ServiceTool.build(~sandbox, ()), + selectedUIControls.contents, + selectedUIControlInspectorData.contents, + ) + }, + ) + + then( + "title should show label of selected ui control inspector data first then fallback to displayName of selected ui controls", + () => { + ( + result.contents->Meta3dCommonlib.ArraySt.length, + (result.contents->Meta3dCommonlib.ArraySt.getExn(0): Antd.Tree.treeData).title + ->Obj.magic + ->Js.Json.stringify + ->Js.String.includes(label1, _), + ( + ( + result.contents->Meta3dCommonlib.ArraySt.getExn(0): Antd.Tree.treeData + ).children->Meta3dCommonlib.ArraySt.getExn(0): Antd.Tree.treeData + ).title + ->Obj.magic + ->Js.Json.stringify + ->Js.String.includes(displayName2, _), + )->expect == (1, true, true) + }, + ) + }) +}) diff --git a/platform/frontend/test/tool/SelectedUIControlsTool.res b/platform/frontend/test/tool/SelectedUIControlsTool.res index 0243b2cc9..45b8554ce 100755 --- a/platform/frontend/test/tool/SelectedUIControlsTool.res +++ b/platform/frontend/test/tool/SelectedUIControlsTool.res @@ -55,3 +55,5 @@ let buildSelectedUIControl = ( let useSelector = ({apAssembleState}: AssembleSpaceStoreType.state) => SelectedUIControls.Method.useSelector + +let convertToTreeData = SelectedUIControls.Method.convertToTreeData \ No newline at end of file diff --git a/protocols/contribute_protocols/meta3d-ui-control-asset-protocol/package.json b/protocols/contribute_protocols/meta3d-ui-control-asset-protocol/package.json index f077c2553..c53f4a791 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-asset-protocol/package.json +++ b/protocols/contribute_protocols/meta3d-ui-control-asset-protocol/package.json @@ -1,6 +1,6 @@ { "name": "meta3d-ui-control-asset-protocol", - "version": "1.0.0-beta.2", + "version": "1.0.0-beta.2.1", "displayName": "资产", "publisher": "meta3d", "author": "Meta3D", diff --git a/protocols/contribute_protocols/meta3d-ui-control-asset-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-asset-protocol/src/Config.ts index 9e1871b62..9372cdbe9 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-asset-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-asset-protocol/src/Config.ts @@ -12,7 +12,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "Asset" + value: "资产" }, { name: "image", diff --git a/protocols/contribute_protocols/meta3d-ui-control-button-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-button-protocol/src/Config.ts index e58524b24..d3c26375d 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-button-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-button-protocol/src/Config.ts @@ -16,7 +16,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "Button##" + _generateUniqueId() + value: "按钮##" + _generateUniqueId() } ] diff --git a/protocols/contribute_protocols/meta3d-ui-control-collapsing-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-collapsing-protocol/src/Config.ts index a6336a069..863c7ead5 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-collapsing-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-collapsing-protocol/src/Config.ts @@ -16,7 +16,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "Collapsing##" + _generateUniqueId() + value: "折叠面板##" + _generateUniqueId() }, { name: "isOpen", diff --git a/protocols/contribute_protocols/meta3d-ui-control-image-button-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-image-button-protocol/src/Config.ts index efafa5320..778eea25e 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-image-button-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-image-button-protocol/src/Config.ts @@ -16,7 +16,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "Image Button##" + _generateUniqueId() + value: "图片按钮##" + _generateUniqueId() }, { name: "image", diff --git a/protocols/contribute_protocols/meta3d-ui-control-input-float3-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-input-float3-protocol/src/Config.ts index 2fac8f083..16068748d 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-input-float3-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-input-float3-protocol/src/Config.ts @@ -16,7 +16,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "InputFloat3##" + _generateUniqueId() + value: "数字输入框##" + _generateUniqueId() }, { name: "step", diff --git a/protocols/contribute_protocols/meta3d-ui-control-input-text-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-input-text-protocol/src/Config.ts index 732a8048d..f3faba6da 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-input-text-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-input-text-protocol/src/Config.ts @@ -16,7 +16,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "InputText##" + _generateUniqueId() + value: "文字输入框##" + _generateUniqueId() }, { name: "maxLength", diff --git a/protocols/contribute_protocols/meta3d-ui-control-menu-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-menu-protocol/src/Config.ts index ce3c768ef..bb3a470cb 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-menu-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-menu-protocol/src/Config.ts @@ -14,7 +14,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "Menu##" + _generateUniqueId() + value: "菜单栏##" + _generateUniqueId() }, { name: "items", diff --git a/protocols/contribute_protocols/meta3d-ui-control-switch-button-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-switch-button-protocol/src/Config.ts index 0fcaf475d..1538b2162 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-switch-button-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-switch-button-protocol/src/Config.ts @@ -16,7 +16,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "SwitchButton##" + _generateUniqueId() + value: "切换按钮##" + _generateUniqueId() }, { name: "image1", diff --git a/protocols/contribute_protocols/meta3d-ui-control-tree-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-tree-protocol/src/Config.ts index a77752682..dd5c0a036 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-tree-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-tree-protocol/src/Config.ts @@ -16,7 +16,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "Tree##" + _generateUniqueId() + value: "树##" + _generateUniqueId() }, { name: "rootNodeLabel", diff --git a/protocols/contribute_protocols/meta3d-ui-control-window-protocol/src/Config.ts b/protocols/contribute_protocols/meta3d-ui-control-window-protocol/src/Config.ts index eea397ea8..20b52f444 100755 --- a/protocols/contribute_protocols/meta3d-ui-control-window-protocol/src/Config.ts +++ b/protocols/contribute_protocols/meta3d-ui-control-window-protocol/src/Config.ts @@ -16,7 +16,7 @@ export let getUIControlSpecificDataFields: getUIControlSpecificDataFieldsMeta3D { name: "label", type_: "string", - value: "Window##" + _generateUniqueId() + value: "窗口##" + _generateUniqueId() }, { name: "flag",