Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(subdomain): use subdomain by workspace #8378

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3b9ea30
feat(front): allow usage of subdomain in dev env
AMoreaux Oct 28, 2024
d614adc
feat(*): allow to use subdomain
AMoreaux Oct 29, 2024
f4bff01
feat(settings): allow to choose auth methods
AMoreaux Nov 7, 2024
b3d6dd0
feat(subdomain): remove lastAuthenticateWorkspace on logout
AMoreaux Nov 7, 2024
0df3615
feat(front): fix eslint
AMoreaux Nov 7, 2024
a29527b
feat(server): fix eslint
AMoreaux Nov 7, 2024
d964f14
feat(subdomain): improve login flow on home page
AMoreaux Nov 8, 2024
d80e940
feat(front): improve SettingsOptionCardContent
AMoreaux Nov 8, 2024
6585655
feat(subdomain): improve signinup
AMoreaux Nov 12, 2024
8050c5a
feat(subdomain): create WorkspaceProviderEffect
AMoreaux Nov 12, 2024
7175b6d
feat(subdomain): add env var IS_MULTIWORKSPACE_ENABLED + add link on …
AMoreaux Nov 12, 2024
2e7a73c
Merge remote-tracking branch 'upstream/main' into feat/use-subdomain-…
AMoreaux Nov 12, 2024
cc06d79
feat(sso|subdomain): Refactor SSO service URL handling and improve SA…
AMoreaux Nov 13, 2024
24da8ba
feat(auth): Introduce SSO Identity Provider Selection
AMoreaux Nov 13, 2024
0f9eb2b
refactor(auth): reorganize sign-in/up components
AMoreaux Nov 14, 2024
9d505f0
Merge remote-tracking branch 'upstream/main' into feat/use-subdomain-…
AMoreaux Nov 14, 2024
f63f488
feat(auth): Consolidate HorizontalSeparator imports
AMoreaux Nov 14, 2024
04c0901
refactor: Remove findAvailableWorkspacesByEmail query
AMoreaux Nov 15, 2024
2817e20
chore: remove unused hook and enhance token handling
AMoreaux Nov 18, 2024
1487f47
Merge remote-tracking branch 'upstream/main' into feat/use-subdomain-…
AMoreaux Nov 18, 2024
9f3ac47
refactor(auth): remove workspace ID from login token generation
AMoreaux Nov 18, 2024
29fec52
refactor: update security item display in navigation drawer
AMoreaux Nov 18, 2024
ca721f7
refactor(auth): remove workspace selection feature
AMoreaux Nov 18, 2024
8ade0e3
feat(workspace): add support for multiworkspace subdomains
AMoreaux Nov 18, 2024
5dfbf8e
Merge remote-tracking branch 'upstream/main' into feat/use-subdomain-…
AMoreaux Nov 18, 2024
0dea459
fix(auth, workspace): correct workspace length check and subdomain ha…
AMoreaux Nov 18, 2024
90ec8f8
feat(settings): conditionally render domain section
AMoreaux Nov 18, 2024
d1047ec
refactor(twenty-ui): Revert change on MenuItemSelect and Select
AMoreaux Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/twenty-front/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ GENERATE_SOURCEMAP=false

# ———————— Optional ————————
# REACT_APP_PORT=3001
# REACT_APP_BASE_URL=http://localhost
# CHROMATIC_PROJECT_TOKEN=
# VITE_DISABLE_TYPESCRIPT_CHECKER=true
# VITE_DISABLE_ESLINT_CHECKER=true
# VITE_DISABLE_ESLINT_CHECKER=true

###### --------------> !!! FOR CHARLES AND FELIX !!! we can create a gist in twenty if you want <---------------------------
###### To configure a local certificate you can follow these step https://gist.github.com/AMoreaux/635ca9c38924d42a4d914dabe4376f72
# SSL_KEY_PATH="~/certs/your-cert.key"
# SSL_CERT_PATH="~/certs/your-cert.crt"
2 changes: 1 addition & 1 deletion packages/twenty-front/src/generated-metadata/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export type ClientConfig = {
debugMode: Scalars['Boolean']['output'];
sentry: Sentry;
signInPrefilled: Scalars['Boolean']['output'];
signUpDisabled: Scalars['Boolean']['output'];
isMultiworkspaceEnabled: Scalars['Boolean']['output'];
support: Support;
};

Expand Down
379 changes: 224 additions & 155 deletions packages/twenty-front/src/generated/graphql.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { AppThemeProvider } from '@/ui/theme/components/AppThemeProvider';
import { PageTitle } from '@/ui/utilities/page-title/components/PageTitle';
import { UserProvider } from '@/users/components/UserProvider';
import { UserProviderEffect } from '@/users/components/UserProviderEffect';
import { WorkspaceProviderEffect } from '@/workspace/components/WorkspaceProviderEffect';
import { StrictMode } from 'react';
import { Outlet, useLocation } from 'react-router-dom';
import { getPageTitleFromPath } from '~/utils/title-utils';
Expand All @@ -32,6 +33,7 @@ export const AppRouterProviders = () => {
<ChromeExtensionSidecarEffect />
<ChromeExtensionSidecarProvider>
<UserProviderEffect />
<WorkspaceProviderEffect />
<UserProvider>
<AuthProvider>
<ApolloMetadataClientProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ const SettingsWorkspace = lazy(() =>
})),
);

const SettingsDomain = lazy(() =>
import('~/pages/settings/workspace/SettingsDomain').then((module) => ({
default: module.SettingsDomain,
})),
);

const SettingsWorkspaceMembers = lazy(() =>
import('~/pages/settings/SettingsWorkspaceMembers').then((module) => ({
default: module.SettingsWorkspaceMembers,
Expand Down Expand Up @@ -272,11 +278,12 @@ export const SettingsRoutes = ({
{isBillingEnabled && (
<Route path={SettingsPath.Billing} element={<SettingsBilling />} />
)}
<Route path={SettingsPath.Workspace} element={<SettingsWorkspace />} />
<Route path={SettingsPath.Domain} element={<SettingsDomain />} />
<Route
path={SettingsPath.WorkspaceMembersPage}
element={<SettingsWorkspaceMembers />}
/>
<Route path={SettingsPath.Workspace} element={<SettingsWorkspace />} />
<Route path={SettingsPath.Objects} element={<SettingsObjects />} />
<Route
path={SettingsPath.ObjectOverview}
Expand Down Expand Up @@ -366,14 +373,12 @@ export const SettingsRoutes = ({
element={<SettingsObjectFieldEdit />}
/>
<Route path={SettingsPath.Releases} element={<Releases />} />
<Route path={SettingsPath.Security} element={<SettingsSecurity />} />
{isSSOEnabled && (
<>
<Route path={SettingsPath.Security} element={<SettingsSecurity />} />
<Route
path={SettingsPath.NewSSOIdentityProvider}
element={<SettingsSecuritySSOIdentifyProvider />}
/>
</>
<Route
path={SettingsPath.NewSSOIdentityProvider}
element={<SettingsSecuritySSOIdentifyProvider />}
/>
)}
</Routes>
</Suspense>
Expand Down
61 changes: 41 additions & 20 deletions packages/twenty-front/src/modules/auth/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';

import { getImageAbsoluteURI } from '~/utils/image/getImageAbsoluteURI';
import { isDefined } from '~/utils/isDefined';

type LogoProps = {
workspaceLogo?: string | null;
size?: string | null;
includeTwentyLogo?: boolean;
};

const StyledContainer = styled.div`
height: 48px;
const StyledContainer = styled.div<StyledMainLogoProps>`
height: ${({ size }) => size};
margin-bottom: ${({ theme }) => theme.spacing(4)};
margin-top: ${({ theme }) => theme.spacing(4)};
position: relative;
width: 48px;
width: ${({ size }) => size};
`;

const StyledTwentyLogo = styled.img`
const StyledTwentyLogo = styled.img<StyledMainLogoProps>`
border-radius: ${({ theme }) => theme.border.radius.xs};
height: 24px;
width: 24px;
height: calc(${({ size }) => size} / 2);
width: calc(${({ size }) => size} / 2);
`;

const StyledTwentyLogoContainer = styled.div`
const StyledTwentyLogoContainer = styled.div<StyledMainLogoProps>`
align-items: center;
background-color: ${({ theme }) => theme.background.primary};
border-radius: ${({ theme }) => theme.border.radius.sm};
bottom: ${({ theme }) => `-${theme.spacing(3)}`};
bottom: calc(-12 * ${({ size }) => size} / 48);
display: flex;
height: 28px;
height: calc((28 * ${({ size }) => size}) / 48);
justify-content: center;
position: absolute;
right: ${({ theme }) => `-${theme.spacing(3)}`};
width: 28px;
right: calc(-12 * ${({ size }) => size} / 48);
width: calc(28 * ${({ size }) => size} / 48);
`;

type StyledMainLogoProps = {
logo?: string | null;
size?: string | null;
};

const StyledMainLogo = styled.div<StyledMainLogoProps>`
Expand All @@ -47,21 +52,37 @@ const StyledMainLogo = styled.div<StyledMainLogoProps>`
width: 100%;
`;

export const Logo = ({ workspaceLogo }: LogoProps) => {
if (!workspaceLogo) {
export const Logo = (props: LogoProps) => {
const theme = useTheme();

const size = props.size ?? theme.spacing(12);

const includeTwentyLogo = isDefined(props.includeTwentyLogo)
? props.includeTwentyLogo
: true;

if (!props.workspaceLogo) {
return (
<StyledContainer>
<StyledMainLogo logo="/icons/android/android-launchericon-192-192.png" />
<StyledContainer size={size}>
<StyledMainLogo
size={size}
logo="/icons/android/android-launchericon-192-192.png"
/>
</StyledContainer>
);
}

return (
<StyledContainer>
<StyledMainLogo logo={getImageAbsoluteURI(workspaceLogo)} />
<StyledTwentyLogoContainer>
<StyledTwentyLogo src="/icons/android/android-launchericon-192-192.png" />
</StyledTwentyLogoContainer>
<StyledContainer size={size}>
<StyledMainLogo logo={getImageAbsoluteURI(props.workspaceLogo)} />
{includeTwentyLogo && (
<StyledTwentyLogoContainer size={size}>
<StyledTwentyLogo
size={size}
src="/icons/android/android-launchericon-192-192.png"
/>
</StyledTwentyLogoContainer>
)}
</StyledContainer>
);
};
15 changes: 15 additions & 0 deletions packages/twenty-front/src/modules/auth/components/VerifyEffect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
import { useAuth } from '@/auth/hooks/useAuth';
import { useIsLogged } from '@/auth/hooks/useIsLogged';
import { AppPath } from '@/types/AppPath';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { isDefined } from '~/utils/isDefined';
import { SnackBarVariant } from '@/ui/feedback/snack-bar-manager/components/SnackBar';

export const VerifyEffect = () => {
const { enqueueSnackBar } = useSnackBar();

const [searchParams] = useSearchParams();
const loginToken = searchParams.get('loginToken');
const errorMessage = searchParams.get('errorMessage');

const isLogged = useIsLogged();
const navigate = useNavigate();
Expand All @@ -30,5 +36,14 @@ export const VerifyEffect = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
// TODO AMOREAUX: the error message it display twice. Need help to fix it
if (isDefined(errorMessage)) {
enqueueSnackBar(errorMessage, {
variant: SnackBarVariant.Error,
});
}
}, []);

return <></>;
};

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { gql } from '@apollo/client';

export const SWITCH_WORKSPACE = gql`
mutation SwitchWorkspace($workspaceId: String!) {
switchWorkspace(workspaceId: $workspaceId) {
id
subdomain
authProviders {
sso {
id
name
type
status
issuer
}
google
magicLink
password
microsoft
}
}
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,26 @@ import { gql } from '@apollo/client';
export const CHECK_USER_EXISTS = gql`
query CheckUserExists($email: String!, $captchaToken: String) {
checkUserExists(email: $email, captchaToken: $captchaToken) {
exists
__typename
... on UserExists {
exists
availableWorkspaces {
id
displayName
subdomain
logo
sso {
type
id
issuer
name
status
}
}
}
... on UserNotExists {
exists
}
}
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { gql } from '@apollo/client';

export const GET_PUBLIC_WORKSPACE_DATA_BY_SUBDOMAIN = gql`
query GetPublicWorkspaceDataBySubdomain {
getPublicWorkspaceDataBySubdomain {
id
logo
displayName
subdomain
authProviders {
sso {
id
name
type
status
issuer
}
google
magicLink
password
microsoft
}
}
}
`;
Loading
Loading