feat(viewer): add property conflict test

This commit is contained in:
Bowen Tan 2022-11-07 17:43:03 +08:00
parent 107e7ada8f
commit ded7c217c5
14 changed files with 934 additions and 510 deletions

View File

@ -1,195 +0,0 @@
{
"version": "sunmao/v1",
"kind": "Application",
"metadata": {
"name": "login"
},
"spec": {
"components": [
{
"id": "stack0",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": []
},
{
"id": "text1",
"type": "core/v1/text",
"properties": {
"value": {
"raw": "text1",
"format": "plain"
}
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
},
{
"type": "core/v1/hidden",
"properties": {
"hidden": false,
"visually": false
}
}
]
},
{
"id": "text2",
"type": "core/v1/text",
"properties": {
"value": {
"raw": "text2",
"format": "plain"
}
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
},
{
"type": "core/v1/style",
"properties": {
"styles": [
{
"styleSlot": "content",
"style": "",
"cssProperties": {
"width": "100px",
"height": "200px",
"color": "rgba(245, 166, 35, 1)"
}
}
]
}
},
{
"type": "core/v1/event",
"properties": {
"handlers": []
}
}
]
},
{
<<<<<<< HEAD
"id": "fileInput6",
"type": "core/v1/fileInput",
"properties": {
"multiple": false,
"hideDefaultInput": false,
"fileTypes": []
=======
"id": "iframe8",
"type": "core/v1/iframe",
"properties": {
"src": "https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569861898606&layer=mapnik",
"referrerpolicy": "unset",
"sandbox": "unset",
"fetchpriority": "auto"
>>>>>>> testaddIframe
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
}
]
},
{
"id": "sub_stack1",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
}
]
},
{
"id": "text3",
"type": "core/v1/text",
"properties": {
"value": {
"raw": "text3",
"format": "plain"
}
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "sub_stack1",
"slot": "content"
},
"ifCondition": true
}
}
]
},
{
"id": "sub_sub_stack0",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "sub_stack1",
"slot": "content"
},
"ifCondition": true
}
}
]
}
]
}
}

View File

@ -1,190 +0,0 @@
{
"version": "sunmao/v1",
"kind": "Application",
"metadata": {
"name": "login"
},
"spec": {
"components": [
{
"id": "stack0",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": []
},
{
"id": "text1",
"type": "core/v1/text",
"properties": {
"value": {
"raw": "text1",
"format": "plain"
}
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
},
{
"type": "core/v1/hidden",
"properties": {
"hidden": false,
"visually": false
}
}
]
},
{
"id": "text2",
"type": "core/v1/text",
"properties": {
"value": {
"raw": "text2",
"format": "plain"
}
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
},
{
"type": "core/v1/style",
"properties": {
"styles": [
{
"styleSlot": "content",
"style": "",
"cssProperties": {
"width": "100px",
"height": "200px",
"color": "rgba(245, 166, 35, 1)"
}
}
]
}
},
{
"type": "core/v1/event",
"properties": {
"handlers": []
}
}
]
},
{
<<<<<<< HEAD
"id": "sub_stack1_newId",
=======
"id": "iframe8",
"type": "core/v1/iframe",
"properties": {
"src": "https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569861898606&layer=mapnik",
"referrerpolicy": "unset",
"sandbox": "unset",
"fetchpriority": "auto"
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
}
]
},
{
"id": "sub_stack1",
>>>>>>> testaddIframe
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
}
]
},
{
"id": "text3",
"type": "core/v1/text",
"properties": {
"value": {
"raw": "text3",
"format": "plain"
}
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "sub_stack1_newId",
"slot": "content"
},
"ifCondition": true
}
}
]
},
{
"id": "sub_sub_stack0",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "sub_stack1_newId",
"slot": "content"
},
"ifCondition": true
}
}
]
}
]
}
}

View File

@ -1,91 +0,0 @@
{
"version": "sunmao/v1",
"kind": "Application",
"metadata": {
"name": "login"
},
"spec": {
"components": [
{
"id": "text11",
"type": "core/v1/text",
"properties": {
"value": {
"raw": "text",
"format": "plain"
}
},
"traits": []
},
{
"id": "iframe14",
"type": "core/v1/iframe",
"properties": {
"src": "https://www.openstreetmap.org/export/embed.html?bbox=-0.004017949104309083%2C51.47612752641776%2C0.00030577182769775396%2C51.478569861898606&layer=mapnik",
"referrerpolicy": "unset",
"sandbox": "unset",
"fetchpriority": "auto"
},
"traits": []
},
{
"id": "stack12",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": []
},
{
"id": "fileInput13",
"type": "core/v1/fileInput",
"properties": {
"multiple": false,
"hideDefaultInput": false,
"fileTypes": []
},
"traits": []
},
{
<<<<<<< HEAD
"id": "text5",
"type": "core/v1/text",
=======
"id": "new_text16",
"type": "core/v1/text",
"properties": {
"value": {
"raw": "text",
"format": "plain"
}
},
"traits": []
},
{
"id": "iframe14",
"type": "core/v1/iframe",
>>>>>>> test-base-1
"properties": {
"value": {
"raw": "text",
"format": "plain"
}
},
"traits": []
},
{
"id": "moduleContainer15",
"type": "core/v1/moduleContainer",
"properties": {
"id": "myModule",
"type": "custom/v1/module"
},
"traits": []
}
]
}
}

View File

@ -1,5 +1,4 @@
import { mergeApplication } from '../src/mergeApplication';
import { BaseSchema, Schema1, Schema2 } from '../src/mock/mock';
import o from './mocks/ComponentDiff/o.json';
import a from './mocks/ComponentDiff/a.json';
import b from './mocks/ComponentDiff/b.json';

View File

@ -0,0 +1,174 @@
{
"version": "sunmao/v1",
"kind": "Application",
"metadata": {
"name": "some App"
},
"spec": {
"components": [
{
"id": "stack0",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": []
},
{
"id": "table2",
"type": "arco/v1/table",
"properties": {
"columns": [
{
"title": "Key",
"dataIndex": "key",
"type": "text",
"displayValue": "",
"filter": false,
"componentSlotIndex": 0,
"sorter": false,
"ellipsis": false,
"width": -1
},
{
"title": "Name",
"dataIndex": "name",
"sorter": true,
"sortDirections": ["ascend", "descend"],
"type": "text",
"filter": true,
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
{
"title": "Age",
"dataIndex": "salary",
"sorter": true,
"sortDirections": ["ascend", "descend"],
"filter": false,
"type": "text",
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
{
"title": "Link",
"dataIndex": "link",
"type": "link",
"filter": true,
"sorter": false,
"sortDirections": ["ascend", "descend"],
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
{
"title": "Address",
"type": "text",
"componentSlotIndex": 0,
"dataIndex": "address",
"displayValue": "Shanghai, China",
"width": 0,
"ellipsis": false,
"sorter": false,
"filter": false,
"sortDirections": [],
"btnCfg": {
"text": "",
"handlers": []
},
"module": {
"id": "",
"type": "",
"properties": {},
"handlers": []
}
}
],
"data": "{{[\n {\n \"key\": 0,\n \"name\": \"Kevin Sandra0\",\n \"link\": \"link-B\",\n \"salary\": 456\n },\n {\n \"key\": 1,\n \"name\": \"Naomi Cook1\",\n \"link\": \"link-B\",\n \"salary\": 51\n },\n {\n \"key\": 2,\n \"name\": \"Naomi Cook2\",\n \"link\": \"link-A\",\n \"salary\": 817\n },\n {\n \"key\": 3,\n \"name\": \"Kevin Sandra3\",\n \"link\": \"link-B\",\n \"salary\": 865\n },\n {\n \"key\": 4,\n \"name\": \"Naomi Cook4\",\n \"link\": \"link-B\",\n \"salary\": 318\n },\n {\n \"key\": 5,\n \"name\": \"Naomi Cook5\",\n \"link\": \"link-A\",\n \"salary\": 701\n },\n {\n \"key\": 6,\n \"name\": \"Naomi Cook6\",\n \"link\": \"link-B\",\n \"salary\": 567\n },\n {\n \"key\": 7,\n \"name\": \"Naomi Cook7\",\n \"link\": \"link-A\",\n \"salary\": 740\n },\n {\n \"key\": 8,\n \"name\": \"Naomi Cook8\",\n \"link\": \"link-A\",\n \"salary\": 967\n },\n {\n \"key\": 9,\n \"name\": \"Kevin Sandra9\",\n \"link\": \"link-A\",\n \"salary\": 906\n },\n {\n \"key\": 10,\n \"name\": \"Naomi Cook10\",\n \"link\": \"link-B\",\n \"salary\": 272\n },\n {\n \"key\": 11,\n \"name\": \"Naomi Cook11\",\n \"link\": \"link-A\",\n \"salary\": 831\n },\n {\n \"key\": 12,\n \"name\": \"Naomi Cook12\",\n \"link\": \"link-A\",\n \"salary\": 661\n }\n]}}",
"rowKey": "id",
"checkCrossPage": true,
"pagination": {
"enablePagination": true,
"pageSize": 10,
"defaultCurrent": 1,
"updateWhenDefaultPageChanges": false,
"useCustomPagination": false,
"simple": false,
"showJumper": false,
"showTotal": false
},
"rowClick": false,
"tableLayoutFixed": false,
"borderCell": false,
"stripe": false,
"size": "default",
"useDefaultFilter": true,
"useDefaultSort": true,
"pagePosition": "bottomCenter",
"rowSelectionType": "single",
"border": true,
"loading": true
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
},
{
"type": "core/v1/style",
"properties": {
"styles": [
{
"styleSlot": "content",
"style": "",
"cssProperties": {
"width": "600px",
"height": "1000px",
"backgroundColor": "yellow"
}
}
]
}
},
{
"type": "core/v1/event",
"properties": {
"handlers": [
{
"type": "onRowClick",
"componentId": "$utils",
"method": {
"name": "core/v1/scrollToComponent",
"parameters": {
"componentId": "stack0"
}
},
"wait": {
"type": "debounce",
"time": 0
},
"disabled": false
}
]
}
}
]
}
]
}
}

View File

@ -0,0 +1,209 @@
{
"version": "sunmao/v1",
"kind": "Application",
"metadata": {
"name": "some App"
},
"spec": {
"components": [
{
"id": "stack0",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": []
},
{
"id": "table2",
"type": "arco/v1/table",
"properties": {
"columns": [
{
"title": "Key",
"dataIndex": "key",
"type": "text",
"displayValue": "",
"filter": false,
"componentSlotIndex": 0,
"sorter": false,
"ellipsis": false,
"width": -1
},
{
"title": "Name",
"dataIndex": "name",
"sorter": true,
"sortDirections": ["ascend", "descend"],
"type": "text",
"filter": true,
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
{
"title": "height",
"dataIndex": "salary",
"sorter": true,
"sortDirections": ["ascend", "descend"],
"filter": false,
"type": "text",
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
{
"title": "Link",
"dataIndex": "link",
"type": "link",
"filter": true,
"sorter": false,
"sortDirections": ["ascend", "descend"],
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
}
],
"data": [
{
"key": 0,
"name": "Kevin Sandra0",
"link": "link-B",
"salary": 456
},
{
"key": 1,
"name": "Naomi Cook1",
"link": "link-B",
"salary": 51
},
{
"key": 2,
"name": "Naomi Cook2",
"link": "link-A",
"salary": 817
},
{
"key": 3,
"name": "Kevin Sandra3",
"link": "link-B",
"salary": 865
},
{
"key": 4,
"name": "Naomi Cook4",
"link": "link-B",
"salary": 318
},
{
"key": 5,
"name": "Naomi Cook5",
"link": "link-A",
"salary": 701
},
{
"key": 6,
"name": "Naomi Cook6",
"link": "link-B",
"salary": 567
},
{
"key": 7,
"name": "Naomi Cook7",
"link": "link-A",
"salary": 740
},
{
"key": 8,
"name": "Naomi Cook8",
"link": "link-A",
"salary": 967
},
{
"key": 9,
"name": "Kevin Sandra9",
"link": "link-A",
"salary": 906
},
{
"key": 10,
"name": "Naomi Cook10",
"link": "link-B",
"salary": 272
},
{
"key": 11,
"name": "Naomi Cook11",
"link": "link-A",
"salary": 831
},
{
"key": 12,
"name": "Naomi Cook12",
"link": "link-A",
"salary": 661
}
],
"rowKey": "key",
"checkCrossPage": true,
"pagination": {
"enablePagination": true,
"pageSize": 12,
"defaultCurrent": 1,
"updateWhenDefaultPageChanges": false,
"useCustomPagination": false,
"simple": false,
"showJumper": false,
"showTotal": false
},
"rowClick": false,
"tableLayoutFixed": false,
"borderCell": false,
"stripe": false,
"size": "default",
"useDefaultFilter": true,
"useDefaultSort": true,
"pagePosition": "bottomCenter",
"rowSelectionType": "single",
"border": true,
"loading": false
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
},
{
"type": "core/v1/style",
"properties": {
"styles": [
{
"styleSlot": "content",
"style": "",
"cssProperties": {
"width": "500px",
"height": "1000px",
"color": "red"
}
}
]
}
}
]
}
]
}
}

View File

@ -0,0 +1,208 @@
{
"version": "sunmao/v1",
"kind": "Application",
"metadata": {
"name": "some App"
},
"spec": {
"components": [
{
"id": "stack0",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": []
},
{
"id": "table2",
"type": "arco/v1/table",
"properties": {
"columns": [
{
"title": "Key",
"dataIndex": "key",
"type": "text",
"displayValue": "",
"filter": false,
"componentSlotIndex": 0,
"sorter": false,
"ellipsis": false,
"width": -1
},
{
"title": "Name",
"dataIndex": "name",
"sorter": true,
"sortDirections": ["ascend", "descend"],
"type": "text",
"filter": true,
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
{
"title": "Salary",
"dataIndex": "salary",
"sorter": true,
"sortDirections": ["ascend", "descend"],
"filter": false,
"type": "text",
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
{
"title": "Link",
"dataIndex": "link",
"type": "link",
"filter": true,
"sorter": false,
"sortDirections": ["ascend", "descend"],
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
}
],
"data": [
{
"key": 0,
"name": "Kevin Sandra0",
"link": "link-B",
"salary": 456
},
{
"key": 1,
"name": "Naomi Cook1",
"link": "link-B",
"salary": 51
},
{
"key": 2,
"name": "Naomi Cook2",
"link": "link-A",
"salary": 817
},
{
"key": 3,
"name": "Kevin Sandra3",
"link": "link-B",
"salary": 865
},
{
"key": 4,
"name": "Naomi Cook4",
"link": "link-B",
"salary": 318
},
{
"key": 5,
"name": "Naomi Cook5",
"link": "link-A",
"salary": 701
},
{
"key": 6,
"name": "Naomi Cook6",
"link": "link-B",
"salary": 567
},
{
"key": 7,
"name": "Naomi Cook7",
"link": "link-A",
"salary": 740
},
{
"key": 8,
"name": "Naomi Cook8",
"link": "link-A",
"salary": 967
},
{
"key": 9,
"name": "Kevin Sandra9",
"link": "link-A",
"salary": 906
},
{
"key": 10,
"name": "Naomi Cook10",
"link": "link-B",
"salary": 272
},
{
"key": 11,
"name": "Naomi Cook11",
"link": "link-A",
"salary": 831
},
{
"key": 12,
"name": "Naomi Cook12",
"link": "link-A",
"salary": 661
}
],
"rowKey": "key",
"checkCrossPage": true,
"pagination": {
"enablePagination": true,
"pageSize": 6,
"defaultCurrent": 1,
"updateWhenDefaultPageChanges": false,
"useCustomPagination": false,
"simple": false,
"showJumper": false,
"showTotal": false
},
"rowClick": false,
"tableLayoutFixed": false,
"borderCell": false,
"stripe": false,
"size": "default",
"useDefaultFilter": true,
"useDefaultSort": true,
"pagePosition": "bottomCenter",
"rowSelectionType": "single",
"border": true,
"loading": false
},
"traits": [
{
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
},
{
"type": "core/v1/style",
"properties": {
"styles": [
{
"styleSlot": "content",
"style": "",
"cssProperties": {
"color": "red",
"backgroundColor": "yellow"
}
}
]
}
}
]
}
]
}
}

View File

@ -0,0 +1,173 @@
{
"version": "sunmao/v1",
"kind": "Application",
"metadata": {
"name": "some App"
},
"spec": {
"components": [
{
"id": "stack0",
"type": "core/v1/stack",
"properties": {
"spacing": 12,
"direction": "horizontal",
"align": "auto",
"wrap": false,
"justify": "flex-start"
},
"traits": []
},
{
"id": "table2",
"type": "arco/v1/table",
"properties": {
"columns": {
"0": {
"title": "Key",
"dataIndex": "key",
"type": "text",
"displayValue": "",
"filter": false,
"componentSlotIndex": 0,
"sorter": false,
"ellipsis": false,
"width": -1
},
"1": {
"title": "Name",
"dataIndex": "name",
"sorter": true,
"sortDirections": ["ascend", "descend"],
"type": "text",
"filter": true,
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
"2": {
"title": "Age",
"dataIndex": "salary",
"sorter": true,
"sortDirections": ["ascend", "descend"],
"filter": false,
"type": "text",
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
"3": {
"title": "Link",
"dataIndex": "link",
"type": "link",
"filter": true,
"sorter": false,
"sortDirections": ["ascend", "descend"],
"displayValue": "",
"ellipsis": false,
"componentSlotIndex": 0,
"width": -1
},
"4": {
"title": "Address",
"type": "text",
"componentSlotIndex": 0,
"dataIndex": "address",
"displayValue": "Shanghai, China",
"width": 0,
"ellipsis": false,
"sorter": false,
"filter": false,
"sortDirections": [],
"btnCfg": {
"text": "",
"handlers": []
},
"module": {
"id": "",
"type": "",
"properties": {},
"handlers": []
}
}
},
"data": "{{[\n {\n \"key\": 0,\n \"name\": \"Kevin Sandra0\",\n \"link\": \"link-B\",\n \"salary\": 456\n },\n {\n \"key\": 1,\n \"name\": \"Naomi Cook1\",\n \"link\": \"link-B\",\n \"salary\": 51\n },\n {\n \"key\": 2,\n \"name\": \"Naomi Cook2\",\n \"link\": \"link-A\",\n \"salary\": 817\n },\n {\n \"key\": 3,\n \"name\": \"Kevin Sandra3\",\n \"link\": \"link-B\",\n \"salary\": 865\n },\n {\n \"key\": 4,\n \"name\": \"Naomi Cook4\",\n \"link\": \"link-B\",\n \"salary\": 318\n },\n {\n \"key\": 5,\n \"name\": \"Naomi Cook5\",\n \"link\": \"link-A\",\n \"salary\": 701\n },\n {\n \"key\": 6,\n \"name\": \"Naomi Cook6\",\n \"link\": \"link-B\",\n \"salary\": 567\n },\n {\n \"key\": 7,\n \"name\": \"Naomi Cook7\",\n \"link\": \"link-A\",\n \"salary\": 740\n },\n {\n \"key\": 8,\n \"name\": \"Naomi Cook8\",\n \"link\": \"link-A\",\n \"salary\": 967\n },\n {\n \"key\": 9,\n \"name\": \"Kevin Sandra9\",\n \"link\": \"link-A\",\n \"salary\": 906\n },\n {\n \"key\": 10,\n \"name\": \"Naomi Cook10\",\n \"link\": \"link-B\",\n \"salary\": 272\n },\n {\n \"key\": 11,\n \"name\": \"Naomi Cook11\",\n \"link\": \"link-A\",\n \"salary\": 831\n },\n {\n \"key\": 12,\n \"name\": \"Naomi Cook12\",\n \"link\": \"link-A\",\n \"salary\": 661\n }\n]}}",
"rowKey": "id",
"checkCrossPage": true,
"pagination": {
"enablePagination": true,
"pageSize": 12,
"defaultCurrent": 1,
"updateWhenDefaultPageChanges": false,
"useCustomPagination": false,
"simple": false,
"showJumper": false,
"showTotal": false
},
"rowClick": false,
"tableLayoutFixed": false,
"borderCell": false,
"stripe": false,
"size": "default",
"useDefaultFilter": true,
"useDefaultSort": true,
"pagePosition": "bottomCenter",
"rowSelectionType": "single",
"border": true,
"loading": true
},
"traits": {
"0": {
"type": "core/v1/slot",
"properties": {
"container": {
"id": "stack0",
"slot": "content"
},
"ifCondition": true
}
},
"1": {
"type": "core/v1/style",
"properties": {
"styles": {
"0": {
"styleSlot": "content",
"style": "",
"cssProperties": {
"width": "600px",
"height": "1000px"
}
}
}
}
},
"2": {
"type": "core/v1/event",
"properties": {
"handlers": [
{
"type": "onRowClick",
"componentId": "$utils",
"method": {
"name": "core/v1/scrollToComponent",
"parameters": {
"componentId": "stack0"
}
},
"wait": {
"type": "debounce",
"time": 0
},
"disabled": false
}
]
}
}
}
}
]
}
}

View File

@ -0,0 +1,47 @@
import { mergeApplication } from '../src/mergeApplication';
import o from './mocks/PropertyDiff/o.json';
import a from './mocks/PropertyDiff/a.json';
import b from './mocks/PropertyDiff/b.json';
import solvedApp from './mocks/PropertyDiff/solved.json';
import { Application, ComponentSchema } from '@sunmao-ui/core';
import { ChangeDiffBlock, OKDiffBlock } from '../src/type';
import { solveApplication, solveJson } from '../src/solve';
describe('diff property changes of component', () => {
const { diffBlocks, map, appSkeleton } = mergeApplication(
o as Application,
a as Application,
b as Application
);
const block1 = diffBlocks[0] as OKDiffBlock;
const block2 = diffBlocks[1] as ChangeDiffBlock;
it(`detect property's conflicts`, () => {
expect(block1.kind).toEqual('ok');
expect(block2.kind).toEqual('change');
expect(block2.diffBlocks.map(d => d.kind)).toEqual([
'equal',
'equal',
'change',
'change',
]);
});
it(`solve component's conflicts`, () => {
const solvedComponent = solveJson(block2.diffBlocks, {
'.properties.data': 'a',
'.properties.pagination.pageSize': 'b',
'.traits.1.properties.styles.0.cssProperties.width': 'a',
'.properties.columns.2.title': 'a',
});
const newAPP = solveApplication({
diffBlocks,
hashMap: map,
solvedComponentsIdMap: {
[block2.id]: solvedComponent as ComponentSchema,
},
checkedHashes: [block2.hashA],
appSkeleton,
});
expect(newAPP).toEqual(solvedApp);
});
});

View File

@ -4,7 +4,7 @@ import { HashDivider, mergeApplication } from './mergeApplication';
import { ChangeDiffBlock } from './type';
import { BaseSchema, Schema1, Schema2 } from './mock/changeProperty';
import { Button, Radio } from '@arco-design/web-react';
import { PropertyViewer } from './components/PropertyEditor';
import { PropertyViewer } from './components/PropertyViewer';
import { solveApplication, solveJson } from './solve';
import { Application, ComponentSchema } from '@sunmao-ui/core';
import { css } from '@emotion/css';

View File

@ -19,6 +19,7 @@ type Props = {
};
const Style = css`
box-sizing: border-box;
height: 100%;
overflow: auto;
padding: 32px;
@ -34,18 +35,20 @@ function diffToTreeNode(block: PropsDiffBlock): Array<TreeDataType> {
checkable: true,
key: `${block.path}-a`,
style: { color: 'green' },
expanded: true,
},
{
title: `${block.key}: ${JSON.stringify(block.bValue)} >>>>>>>> B`,
checkable: true,
key: `${block.path}-b`,
style: { color: 'green' },
expanded: true,
},
];
case 'equal':
return [
{
title: block.key,
title: `${block.key}: ${block.value}`,
children: flatten(block.children.map(diffToTreeNode)),
key: block.path,
},
@ -53,22 +56,36 @@ function diffToTreeNode(block: PropsDiffBlock): Array<TreeDataType> {
case 'change':
return [
{
title: block.key,
title: `${block.key}: ${block.value}`,
children: flatten(block.children.map(diffToTreeNode)),
key: block.path,
style: { color: block.childrenHasConflict ? 'orange' : undefined },
expanded: true,
},
];
}
return [];
}
function getDefaultExpandedKeys(tree: TreeDataType[]) {
const expandedKeys: string[] = [];
function traverseTreeNode(node: TreeDataType) {
if (node.expanded) {
expandedKeys.push(node.key!);
}
node.children?.forEach(traverseTreeNode);
}
tree.forEach(traverseTreeNode);
return expandedKeys;
}
export const PropertyViewer: React.FC<Props> = ({
selectedHash,
propsDiffBlocks: diffs,
onCheck,
}) => {
const data = flatten(diffs.map(diffToTreeNode));
const data = flatten(diffs.map(diff => diffToTreeNode(diff)));
const defaultExpandedKeys = getDefaultExpandedKeys(data);
const _onCheck = (keys: string[]) => {
const checkedPropsMap: PropsConflictMap = {};
@ -87,7 +104,11 @@ export const PropertyViewer: React.FC<Props> = ({
<div className={Style}>
<h1></h1>
<div>Component: {selectedHash}</div>
<ArcoTree treeData={data} onCheck={_onCheck} />
<ArcoTree
treeData={data}
onCheck={_onCheck}
defaultExpandedKeys={defaultExpandedKeys}
/>
</div>
);
};

View File

@ -55,7 +55,6 @@ export function mergeApplication(
const mergeRegion = Diff3.diff3Merge(aHashed, oHashed, bHashed);
const formatted = flatten(mergeRegion.map(r => formatMergeRegionToDiffBlock(r, map)));
console.log('diffBlocks', formatted);
const appSkeleton = { ...o, spec: { ...o.spec, components: [] } };
return { diffBlocks: formatted, map, appSkeleton };
}

View File

@ -11,8 +11,6 @@ export function mergeJSON(
const oVal = o[oKey];
const aVal = a[oKey];
const bVal = b[oKey];
console.log('a', a);
console.log('b', b);
if (oKey in a && oKey in b) {
if (oVal === aVal && oVal === bVal) {
// oab都在且无变化
@ -29,16 +27,29 @@ export function mergeJSON(
if (oVal !== aVal && oVal !== bVal && aVal !== bVal) {
// oab都在但不相等
if (typeof aVal === 'object' && typeof bVal === 'object') {
const diffBlocks = mergeJSON(oVal, aVal, bVal, `${path}.${oKey}`);
// 都是对象进一步diff
blocks.push({
kind: 'change',
key: oKey,
value: oVal,
path: `${path}.${oKey}`,
children: diffBlocks,
childrenHasConflict: propsDiffBlocksHasChange(diffBlocks),
});
const diffBlocks = mergeJSON(oVal, aVal, bVal, `${path}.${oKey}`);
const childrenHasConflict = propsDiffBlocksHasChange(diffBlocks);
if (childrenHasConflict) {
// 对象内有冲突
blocks.push({
kind: 'change',
key: oKey,
value: oVal,
path: `${path}.${oKey}`,
children: diffBlocks,
childrenHasConflict: propsDiffBlocksHasChange(diffBlocks),
});
} else {
// 对象内无冲突
blocks.push({
kind: 'equal',
key: oKey,
value: oVal,
path: `${path}.${oKey}`,
children: diffBlocks,
});
}
} else {
blocks.push({
kind: 'conflict',
@ -131,17 +142,17 @@ function findIncrement(
const bVal = another[aKey];
if (notIn(aKey, o) && notIn(aKey, another)) {
blocks.push({
kind: 'change',
kind: 'equal',
key: aKey,
value: aVal,
path: `${path}.${aKey}`,
children: [],
childrenHasConflict: false,
});
continue;
}
if (notIn(aKey, o) && aKey in another) {
// 如果反转了就不需要对比ab都有value了因为a已经比过了
if (!reverse && notIn(aKey, o) && aKey in another) {
if (typeof aVal === 'object' && typeof bVal === 'object') {
// 都是对象进一步diff
const diffBlocks = mergeJSON(oVal, aVal, bVal);
@ -153,6 +164,15 @@ function findIncrement(
children: diffBlocks,
childrenHasConflict: propsDiffBlocksHasChange(diffBlocks),
});
} else if (aVal === bVal) {
// 两者相等
blocks.push({
kind: 'equal',
key: aKey,
value: aVal,
path: `${path}.${aKey}`,
children: [],
});
} else {
blocks.push({
kind: 'conflict',

View File

@ -2661,6 +2661,24 @@
source-map "^0.5.7"
stylis "4.0.13"
"@emotion/babel-plugin@^11.10.5":
version "11.10.5"
resolved "https://registry.yarnpkg.com/@emotion/babel-plugin/-/babel-plugin-11.10.5.tgz#65fa6e1790ddc9e23cc22658a4c5dea423c55c3c"
integrity sha512-xE7/hyLHJac7D2Ve9dKroBBZqBT7WuPQmWcq7HSGb84sUuP4mlOWoB8dvVfD9yk5DHkU1m6RW7xSoDtnQHNQeA==
dependencies:
"@babel/helper-module-imports" "^7.16.7"
"@babel/plugin-syntax-jsx" "^7.17.12"
"@babel/runtime" "^7.18.3"
"@emotion/hash" "^0.9.0"
"@emotion/memoize" "^0.8.0"
"@emotion/serialize" "^1.1.1"
babel-plugin-macros "^3.1.0"
convert-source-map "^1.5.0"
escape-string-regexp "^4.0.0"
find-root "^1.1.0"
source-map "^0.5.7"
stylis "4.1.3"
"@emotion/cache@^11.10.0":
version "11.10.3"
resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-11.10.3.tgz#c4f67904fad10c945fea5165c3a5a0583c164b87"
@ -2672,6 +2690,17 @@
"@emotion/weak-memoize" "^0.3.0"
stylis "4.0.13"
"@emotion/cache@^11.10.5":
version "11.10.5"
resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-11.10.5.tgz#c142da9351f94e47527ed458f7bbbbe40bb13c12"
integrity sha512-dGYHWyzTdmK+f2+EnIGBpkz1lKc4Zbj2KHd4cX3Wi8/OWr5pKslNjc3yABKH4adRGCvSX4VDC0i04mrrq0aiRA==
dependencies:
"@emotion/memoize" "^0.8.0"
"@emotion/sheet" "^1.2.1"
"@emotion/utils" "^1.2.0"
"@emotion/weak-memoize" "^0.3.0"
stylis "4.1.3"
"@emotion/cache@^11.4.0":
version "11.5.0"
resolved "https://registry.npmjs.org/@emotion/cache/-/cache-11.5.0.tgz"
@ -2733,15 +2762,15 @@
resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.8.0.tgz#f580f9beb67176fa57aae70b08ed510e1b18980f"
integrity sha512-G/YwXTkv7Den9mXDO7AhLWkE3q+I92B+VqAE+dYG4NGPaHZGvt3G8Q0p9vmE+sq7rTGphUbAvmQ9YpbfMQGGlA==
"@emotion/react@^11.0.0", "@emotion/react@^11.1.1":
version "11.10.4"
resolved "https://registry.yarnpkg.com/@emotion/react/-/react-11.10.4.tgz#9dc6bccbda5d70ff68fdb204746c0e8b13a79199"
integrity sha512-j0AkMpr6BL8gldJZ6XQsQ8DnS9TxEQu1R+OGmDZiWjBAJtCcbt0tS3I/YffoqHXxH6MjgI7KdMbYKw3MEiU9eA==
"@emotion/react@^11.0.0", "@emotion/react@^11.1.1", "@emotion/react@^11.8.1":
version "11.10.5"
resolved "https://registry.yarnpkg.com/@emotion/react/-/react-11.10.5.tgz#95fff612a5de1efa9c0d535384d3cfa115fe175d"
integrity sha512-TZs6235tCJ/7iF6/rvTaOH4oxQg2gMAcdHemjwLKIjKz4rRuYe1HJ2TQJKnAcRAfOUDdU8XoDadCe1rl72iv8A==
dependencies:
"@babel/runtime" "^7.18.3"
"@emotion/babel-plugin" "^11.10.0"
"@emotion/cache" "^11.10.0"
"@emotion/serialize" "^1.1.0"
"@emotion/babel-plugin" "^11.10.5"
"@emotion/cache" "^11.10.5"
"@emotion/serialize" "^1.1.1"
"@emotion/use-insertion-effect-with-fallbacks" "^1.0.0"
"@emotion/utils" "^1.2.0"
"@emotion/weak-memoize" "^0.3.0"
@ -2769,6 +2798,17 @@
"@emotion/utils" "^1.2.0"
csstype "^3.0.2"
"@emotion/serialize@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@emotion/serialize/-/serialize-1.1.1.tgz#0595701b1902feded8a96d293b26be3f5c1a5cf0"
integrity sha512-Zl/0LFggN7+L1liljxXdsVSVlg6E/Z/olVWpfxUTxOAmi8NU7YoeWeLfi1RmnB2TATHoaWwIBRoL+FvAJiTUQA==
dependencies:
"@emotion/hash" "^0.9.0"
"@emotion/memoize" "^0.8.0"
"@emotion/unitless" "^0.8.0"
"@emotion/utils" "^1.2.0"
csstype "^3.0.2"
"@emotion/sheet@^1.0.3":
version "1.0.3"
resolved "https://registry.npmjs.org/@emotion/sheet/-/sheet-1.0.3.tgz"
@ -2779,15 +2819,20 @@
resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.2.0.tgz#771b1987855839e214fc1741bde43089397f7be5"
integrity sha512-OiTkRgpxescko+M51tZsMq7Puu/KP55wMT8BgpcXVG2hqXc0Vo0mfymJ/Uj24Hp0i083ji/o0aLddh08UEjq8w==
"@emotion/styled@^11.0.0":
version "11.10.4"
resolved "https://registry.yarnpkg.com/@emotion/styled/-/styled-11.10.4.tgz#e93f84a4d54003c2acbde178c3f97b421fce1cd4"
integrity sha512-pRl4R8Ez3UXvOPfc2bzIoV8u9P97UedgHS4FPX594ntwEuAMA114wlaHvOK24HB48uqfXiGlYIZYCxVJ1R1ttQ==
"@emotion/sheet@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.2.1.tgz#0767e0305230e894897cadb6c8df2c51e61a6c2c"
integrity sha512-zxRBwl93sHMsOj4zs+OslQKg/uhF38MB+OMKoCrVuS0nyTkqnau+BM3WGEoOptg9Oz45T/aIGs1qbVAsEFo3nA==
"@emotion/styled@^11.0.0", "@emotion/styled@^11.8.1":
version "11.10.5"
resolved "https://registry.yarnpkg.com/@emotion/styled/-/styled-11.10.5.tgz#1fe7bf941b0909802cb826457e362444e7e96a79"
integrity sha512-8EP6dD7dMkdku2foLoruPCNkRevzdcBaY6q0l0OsbyJK+x8D9HWjX27ARiSIKNF634hY9Zdoedh8bJCiva8yZw==
dependencies:
"@babel/runtime" "^7.18.3"
"@emotion/babel-plugin" "^11.10.0"
"@emotion/babel-plugin" "^11.10.5"
"@emotion/is-prop-valid" "^1.2.0"
"@emotion/serialize" "^1.1.0"
"@emotion/serialize" "^1.1.1"
"@emotion/use-insertion-effect-with-fallbacks" "^1.0.0"
"@emotion/utils" "^1.2.0"
@ -11878,6 +11923,11 @@ stylis@4.0.13:
resolved "https://registry.npmjs.org/stylis/-/stylis-4.0.13.tgz"
integrity sha512-xGPXiFVl4YED9Jh7Euv2V220mriG9u4B2TA6Ybjc1catrstKD2PpIdU3U0RKpkVBC2EhmL/F0sPCr9vrFTNRag==
stylis@4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.3.tgz#fd2fbe79f5fed17c55269e16ed8da14c84d069f7"
integrity sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA==
stylis@^4.0.10:
version "4.0.10"
resolved "https://registry.npmjs.org/stylis/-/stylis-4.0.10.tgz"