Skip to content

Commit a92a113

Browse files
added icon selector for sourceIcon
1 parent 32d2bb6 commit a92a113

File tree

6 files changed

+52
-34
lines changed

6 files changed

+52
-34
lines changed

client/packages/lowcoder-design/src/components/iconSelect/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export const IconSelect = (props: {
398398
visible={visible}
399399
setVisible={setVisible}
400400
trigger="click"
401-
leftOffset={-96}
401+
leftOffset={-30}
402402
searchKeywords={props.searchKeywords}
403403
/>
404404
);

client/packages/lowcoder/src/comps/controls/iconControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const Wrapper = styled.div`
7070
}
7171
`;
7272

73-
const IconPicker = (props: {
73+
export const IconPicker = (props: {
7474
value: string;
7575
onChange: (value: string) => void;
7676
label?: ReactNode;

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

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useState } from "react";
22
import { messageInstance, CloseEyeIcon } from "lowcoder-design";
3-
import { trans } from "i18n";
3+
import { i18nObjs, trans } from "i18n";
44
import {
55
FormStyled,
66
PasswordLabel,
77
StyledSteps
88
} from "../styledComponents";
9-
import { default as Form } from "antd/es/form";
9+
import { default as Form, FormInstance } from "antd/es/form";
1010
import { default as Input } from "antd/es/input";
1111
import { default as Tooltip } from "antd/es/tooltip";
1212
import IdSourceApi, { ConfigItem } from "api/idSourceApi";
@@ -16,6 +16,7 @@ import _ from "lodash";
1616
import Flex from "antd/es/flex";
1717
import Button from "antd/es/button";
1818
import axios from "axios";
19+
import { IconPicker } from "@lowcoder-ee/comps/controls/iconControl";
1920

2021
const sourceMappingKeys = [
2122
'uid',
@@ -80,7 +81,7 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
8081

8182
const [saveLoading, setSaveLoading] = useState(false);
8283
const [currentStep, setCurrentStep] = useState(0);
83-
const [issuerDetails, setIssuerDetails] = useState<ConfigProvider>();
84+
const [issuerDetails, setIssuerDetails] = useState<ConfigProvider | {}>({});
8485

8586
function saveAuthProvider(values: ConfigItem) {
8687
setSaveLoading(true);
@@ -105,31 +106,32 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
105106
form1.validateFields().then(async (values) => {
106107
setSaveLoading(true);
107108
const { issuer } = values;
108-
const res = await axios.get<OpenIdProvider>(`${issuer}/.well-known/openid-configuration`);
109-
setSaveLoading(false);
110-
111-
if (res.status >= 400) {
112-
return null;
109+
try {
110+
const res = await axios.get<OpenIdProvider>(`${issuer}/.well-known/openid-configuration`);
111+
setIssuerDetails(() => {
112+
const issuer = {
113+
authType: AuthType.Generic,
114+
source: '',
115+
sourceName: '',
116+
issuer: res.data.issuer,
117+
authorizationEndpoint: res.data.authorization_endpoint,
118+
tokenEndpoint: res.data.token_endpoint,
119+
userInfoEndpoint: res.data.userinfo_endpoint,
120+
jwksUri: res.data.jwks_uri,
121+
scope: res.data.scopes_supported.join(','),
122+
sourceMappings: sourceMappingKeys.map(sourceKey => ({
123+
[sourceKey]: sourceKey,
124+
}))
125+
};
126+
form1.setFieldsValue(issuer);
127+
return issuer;
128+
})
129+
} catch (e) {
130+
setIssuerDetails({});
131+
} finally {
132+
setSaveLoading(false);
133+
setCurrentStep(currentStep => currentStep + 1);
113134
}
114-
setIssuerDetails(() => {
115-
const issuer = {
116-
authType: AuthType.Generic,
117-
source: '',
118-
sourceName: '',
119-
issuer: res.data.issuer,
120-
authorizationEndpoint: res.data.authorization_endpoint,
121-
tokenEndpoint: res.data.token_endpoint,
122-
userInfoEndpoint: res.data.userinfo_endpoint,
123-
jwksUri: res.data.jwks_uri,
124-
scope: res.data.scopes_supported.join(','),
125-
sourceMappings: sourceMappingKeys.map(sourceKey => ({
126-
[sourceKey]: sourceKey,
127-
}))
128-
};
129-
form1.setFieldsValue(issuer);
130-
return issuer;
131-
})
132-
setCurrentStep(currentStep => currentStep + 1);
133135
})
134136
}
135137

@@ -215,6 +217,7 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
215217
const label = valueObject ? valueObject.label : value as string;
216218
const tip = valueObject && valueObject.tip;
217219
const isPassword = valueObject && valueObject.isPassword;
220+
const isIcon = valueObject && valueObject.isIcon;
218221
return (
219222
<div key={key}>
220223
<Form.Item
@@ -247,6 +250,12 @@ function GenericOAuthForm(props: GenericOAuthFormProp) {
247250
placeholder={trans("idSource.encryptedServer")}
248251
autoComplete={"one-time-code"}
249252
/>
253+
) : isIcon ? (
254+
<IconPicker
255+
onChange={(value) => form1.setFieldValue("sourceIcon", value)}
256+
label={'Source Icon'}
257+
value={form1.getFieldValue('sourceIcon')}
258+
/>
250259
) : (
251260
<Input
252261
placeholder={trans("idSource.formPlaceholder", {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { validateResponse } from "api/apiUtils";
3737
import { ItemType } from "pages/setting/idSource/idSourceConstants";
3838
import _ from "lodash";
3939
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
40+
import { IconPicker } from "@lowcoder-ee/comps/controls/iconControl";
4041

4142
type IdSourceDetailProps = {
4243
location: Location & { state: ConfigItem };
@@ -163,6 +164,7 @@ export const IdSourceDetail = (props: IdSourceDetailProps) => {
163164
const label = valueObject ? valueObject.label : value as string;
164165
const isList = valueObject && valueObject.isList;
165166
const isPassword = valueObject && valueObject.isPassword;
167+
const isIcon = valueObject && valueObject.isIcon;
166168
return (
167169
<div key={key}>
168170
<Form.Item
@@ -206,7 +208,7 @@ export const IdSourceDetail = (props: IdSourceDetailProps) => {
206208
}
207209
autoComplete={"one-time-code"}
208210
/>
209-
) : !isPassword && !isList ? (
211+
) : !isPassword && !isList && !isIcon ? (
210212
<Input
211213
placeholder={trans("idSource.formPlaceholder", {
212214
label,
@@ -217,6 +219,12 @@ export const IdSourceDetail = (props: IdSourceDetailProps) => {
217219
(lock ? <LockIcon onClick={() => handleLockClick()} /> : <UnLockIcon />)
218220
}
219221
/>
222+
) : !isPassword && !isList && isIcon ? (
223+
<IconPicker
224+
onChange={(value) => form.setFieldValue("sourceIcon", value)}
225+
label={'Source Icon'}
226+
value={form.getFieldValue('sourceIcon')}
227+
/>
220228
) : (
221229
<CustomSelect
222230
options={(value as ItemType).options}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const authConfig = {
7171
source: { label: "Source", isRequire: true },
7272
sourceName: { label: "Source Name", isRequire: true },
7373
sourceDescription: { label: "Source Description" },
74-
sourceIcon: { label: "Source Icon" },
74+
sourceIcon: { label: "Source Icon", isIcon: true },
7575
sourceCategory: { label: "Source Category" },
7676
...clientIdandSecretConfig,
7777
issuer: { label: 'Issuer URI', isRequired: true },
@@ -105,6 +105,7 @@ export type ItemType = {
105105
isList?: boolean;
106106
isRequire?: boolean;
107107
isPassword?: boolean;
108+
isIcon?: boolean;
108109
hasLock?: boolean;
109110
tip?: string;
110111
}

client/packages/lowcoder/src/pages/setting/styled.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ export const ModalNameDiv = styled.div`
6969
`;
7070

7171
export const CustomModalStyled = styled(CustomModal)`
72-
button {
73-
margin-top: 20px;
74-
}
72+
// button {
73+
// margin-top: 20px;
74+
// }
7575
`;
7676

7777
export const TacoInputStyled = styled(TacoInput)`

0 commit comments

Comments
 (0)