mirror of
https://github.com/lingble/twenty.git
synced 2025-10-29 11:52:28 +00:00
## What it does ### Backend - [x] Add a mutation to create OIDC and SAML configuration - [x] Add a mutation to delete an SSO config - [x] Add a feature flag to toggle SSO - [x] Add a mutation to activate/deactivate an SSO config - [x] Add a mutation to delete an SSO config - [x] Add strategy to use OIDC or SAML - [ ] Improve error management ### Frontend - [x] Add section "security" in settings - [x] Add page to list SSO configurations - [x] Add page and forms to create OIDC or SAML configuration - [x] Add field to "connect with SSO" in the signin/signup process - [x] Trigger auth when a user switch to a workspace with SSO enable - [x] Add an option on the security page to activate/deactivate the global invitation link - [ ] Add new Icons for SSO Identity Providers (okta, Auth0, Azure, Microsoft) --------- Co-authored-by: Félix Malfait <felix@twenty.com> Co-authored-by: Charles Bochet <charles@twenty.com>
131 lines
3.2 KiB
TypeScript
131 lines
3.2 KiB
TypeScript
import { useTheme } from '@emotion/react';
|
|
import styled from '@emotion/styled';
|
|
import React from 'react';
|
|
import { IconComponent } from 'twenty-ui';
|
|
|
|
export type MainButtonVariant = 'primary' | 'secondary';
|
|
|
|
type Props = {
|
|
title: string;
|
|
fullWidth?: boolean;
|
|
width?: number;
|
|
variant?: MainButtonVariant;
|
|
soon?: boolean;
|
|
} & React.ComponentProps<'button'>;
|
|
|
|
const StyledButton = styled.button<
|
|
Pick<Props, 'fullWidth' | 'width' | 'variant'>
|
|
>`
|
|
align-items: center;
|
|
background: ${({ theme, variant, disabled }) => {
|
|
if (disabled === true) {
|
|
return theme.background.secondary;
|
|
}
|
|
|
|
switch (variant) {
|
|
case 'primary':
|
|
return theme.background.primaryInverted;
|
|
case 'secondary':
|
|
return theme.background.primary;
|
|
default:
|
|
return theme.background.primary;
|
|
}
|
|
}};
|
|
border: 1px solid;
|
|
border-color: ${({ theme, disabled, variant }) => {
|
|
if (disabled === true) {
|
|
return theme.background.transparent.lighter;
|
|
}
|
|
|
|
switch (variant) {
|
|
case 'primary':
|
|
return theme.background.transparent.strong;
|
|
case 'secondary':
|
|
return theme.border.color.medium;
|
|
default:
|
|
return theme.background.primary;
|
|
}
|
|
}};
|
|
border-radius: ${({ theme }) => theme.border.radius.md};
|
|
${({ theme, disabled }) => {
|
|
if (disabled === true) {
|
|
return '';
|
|
}
|
|
|
|
return `box-shadow: ${theme.boxShadow.light};`;
|
|
}}
|
|
color: ${({ theme, variant, disabled }) => {
|
|
if (disabled === true) {
|
|
return theme.font.color.light;
|
|
}
|
|
|
|
switch (variant) {
|
|
case 'primary':
|
|
return theme.font.color.inverted;
|
|
case 'secondary':
|
|
return theme.font.color.primary;
|
|
default:
|
|
return theme.font.color.primary;
|
|
}
|
|
}};
|
|
cursor: ${({ disabled }) => (disabled ? 'not-allowed' : 'pointer')};
|
|
display: flex;
|
|
flex-direction: row;
|
|
font-family: ${({ theme }) => theme.font.family};
|
|
font-weight: ${({ theme }) => theme.font.weight.semiBold};
|
|
gap: ${({ theme }) => theme.spacing(2)};
|
|
justify-content: center;
|
|
outline: none;
|
|
padding: ${({ theme }) => theme.spacing(2)} ${({ theme }) => theme.spacing(3)};
|
|
max-height: ${({ theme }) => theme.spacing(8)};
|
|
width: ${({ fullWidth, width }) =>
|
|
fullWidth ? '100%' : width ? `${width}px` : 'auto'};
|
|
${({ theme, variant, disabled }) => {
|
|
switch (variant) {
|
|
case 'secondary':
|
|
return `
|
|
&:hover {
|
|
background: ${theme.background.tertiary};
|
|
}
|
|
`;
|
|
default:
|
|
return `
|
|
&:hover {
|
|
background: ${
|
|
!disabled
|
|
? theme.background.primaryInvertedHover
|
|
: theme.background.secondary
|
|
};};
|
|
}
|
|
`;
|
|
}
|
|
}};
|
|
`;
|
|
|
|
type MainButtonProps = Props & {
|
|
Icon?: IconComponent;
|
|
};
|
|
|
|
export const MainButton = ({
|
|
Icon,
|
|
title,
|
|
width,
|
|
fullWidth = false,
|
|
variant = 'primary',
|
|
type,
|
|
onClick,
|
|
disabled,
|
|
className,
|
|
}: MainButtonProps) => {
|
|
const theme = useTheme();
|
|
return (
|
|
<StyledButton
|
|
className={className}
|
|
{...{ disabled, fullWidth, width, onClick, type, variant }}
|
|
>
|
|
{Icon && <Icon size={theme.icon.size.sm} />}
|
|
{title}
|
|
</StyledButton>
|
|
);
|
|
};
|