mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-31 07:02:03 +08:00
fix: if invalid switch is disabled (#1656)
Co-authored-by: Ankit Nayan <ankit@signoz.io>
This commit is contained in:
parent
00863e54de
commit
4727dbc9f0
@ -25,7 +25,7 @@ function SwitchComponent({
|
||||
setIsLoading(false);
|
||||
};
|
||||
|
||||
const isInValidCertificate = useMemo(
|
||||
const isInValidVerificate = useMemo(
|
||||
() => !getIsValidCertificate(record?.samlConfig),
|
||||
[record],
|
||||
);
|
||||
@ -33,7 +33,7 @@ function SwitchComponent({
|
||||
return (
|
||||
<Switch
|
||||
loading={isLoading}
|
||||
disabled={isInValidCertificate}
|
||||
disabled={isInValidVerificate}
|
||||
checked={isChecked}
|
||||
onChange={onChangeHandler}
|
||||
/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { LockTwoTone } from '@ant-design/icons';
|
||||
import { Button, Modal, notification, Space, Table, Typography } from 'antd';
|
||||
import { Button, Modal, notification, Space, Table } from 'antd';
|
||||
import { ColumnsType } from 'antd/lib/table';
|
||||
import deleteDomain from 'api/SAML/deleteDomain';
|
||||
import listAllDomain from 'api/SAML/listAllDomain';
|
||||
@ -20,7 +20,6 @@ import AddDomain from './AddDomain';
|
||||
import Create from './Create';
|
||||
import EditSaml from './Edit';
|
||||
import SwitchComponent from './Switch';
|
||||
import { getIsValidCertificate } from './utils';
|
||||
|
||||
function AuthDomains(): JSX.Element {
|
||||
const { t } = useTranslation(['common', 'organizationsettings']);
|
||||
@ -196,12 +195,6 @@ function AuthDomains(): JSX.Element {
|
||||
);
|
||||
}
|
||||
|
||||
const isValidCertificate = getIsValidCertificate(record.samlConfig);
|
||||
|
||||
if (!isValidCertificate) {
|
||||
return <Typography>Configure SSO </Typography>;
|
||||
}
|
||||
|
||||
return (
|
||||
<Button type="link" onClick={onEditHandler(record)}>
|
||||
Edit SSO
|
||||
|
@ -1,6 +1,13 @@
|
||||
export const getIsValidCertificate = (
|
||||
config: Record<string, string>,
|
||||
): boolean =>
|
||||
config?.samlCert.length !== 0 &&
|
||||
config?.samlEntity.length !== 0 &&
|
||||
config?.samlIdp.length !== 0;
|
||||
import { SAMLConfig } from 'types/api/SAML/listDomain';
|
||||
|
||||
export const getIsValidCertificate = (config: SAMLConfig): boolean => {
|
||||
if (config === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
config?.samlCert?.length !== 0 &&
|
||||
config?.samlEntity?.length !== 0 &&
|
||||
config?.samlIdp?.length !== 0
|
||||
);
|
||||
};
|
||||
|
@ -1,16 +1,18 @@
|
||||
import { Organization } from '../user/getOrganization';
|
||||
|
||||
export interface SAMLConfig {
|
||||
samlEntity: string;
|
||||
samlIdp: string;
|
||||
samlCert: string;
|
||||
}
|
||||
|
||||
export interface SAMLDomain {
|
||||
id: string;
|
||||
name: string;
|
||||
orgId: Organization['id'];
|
||||
ssoEnabled: boolean;
|
||||
ssoType: 'SAML';
|
||||
samlConfig: {
|
||||
samlEntity: string;
|
||||
samlIdp: string;
|
||||
samlCert: string;
|
||||
};
|
||||
samlConfig: SAMLConfig;
|
||||
}
|
||||
|
||||
export interface Props {
|
||||
|
Loading…
x
Reference in New Issue
Block a user