Skip to content

Commit 35a7496

Browse files
fix: component dnd (#3497)
* fix: builder script error because of not hydrated tags fix: builder script error after element was added fix: issues with empty Action Select fields fix: action create/update form issues fix: runtime actions cleanup when related action removed refactor: builder click overlay fix: elementTree bad state warning fix: elementTree bad state warning revert: unwanted change after rebase refactor: fix edit component on context menu fix: use converted element directly as root element refactor: builder click overlay wip: fix drag and drop wip: adding droppable rectangles feat: finish element blueprints refactor: comment old spec fix: dnd specs fix: renderer specs fix: build issues lint: fix tsconfig.base lint fix: drop indicator fix: restore builder style fix: restore builder style fix: e2e specs fix: convert to component use case fix: build issue fix: unit specs fix: convert element to component use case * revert: unwated changes after rebase --------- Co-authored-by: Vladyslav Polishchuk <gm.vpolishchuk@gmail.com>
1 parent aedd690 commit 35a7496

File tree

100 files changed

+2254
-2723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2254
-2723
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# pnpm cli tasks lint --stage test
1+
pnpm cli tasks lint --stage test

apps/web-e2e/src/modules/convert-element-to-component/convert-element-to-component.fixture.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ export class ConvertElementToComponentPage extends BuilderPage {
1515
async checkComponentHasCorrectElements() {
1616
await expect(this.getBuilderRenderContainer()).toHaveText(textContent)
1717

18-
await this.checkElementTreeStructure([
19-
'Container Root',
20-
'Container',
21-
'Row',
22-
'Column',
23-
'Text',
24-
])
18+
await this.checkElementTreeStructure(['Container', 'Row', 'Column', 'Text'])
2519
}
2620

2721
async convertElementToComponent() {

libs/frontend/abstract/application/src/component/component.service.interface.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import type { IComponentModel } from '@codelab/frontend/abstract/domain'
1+
import type {
2+
IComponentModel,
3+
IElementModel,
4+
} from '@codelab/frontend/abstract/domain'
25
import type {
36
ICreateComponentData,
47
IRef,
@@ -27,6 +30,10 @@ export interface IComponentService
2730
// componentDevelopmentService: IComponentDevelopmentService
2831
// moved to builder
2932
// getSelectComponentOptions(): Promise<Array<DefaultOptionType>>
33+
createWithoutRoot(
34+
data: ICreateComponentData,
35+
rootElement: IElementModel,
36+
): Promise<IComponentModel>
3037
importComponent(componentDataFile: File): Promise<Maybe<IComponentModel>>
3138
previewComponent(id: string): void
3239
}

libs/frontend/abstract/application/src/renderer/runtime-component/runtime-component.model.interface.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type { IComponentModel } from '@codelab/frontend/abstract/domain'
2-
import type { Maybe } from '@codelab/shared/abstract/types'
2+
import type { Maybe, Nullable } from '@codelab/shared/abstract/types'
33
import type { Ref } from 'mobx-keystone'
44

55
import type { IBaseRuntimeModel } from '../runtime.model.interface'
66
import type { IRuntimeElementModel } from '../runtime-element'
77
import type { IRuntimeComponentPropModel } from '../runtime-prop'
8+
import { ReactElement } from 'react'
89

910
/**
1011
* Represents runtime model IComponentModel
@@ -26,6 +27,13 @@ export interface IRuntimeComponentModel extends IBaseRuntimeModel {
2627
component: Ref<IComponentModel>
2728
isChildMapperComponentInstance: boolean
2829
isTypedProp?: boolean
30+
elements: Array<IRuntimeElementModel>
31+
/**
32+
* When clicking an element from component while editing a page or another component we should select element
33+
* from main tree that is being edited
34+
*/
35+
mainTreeElement: Maybe<IRuntimeElementModel>
36+
2937
/**
3038
* Exposed for external use by other models and to preserve structure
3139
*/

libs/frontend/abstract/application/src/renderer/runtime-element/runtime-element.model.interface.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export interface IRuntimeElementModel extends IBaseRuntimeModel {
2525
* The runtime model for IElementModel.closestContainerNode
2626
*/
2727
closestContainerNode: Ref<IRuntimeComponentModel | IRuntimePageModel>
28+
29+
descendantElements: Array<IRuntimeElementModel>
30+
2831
element: Ref<IElementModel>
32+
33+
mainTreeElement: IRuntimeElementModel
2934
parentElement: Maybe<IRuntimeElementModel>
3035
parentElementKey: Nullable<string>
3136
pathFromRoot: Array<IRuntimeElementModel>

libs/frontend/abstract/application/src/renderer/runtime-element/runtime.element.service.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export interface IRuntimeElementService {
1111
currentStylePseudoClass: ElementStylePseudoClass
1212
elements: ObjectMap<IRuntimeElementModel>
1313
elementsList: Array<IRuntimeElementModel>
14-
expandedCompositeKeys: Array<string>
1514
add(
1615
element: IElementModel,
1716
closestContainerNode: IRuntimeComponentModel | IRuntimePageModel,
1817
parentElement: Nullable<IRuntimeElementModel>,
1918
propKey?: string,
2019
): IRuntimeElementModel
20+
getExpandedCompositeKeys(): Array<string>
2121
maybeRuntimeElement(compositeKey: string): Maybe<IRuntimeElementModel>
2222
remove(runtimeElement: IRuntimeElementModel): void
2323
runtimeElement(compositeKey: string): IRuntimeElementModel

libs/frontend/abstract/application/src/renderer/runtime-page/runtime-page.model.interface.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { IPageModel } from '@codelab/frontend/abstract/domain'
22
import type { Ref } from 'mobx-keystone'
3+
import type { Maybe } from '@codelab/shared/abstract/types'
34

45
import type { IBaseRuntimeModel } from '../runtime.model.interface'
56
import type { IRuntimeElementModel } from '../runtime-element'
@@ -12,6 +13,12 @@ export interface IRuntimePageModel extends IBaseRuntimeModel {
1213
* Regular page in case the current model is a provider page
1314
*/
1415
childPage?: Ref<IRuntimePageModel>
16+
elements: Array<IRuntimeElementModel>
17+
/**
18+
* When clicking an element from provider page while editing a regular page we should select root element of regular page
19+
* This is the root element of the regular page
20+
*/
21+
mainTreeElement: Maybe<IRuntimeElementModel>
1522
/**
1623
* Page domain model
1724
*/

libs/frontend/abstract/domain/src/component/component.domain.service.interface.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import type {
22
RenderTypeSelectOption,
33
SelectOption,
44
} from '@codelab/frontend/abstract/types'
5-
import type {
6-
IComponentDto,
7-
ICreateComponentData,
8-
} from '@codelab/shared/abstract/core'
5+
import type { IComponentDto } from '@codelab/shared/abstract/core'
96
import type { ObjectMap } from 'mobx-keystone'
107

118
import type { IHydrateable } from '../shared'
@@ -16,7 +13,6 @@ export interface IComponentDomainService
1613
componentList: Array<IComponentModel>
1714
components: ObjectMap<IComponentModel>
1815
sortedComponentsList: Array<IComponentModel>
19-
add(data: ICreateComponentData): IComponentModel
2016
component(id: string): IComponentModel
2117
findById(id: string): IComponentModel
2218
getRenderTypeOptions(

libs/frontend/abstract/domain/src/element/element.model.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ export interface IElementModel extends IModel<IElementDto, IElementModel> {
108108
primary: string
109109
secondary: string | undefined
110110
}
111+
attachAsComponentRoot(component: IRef): void
111112
attachAsFirstChild(parentElement: IElementModel): void
112113
attachAsNextSibling(sibling: IElementModel): void
113114
attachAsPrevSibling(sibling: IElementModel): void
@@ -118,7 +119,6 @@ export interface IElementModel extends IModel<IElementDto, IElementModel> {
118119
setName(name: string): void
119120
setNextSibling(nextSibling: Ref<IElementModel>): void
120121
setOrderInParent(order: number | null): void
121-
setParentComponent(component: Ref<IComponentModel>): void
122122
setParentElement(parent: Ref<IElementModel>): void
123123
setPrevSibling(prevSibling: Ref<IElementModel>): void
124124
setProps(props: IPropModel): void

libs/frontend/abstract/domain/src/shared/constant.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export const DATASET_ELEMENT_ID = 'elementId'
1313

1414
export const DATA_ELEMENT_ID = 'data-element-id'
1515

16+
export const DATA_RUNTIME_ELEMENT_KEY = 'data-runtime-element-key'
17+
1618
export const BUILDER_CONTAINER_ID = 'Builder'
1719

1820
export const BUILDER_NONE_CLASS_NAME = 'Builder-none'
@@ -23,6 +25,8 @@ export const DATA_GRID = 'DATA-GRID'
2325

2426
export const ROOT_RENDER_CONTAINER_ID = 'render-root'
2527

28+
export const BLUEPRINT_ID_PREFIX = 'blueprint-'
29+
2630
export const LAST_WORD_AFTER_DOT_REGEX = /\.\w+$/
2731

2832
export const WORD_BEFORE_DOT_REGEX = /\w*(\.)?/

0 commit comments

Comments
 (0)