Skip to content

Commit b24006d

Browse files
add source categories
1 parent a314888 commit b24006d

File tree

2 files changed

+42
-12
lines changed

2 files changed

+42
-12
lines changed

client/packages/lowcoder/src/pages/setting/idSource/OAuthForms/GenericOAuthForm.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from "react";
2-
import { messageInstance, CloseEyeIcon } from "lowcoder-design";
2+
import { messageInstance, CloseEyeIcon, CustomSelect } from "lowcoder-design";
33
import { i18nObjs, trans } from "i18n";
44
import {
55
FormStyled,
@@ -107,7 +107,7 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
107107
setSaveLoading(true);
108108
const { issuer } = values;
109109
try {
110-
const res = await axios.get<OpenIdProvider>(`${issuer}/.well-known/openid-configuration`);
110+
const res = await axios.get<OpenIdProvider>(issuer);
111111
setIssuerDetails(() => {
112112
const issuer = {
113113
authType: AuthType.Generic,
@@ -189,6 +189,7 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
189189
current={currentStep}
190190
items={steps}
191191
style={{marginBottom: '16px'}}
192+
onChange={(current) => setCurrentStep(current)}
192193
/>
193194

194195
<FormStyled
@@ -213,11 +214,13 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
213214
)}
214215
{currentStep === 1 && Object.entries(authConfigForm).map(([key, value]) => {
215216
const valueObject = _.isObject(value) ? (value as ItemType) : false;
216-
const required = true;
217+
let required = (key === "clientId" || key === "clientSecret" || key === "scope");
218+
required = valueObject ? valueObject.isRequire ?? required : required;
217219
const label = valueObject ? valueObject.label : value as string;
218220
const tip = valueObject && valueObject.tip;
219221
const isPassword = valueObject && valueObject.isPassword;
220222
const isIcon = valueObject && valueObject.isIcon;
223+
const isList = valueObject && valueObject.isList;
221224
return (
222225
<div key={key}>
223226
<Form.Item
@@ -250,12 +253,19 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
250253
placeholder={trans("idSource.encryptedServer")}
251254
autoComplete={"one-time-code"}
252255
/>
253-
) : isIcon ? (
256+
) : !isPassword && !isList && isIcon ? (
254257
<IconPicker
255258
onChange={(value) => form1.setFieldValue("sourceIcon", value)}
256259
label={'Source Icon'}
257260
value={form1.getFieldValue('sourceIcon')}
258261
/>
262+
) : !isPassword && isList && !isIcon ? (
263+
<CustomSelect
264+
options={(value as ItemType).options}
265+
placeholder={trans("idSource.formSelectPlaceholder", {
266+
label,
267+
})}
268+
/>
259269
) : (
260270
<Input
261271
placeholder={trans("idSource.formPlaceholder", {

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

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ export const IdSource = [
1919
AuthType.Generic,
2020
];
2121

22+
export enum AuthCategoriesEnum {
23+
ENTERPISE_ENTITY = "Enterprise Identity",
24+
CLOUD_SERVICES = "Cloud Services",
25+
SOCIAL_MEDIA = "Social Media",
26+
DEVELOPMENT = "Development",
27+
TOOLS_AND_PRODUCTIVITY = "Tools & Productivity",
28+
}
29+
30+
type AuthCategoriesEnumKey = keyof typeof AuthCategoriesEnum;
31+
const AuthCategories = Object.keys(AuthCategoriesEnum).map(
32+
(cat) => {
33+
const value = AuthCategoriesEnum[cat as AuthCategoriesEnumKey];
34+
return {
35+
label: value,
36+
value: cat
37+
}
38+
}
39+
);
40+
41+
2242
export const validatorOptions = [];
2343

2444
export const clientIdandSecretConfig = {
@@ -70,15 +90,15 @@ export const authConfig = {
7090
form: {
7191
source: { label: "Source", isRequire: true },
7292
sourceName: { label: "Source Name", isRequire: true },
73-
sourceDescription: { label: "Source Description" },
74-
sourceIcon: { label: "Source Icon", isIcon: true },
75-
sourceCategory: { label: "Source Category" },
93+
sourceDescription: { label: "Source Description", isRequire: false },
94+
sourceIcon: { label: "Source Icon", isIcon: true, isRequire: true, },
95+
sourceCategory: { label: "Source Category", isRequire: true, isList: true, options: AuthCategories },
7696
...clientIdandSecretConfig,
77-
issuer: { label: 'Issuer URI', isRequired: true },
78-
authorizationEndpoint: { label: 'Authorization Endpoint', isRequired: true },
79-
tokenEndpoint: { label: 'Token Endpoint', isRequired: true },
80-
userInfoEndpoint: { label: 'UserInfo Endpoint', isRequired: true },
81-
// jwks: { label: 'Authorize URL', isRequired: true },
97+
issuer: { label: 'Issuer URI', isRequire: true },
98+
authorizationEndpoint: { label: 'Authorization Endpoint', isRequire: true },
99+
tokenEndpoint: { label: 'Token Endpoint', isRequire: true },
100+
userInfoEndpoint: { label: 'UserInfo Endpoint', isRequire: true },
101+
// jwks: { label: 'Authorize URL', isRequire: true },
82102
scope: "Scope",
83103
// baseUrl: "Base URL",
84104
// realm: "Realm",

0 commit comments

Comments
 (0)