mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-02 01:10:41 +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);
|
setIsLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const isInValidCertificate = useMemo(
|
const isInValidVerificate = useMemo(
|
||||||
() => !getIsValidCertificate(record?.samlConfig),
|
() => !getIsValidCertificate(record?.samlConfig),
|
||||||
[record],
|
[record],
|
||||||
);
|
);
|
||||||
@ -33,7 +33,7 @@ function SwitchComponent({
|
|||||||
return (
|
return (
|
||||||
<Switch
|
<Switch
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
disabled={isInValidCertificate}
|
disabled={isInValidVerificate}
|
||||||
checked={isChecked}
|
checked={isChecked}
|
||||||
onChange={onChangeHandler}
|
onChange={onChangeHandler}
|
||||||
/>
|
/>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { LockTwoTone } from '@ant-design/icons';
|
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 { ColumnsType } from 'antd/lib/table';
|
||||||
import deleteDomain from 'api/SAML/deleteDomain';
|
import deleteDomain from 'api/SAML/deleteDomain';
|
||||||
import listAllDomain from 'api/SAML/listAllDomain';
|
import listAllDomain from 'api/SAML/listAllDomain';
|
||||||
@ -20,7 +20,6 @@ import AddDomain from './AddDomain';
|
|||||||
import Create from './Create';
|
import Create from './Create';
|
||||||
import EditSaml from './Edit';
|
import EditSaml from './Edit';
|
||||||
import SwitchComponent from './Switch';
|
import SwitchComponent from './Switch';
|
||||||
import { getIsValidCertificate } from './utils';
|
|
||||||
|
|
||||||
function AuthDomains(): JSX.Element {
|
function AuthDomains(): JSX.Element {
|
||||||
const { t } = useTranslation(['common', 'organizationsettings']);
|
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 (
|
return (
|
||||||
<Button type="link" onClick={onEditHandler(record)}>
|
<Button type="link" onClick={onEditHandler(record)}>
|
||||||
Edit SSO
|
Edit SSO
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
export const getIsValidCertificate = (
|
import { SAMLConfig } from 'types/api/SAML/listDomain';
|
||||||
config: Record<string, string>,
|
|
||||||
): boolean =>
|
export const getIsValidCertificate = (config: SAMLConfig): boolean => {
|
||||||
config?.samlCert.length !== 0 &&
|
if (config === null) {
|
||||||
config?.samlEntity.length !== 0 &&
|
return false;
|
||||||
config?.samlIdp.length !== 0;
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
config?.samlCert?.length !== 0 &&
|
||||||
|
config?.samlEntity?.length !== 0 &&
|
||||||
|
config?.samlIdp?.length !== 0
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
import { Organization } from '../user/getOrganization';
|
import { Organization } from '../user/getOrganization';
|
||||||
|
|
||||||
|
export interface SAMLConfig {
|
||||||
|
samlEntity: string;
|
||||||
|
samlIdp: string;
|
||||||
|
samlCert: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface SAMLDomain {
|
export interface SAMLDomain {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
orgId: Organization['id'];
|
orgId: Organization['id'];
|
||||||
ssoEnabled: boolean;
|
ssoEnabled: boolean;
|
||||||
ssoType: 'SAML';
|
ssoType: 'SAML';
|
||||||
samlConfig: {
|
samlConfig: SAMLConfig;
|
||||||
samlEntity: string;
|
|
||||||
samlIdp: string;
|
|
||||||
samlCert: string;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user