Skip to content

Commit 704a160

Browse files
committed
Merge branch 'dev' of github.com:lowcoder-org/lowcoder into dev
2 parents 156b06a + adacf37 commit 704a160

File tree

6 files changed

+57
-44
lines changed

6 files changed

+57
-44
lines changed

client/packages/lowcoder/src/comps/comps/tableComp/column/columnTypeComps/columnSwitchComp.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ const childrenMap = {
6969

7070
const getBaseValue: ColumnTypeViewFn<typeof childrenMap, boolean, boolean> = (props) => props.switchState;
7171

72+
let onEvent: (eventName: string) => Promise<unknown[]>;
73+
7274
export const SwitchComp = (function () {
7375
return new ColumnTypeCompBuilder(
7476
childrenMap,
7577
(props, dispatch) => {
78+
onEvent = props.onEvent;
7679
const value = props.changeValue ?? getBaseValue(props, dispatch);
7780
const CheckBoxComp = () => {
7881
return (
@@ -106,6 +109,8 @@ export const SwitchComp = (function () {
106109
disabled={false}
107110
onChange={(checked, e) => {
108111
props.onChange(checked);
112+
onEvent?.("change");
113+
onEvent?.(checked ? "true" : "false");
109114
}}
110115
/>
111116
</Wrapper>

client/packages/lowcoder/src/comps/hooks/localStorageComp.ts

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,28 @@ const APP_STORE_NAMESPACE = "lowcoder_app_local_storage";
1313
const LocalStorageCompBase = withViewFn(
1414
simpleMultiComp({ values: stateComp<JSONObject>({}) }),
1515
(comp) => {
16-
const originStore = localStorage.getItem(APP_STORE_NAMESPACE) || "{}";
17-
let parseStore = {};
18-
try {
19-
parseStore = JSON.parse(originStore);
20-
} catch (e) {
21-
log.error("application local storage invalid");
22-
}
23-
16+
// add custom event listener to update values reactively
2417
useEffect(() => {
25-
const value = comp.children.values.value;
26-
if (!isEqual(value, parseStore)) {
27-
log.info(value, parseStore);
28-
comp.children.values.dispatchChangeValueAction(parseStore);
29-
}
30-
}, [parseStore]);
18+
const handler = () => {
19+
try {
20+
const raw = localStorage.getItem(APP_STORE_NAMESPACE) || "{}";
21+
const parsed = JSON.parse(raw);
22+
comp.children.values.dispatchChangeValueAction(parsed);
23+
} catch (e) {
24+
log.error("Failed to parse localStorage:", e);
25+
}
26+
};
27+
28+
// Add listener on mount
29+
window.addEventListener("lowcoder-localstorage-updated", handler);
30+
31+
// Run once on mount to initialize
32+
handler();
33+
34+
return () => {
35+
window.removeEventListener("lowcoder-localstorage-updated", handler);
36+
};
37+
}, []);
3138

3239
return null;
3340
}
@@ -62,6 +69,8 @@ LocalStorageComp = withMethodExposing(LocalStorageComp, [
6269
parseStore[key] = value;
6370
localStorage.setItem(APP_STORE_NAMESPACE, JSON.stringify(parseStore));
6471
comp.children.values.dispatchChangeValueAction(parseStore);
72+
73+
window.dispatchEvent(new CustomEvent("lowcoder-localstorage-updated"));
6574
} catch (e) {
6675
localStorage.setItem(APP_STORE_NAMESPACE, "{}");
6776
}
@@ -83,6 +92,9 @@ LocalStorageComp = withMethodExposing(LocalStorageComp, [
8392
delete parseStore[key];
8493
localStorage.setItem(APP_STORE_NAMESPACE, JSON.stringify(parseStore));
8594
comp.children.values.dispatchChangeValueAction(parseStore);
95+
96+
// Trigger update
97+
window.dispatchEvent(new CustomEvent("lowcoder-localstorage-updated"));
8698
} catch (e) {
8799
localStorage.setItem(APP_STORE_NAMESPACE, "{}");
88100
}
@@ -98,6 +110,9 @@ LocalStorageComp = withMethodExposing(LocalStorageComp, [
98110
execute: (comp) => {
99111
localStorage.removeItem(APP_STORE_NAMESPACE);
100112
comp.children.values.dispatchChangeValueAction({});
113+
114+
// Trigger update
115+
window.dispatchEvent(new CustomEvent("lowcoder-localstorage-updated"));
101116
},
102117
},
103118
]);

client/packages/lowcoder/src/pages/userAuth/register.tsx

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,28 @@ function UserRegister() {
9595
setSigninEnabled(LOWCODER_EMAIL_AUTH_ENABLED === 'true');
9696
}, [serverSettings]);
9797

98+
const fetchOrgsByEmail = () => {
99+
fetchOrgPaginationByEmail({
100+
email: ' ',
101+
pageNum: 1,
102+
pageSize: 10,
103+
})
104+
.then((resp) => {
105+
if (resp.success) {
106+
const orgList = resp.data || [];
107+
if (orgList.length) {
108+
// in Enterprise mode, we will get org data in different format
109+
const selectedOrgId = orgList[0]?.id || orgList[0]?.orgId;
110+
setDefaultOrgId(selectedOrgId);
111+
dispatch(fetchConfigAction(selectedOrgId));
112+
}
113+
}
114+
})
115+
}
116+
98117
useEffect(() => {
99118
if (isEnterpriseMode) {
100-
// dispatch(fetchConfigAction());
101-
fetchOrgPaginationByEmail({
102-
email: ' ',
103-
pageNum: 1,
104-
pageSize: 10,
105-
})
106-
.then((resp) => {
107-
if (resp.success) {
108-
const orgList = resp.data || [];
109-
if (orgList.length) {
110-
// in Enterprise mode, we will get org data in different format
111-
const selectedOrgId = orgList[0]?.id || orgList[0]?.orgId;
112-
setDefaultOrgId(selectedOrgId);
113-
dispatch(fetchConfigAction(selectedOrgId));
114-
}
115-
}
116-
})
119+
fetchOrgsByEmail();
117120
}
118121
}, [isEnterpriseMode]);
119122

server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/usermanagement/OrganizationController.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,7 @@ public Mono<PageResponseView<?>> getOrganizationByUser(@PathVariable String emai
6868
.map(OrgView::new)
6969
.cache();
7070
} else {
71-
// Not SAAS: check if user exists and is a member of the org
72-
flux = userService.findByEmailDeep(email)
73-
.flatMapMany(user ->
74-
organizationService.getOrganizationInEnterpriseMode().flux()
75-
.flatMap(org ->
76-
orgMemberService.getOrgMember(org.getId(), user.getId())
77-
.filter(orgMember -> !orgMember.isInvalid())
78-
.map(__ -> new OrgView(org))
79-
)
80-
)
81-
.cache();
71+
flux = organizationService.getOrganizationInEnterpriseMode().flux().map(OrgView::new).cache();
8272
}
8373
var newflux = flux.sort((OrgView o1, OrgView o2) -> {
8474
if (o1.getOrgName() == null || o2.getOrgName() == null) {

server/api-service/lowcoder-server/src/test/java/org/lowcoder/api/authentication/GenericAuthenticateTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public void testGoogleLoginSuccess(WireMockRuntimeInfo wmRuntimeInfo) {
182182
})
183183
.verifyComplete();
184184

185-
Mockito.framework().clearInlineMocks();
185+
// Mockito.framework().clearInlineMocks();
186186
}
187187

188188
private String getEmailAuthConfigId() {

server/api-service/lowcoder-server/src/test/java/org/lowcoder/api/common/TestRedisConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import java.util.concurrent.atomic.AtomicInteger;
1111

1212
@SuppressWarnings("UnstableApiUsage")
13-
//@TestConfiguration
13+
@TestConfiguration
1414
public class TestRedisConfiguration {
1515

1616
private static final AtomicInteger STATE = new AtomicInteger(0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy