Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c8b97b

Browse files
author
hulutter
committed
feat(client): remove id property as it might interfere with other features and add data-testid to enable test automation
1 parente14cab9 commit9c8b97b

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

‎client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx‎

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import { trans } from "i18n";
2828
exporttypeNewChildren<ChildrenCompMapextendsRecord<string,Comp<unknown>>>=
2929
ChildrenCompMap&{
3030
hidden:InstanceType<typeofBoolCodeControl>;
31-
id:InstanceType<typeofStringControl>;
3231
className:InstanceType<typeofStringControl>;
32+
dataTestId:InstanceType<typeofStringControl>;
3333
};
3434

3535
exportfunctionHidableView(props:{
@@ -56,15 +56,15 @@ export function HidableView(props: {
5656

5757
exportfunctionExtendedComponentView(props:{
5858
children:JSX.Element|React.ReactNode;
59-
id:string;
6059
className:string;
60+
dataTestId:string;
6161
}){
62-
if(!props.id&&!props.className){
62+
if(!props.className&&!props.dataTestId){
6363
return<>{props.children}</>;
64-
}
65-
64+
}
65+
6666
return(
67-
<divid={props.id}className={props.className}>
67+
<divclassName={props.className}data-testid={props.dataTestId}>
6868
{props.children}
6969
</div>
7070
);
@@ -73,17 +73,17 @@ export function ExtendedComponentView(props: {
7373
exportfunctionExtendedPropertyView<
7474
ChildrenCompMapextendsRecord<string,Comp<unknown>>,
7575
>(props:{
76-
children:JSX.Element|React.ReactNode,
77-
childrenMap:NewChildren<ChildrenCompMap>
78-
}
76+
children:JSX.Element|React.ReactNode,
77+
childrenMap:NewChildren<ChildrenCompMap>
78+
}
7979
){
8080
return(
8181
<>
82-
{props.children}
83-
<Sectionname={trans("prop.component")}>
84-
{props.childrenMap.id?.propertyView({label:trans("prop.id")})}
85-
{props.childrenMap.className?.propertyView({label:trans("prop.className")})}
86-
</Section>
82+
{props.children}
83+
<Sectionname={trans("prop.component")}>
84+
{props.childrenMap.className?.propertyView({label:trans("prop.className")})}
85+
{props.childrenMap.dataTestId?.propertyView({label:trans("prop.dataTestId")})}
86+
</Section>
8787
</>
8888
);
8989
}
@@ -93,7 +93,12 @@ export function uiChildren<
9393
>(
9494
childrenMap:ToConstructor<ChildrenCompMap>
9595
):ToConstructor<NewChildren<ChildrenCompMap>>{
96-
return{ ...childrenMap,hidden:BoolCodeControl,id:StringControl,className:StringControl}asany;
96+
return{
97+
...childrenMap,
98+
hidden:BoolCodeControl,
99+
className:StringControl,
100+
dataTestId:StringControl
101+
}asany;
97102
}
98103

99104
typeViewReturn=ReactNode;
@@ -160,14 +165,11 @@ export class UICompBuilder<
160165
}
161166

162167
build(){
163-
if(this.childrenMap.hasOwnProperty("hidden")){
164-
thrownewError("already has hidden");
165-
}
166-
if(this.childrenMap.hasOwnProperty("id")){
167-
thrownewError("already has id");
168-
}
169-
if(this.childrenMap.hasOwnProperty("className")){
170-
thrownewError("already has className");
168+
constreservedProps=["hidden","className","dataTestId"];
169+
for(constreservedPropofreservedProps){
170+
if(this.childrenMap.hasOwnProperty(reservedProp)){
171+
thrownewError(`Property »${reservedProp}« is reserved and must not be implemented in components!`);
172+
}
171173
}
172174
constnewChildrenMap=uiChildren(this.childrenMap);
173175
constbuilder=this;
@@ -178,7 +180,7 @@ export class UICompBuilder<
178180
ToNodeType<NewChildren<ChildrenCompMap>>
179181
>{
180182
ref:React.RefObject<HTMLDivElement>=React.createRef();
181-
183+
182184
overrideparseChildrenFromValue(
183185
params:CompParams<ToDataType<NewChildren<ChildrenCompMap>>>
184186
):NewChildren<ChildrenCompMap>{
@@ -241,7 +243,10 @@ function UIView(props: { comp: any; viewFn: any }) {
241243
//END ADD BY FRED
242244

243245
return(
244-
<ExtendedComponentViewid={childrenProps.idasstring}className={childrenProps.classNameasstring}>
246+
<ExtendedComponentView
247+
className={childrenProps.classNameasstring}
248+
dataTestId={childrenProps.dataTestIdasstring}
249+
>
245250
<HidableViewhidden={childrenProps.hiddenasboolean}>
246251
{props.viewFn(childrenProps,comp.dispatch)}
247252
</HidableView>

‎client/packages/lowcoder/src/i18n/locales/de.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ export const de = {
184184
"maskClosable":"Zum Schließen auf \"Draußen\" klicken",
185185
"showMask":"Maske zeigen",
186186
"component":"Komponente",
187-
"id":"ID",
188187
"className":"Klasse",
188+
"dataTestId":"Test ID",
189189
},
190190
"autoHeightProp":{
191191
"auto":"Auto",

‎client/packages/lowcoder/src/i18n/locales/en.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ export const en = {
212212
"horizontal":"Horizontal",
213213
"minHorizontalWidth":"Minimum Horizontal Width",
214214
"component":"Component",
215-
"id":"ID",
216215
"className":"Class",
216+
"dataTestId":"Test ID",
217217
},
218218
"autoHeightProp":{
219219
"auto":"Auto",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp