Skip to content

Commit f2ae2de

Browse files
feat: instanceId, realm, scope added for ORY/KeyCloak
1 parent 55d1b17 commit f2ae2de

File tree

4 files changed

+80
-14
lines changed

4 files changed

+80
-14
lines changed

client/packages/lowcoder/src/pages/setting/idSource/createModal.tsx

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import { useEffect, useMemo, useState } from "react";
22
import { messageInstance, CustomSelect, CloseEyeIcon } from "lowcoder-design";
33
import {
44
CustomModalStyled,
@@ -10,12 +10,13 @@ import {
1010
SpanStyled,
1111
PasswordLabel
1212
} from "./styledComponents";
13-
import { Form, Input, Select } from "antd";
13+
import { Form, Input, Select, Tooltip } from "antd";
1414
import IdSourceApi, { ConfigItem } from "api/idSourceApi";
1515
import { validateResponse } from "api/apiUtils";
16-
import { authConfig, AuthType } from "./idSourceConstants";
16+
import { authConfig, AuthType, clientIdandSecretConfig, ItemType } from "./idSourceConstants";
1717
import { ServerAuthTypeInfo } from "constants/authConstants";
1818
import { GeneralLoginIcon } from "assets/icons";
19+
import _ from "lodash";
1920

2021
type CreateModalProp = {
2122
modalVisible: boolean;
@@ -42,7 +43,11 @@ function CreateModal(props: CreateModalProp) {
4243
}
4344
function saveAuthProvider(values: ConfigItem) {
4445
setSaveLoading(true);
45-
IdSourceApi.saveConfig(values)
46+
const config = {
47+
...values,
48+
enableRegister: true,
49+
}
50+
IdSourceApi.saveConfig(config)
4651
.then((resp) => {
4752
if (validateResponse(resp)) {
4853
messageInstance.success(trans("idSource.saveSuccess"));
@@ -69,6 +74,13 @@ function CreateModal(props: CreateModalProp) {
6974
value: config.sourceValue,
7075
}));
7176

77+
const selectedAuthType = Form.useWatch('authType', form);;
78+
79+
const authConfigForm = useMemo(() => {
80+
if(!authConfig[selectedAuthType]) return clientIdandSecretConfig;
81+
return authConfig[selectedAuthType].form;
82+
}, [selectedAuthType])
83+
7284
return (
7385
<CustomModalStyled
7486
width="500px"
@@ -115,7 +127,56 @@ function CreateModal(props: CreateModalProp) {
115127
))}
116128
</CustomSelect>
117129
</Form.Item>
118-
<Form.Item
130+
{Object.entries(authConfigForm).map(([key, value]) => {
131+
const valueObject = _.isObject(value) ? (value as ItemType) : false;
132+
const required = true;
133+
const label = valueObject ? valueObject.label : value;
134+
const tip = valueObject && valueObject.tip;
135+
const isPassword = valueObject && valueObject.isPassword;
136+
return (
137+
<div key={key}>
138+
<Form.Item
139+
key={key}
140+
name={key}
141+
rules={[
142+
{
143+
required,
144+
message: trans("idSource.formPlaceholder", {
145+
label,
146+
}),
147+
},
148+
]}
149+
label={
150+
isPassword ? (
151+
<PasswordLabel>
152+
<span>{label}:</span>
153+
<CloseEyeIcon />
154+
</PasswordLabel>
155+
) : (
156+
<Tooltip title={tip}>
157+
<span className={tip ? "has-tip" : ""}>{label}</span>:
158+
</Tooltip>
159+
)
160+
}
161+
>
162+
{isPassword ? (
163+
<Input
164+
type={"password"}
165+
placeholder={trans("idSource.encryptedServer")}
166+
autoComplete={"one-time-code"}
167+
/>
168+
) : (
169+
<Input
170+
placeholder={trans("idSource.formPlaceholder", {
171+
label,
172+
})}
173+
/>
174+
)}
175+
</Form.Item>
176+
</div>
177+
);
178+
})}
179+
{/* <Form.Item
119180
name="clientId"
120181
label="Client ID"
121182
rules={[{ required: true }]}
@@ -147,10 +208,7 @@ function CreateModal(props: CreateModalProp) {
147208
placeholder={trans("idSource.encryptedServer")}
148209
autoComplete="off"
149210
/>
150-
</Form.Item>
151-
<Form.Item className="register" name="enableRegister" valuePropName="checked">
152-
<CheckboxStyled>{trans("idSource.enableRegister")}</CheckboxStyled>
153-
</Form.Item>
211+
</Form.Item> */}
154212
</FormStyled>
155213
</CustomModalStyled>
156214
);

client/packages/lowcoder/src/pages/setting/idSource/detail/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ export const IdSourceDetail = (props: IdSourceDetailProps) => {
231231
</div>
232232
);
233233
})}
234-
<Form.Item className="register" name="enableRegister" valuePropName="checked">
234+
{/* <Form.Item className="register" name="enableRegister" valuePropName="checked">
235235
<CheckboxStyled>{trans("idSource.enableRegister")}</CheckboxStyled>
236-
</Form.Item>
236+
</Form.Item> */}
237237

238238
<Form.Item>
239239
<SaveButton loading={saveLoading} disabled={saveDisable} htmlType="submit">

client/packages/lowcoder/src/pages/setting/idSource/idSourceConstants.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,21 @@ export const authConfig = {
4646
[AuthType.Ory]: {
4747
sourceName: "Ory",
4848
sourceValue: AuthType.Ory,
49-
form: clientIdandSecretConfig,
49+
form: {
50+
...clientIdandSecretConfig,
51+
instanceId: "Instance ID",
52+
scope: "Scope",
53+
},
5054
},
5155
[AuthType.KeyCloak]: {
5256
sourceName: "KeyCloak",
5357
sourceValue: AuthType.KeyCloak,
54-
form: clientIdandSecretConfig,
58+
form: {
59+
...clientIdandSecretConfig,
60+
instanceId: "Instance ID",
61+
realm: "Realm",
62+
scope: "Scope",
63+
},
5564
},
5665
} as { [key: string]: { sourceName: string; sourceValue: AuthType, form: FormItemType } };
5766

client/packages/lowcoder/src/pages/setting/idSource/list.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export const IdSourceList = (props: any) => {
6464
IdSource.includes(item.authType)
6565
);
6666
res = _.uniqBy(res, 'authType');
67-
console.log(res)
6867
setConfigs(res);
6968
}
7069
})

0 commit comments

Comments
 (0)