Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 8 additions & 2 deletions src/app/demo/DemoShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ export function DemoShell({ children }: PropsWithChildren): JSX.Element {
All people and businesses are fictional. Changes are temporary and expire within 24 hours. Please do not
enter personal or confidential information.
</p>
<p>Company login, invitations, uploads and external integrations are disabled in this demo.</p>
<p>
Team settings includes a fictional team and read-only previews of company login, invitations and
integrations. Uploads and exports are disabled.
</p>
{error && <p role="alert">{error}</p>}
<div className={styles.actions}>
<Button
Expand Down Expand Up @@ -177,7 +180,10 @@ export function DemoShell({ children }: PropsWithChildren): JSX.Element {
>
<h2 id="demo-guide-title">Try EPOCA in a few minutes</h2>
<DemoGuide />
<p>Sample data only. Sessions last up to 24 hours; integrations and downloads are unavailable.</p>
<p>
Sample data only. Sessions last up to 24 hours. Team settings previews do not send invitations or connect
external services. Downloads are unavailable.
</p>
<Button label="Got it" onClick={() => setShowGuide(false)} />
</Modal>
<Modal
Expand Down
2 changes: 0 additions & 2 deletions src/app/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isDemo } from '@/core/config/demo';
import { paths } from '@/app/routing/paths';
import { ROLE_PERMISSIONS } from '@/app/routing/rolePermissions';
import Icon, { icons } from '@/core/theme/icon';
Expand Down Expand Up @@ -110,7 +109,6 @@ function Navbar(): JSX.Element {
});

const userHasRequiredPermissions = (item: NavItem): boolean => {
if (isDemo && item.value === 'team-settings') return false;
if (!item.requiredPermissions) return true;

const requiredRoles = ROLE_PERMISSIONS[item.requiredPermissions];
Expand Down
2 changes: 1 addition & 1 deletion src/app/routing/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const contextOrganizationRoutes: RouteObject[] = [
...projectsRoutes,
...reportRoutes,
...pivotTableRoutes,
...(isDemo ? [] : teamSettingsRoutes),
...teamSettingsRoutes,
{ path: '*', element: <Navigate to={paths.index} replace /> },
],
},
Expand Down
2 changes: 2 additions & 0 deletions src/core/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"team_seatings.demo.members": "Your fictional team. Try changing another member’s role or project assignments. Your guest Owner account stays protected. Reset demo restores the sample team.",
"team_seatings.demo.preview": "Read-only demo preview. These fictional settings do not connect to an identity provider, create credentials or send invitations.",
"app.router.non_authed_page_slides.client_panel.text": "Let your client track progress in their project. Create client panel,\naccount for their use which lets them preview time and activities.",
"app.router.non_authed_page_slides.client_panel.title": "Client panel",
"app.router.non_authed_page_slides.export_data.text": "Export work data to Excel (.xls, .csv) for analysis.\n ",
Expand Down
2 changes: 2 additions & 0 deletions src/core/i18n/locales/pl/translation.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"team_seatings.demo.members": "Twój fikcyjny zespół. Zmieniaj role innych osób lub ich przypisania do projektów. Konto gościa Owner pozostaje chronione. Reset demo przywraca przykładowy zespół.",
"team_seatings.demo.preview": "Podgląd demo tylko do odczytu. Fikcyjne ustawienia nie łączą się z dostawcą logowania, nie tworzą kluczy ani nie wysyłają zaproszeń.",
"app.router.non_authed_page_slides.client_panel.text": "Pozwól klientowi śledzić postępy w jego projekcie. Utwórz panel klienta,\nkonto do jego użytku, które pozwoli mu na podgląd czasu pracy i działań.",
"app.router.non_authed_page_slides.client_panel.title": "Panel klienta",
"app.router.non_authed_page_slides.export_data.text": "Eksportuj dane pracy do Excela (.xls, .csv) do analizy.\n ",
Expand Down
3 changes: 3 additions & 0 deletions src/core/theme/checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import styles from './Checkbox.module.scss';

interface CheckboxProps {
ariaLabel?: string;
disabled?: boolean;
className?: string;
label?: string;
infoText?: string;
Expand All @@ -19,6 +20,7 @@ interface CheckboxProps {

const Checkbox = ({
ariaLabel,
disabled = false,
className,
label,
infoText,
Expand Down Expand Up @@ -56,6 +58,7 @@ const Checkbox = ({
>
<input
aria-label={ariaLabel ?? label}
disabled={disabled}
checked={selected}
className={clsx(styles.checkbox, inputVariant)}
id={inputId}
Expand Down
10 changes: 10 additions & 0 deletions src/modules/teamSettings/TeamSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isDemo } from '@/core/config/demo';
import MainContent from '@/core/theme/mainContent';
import PageLayout from '@/core/theme/pageLayout';
import ScrolledContainer from '@/core/theme/scrolledContainer';
Expand Down Expand Up @@ -73,6 +74,15 @@ function TeamSettings(): JSX.Element {
<ScrolledContainer>
<MainContent>
<PageLayout className={styles.layout} sectionName={selectedTab.label} title={t('common.team_seatings')}>
{isDemo && (
<p>
{t(
tab === 'members' && memberTab !== 'invitations'
? 'team_seatings.demo.members'
: 'team_seatings.demo.preview',
)}
</p>
)}
<Tabs className={styles.tabs} onTabClick={onTabClick} tabs={TABS} />
</PageLayout>
</MainContent>
Expand Down
19 changes: 19 additions & 0 deletions src/modules/teamSettings/authentication/Authentication.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import { fireEvent, render, screen } from '@testing-library/react';
import type { MockedFunction } from 'vitest';
import Authentication from './Authentication';

const demoMode = vi.hoisted(() => ({ enabled: false }));
vi.mock('@/core/config/demo', () => ({
get isDemo() {
return demoMode.enabled;
},
}));
beforeEach(() => {
demoMode.enabled = false;
});

vi.mock('react-i18next', async () => ({
...(await vi.importActual('react-i18next')),
useTranslation: () => ({ t: (key: string) => key }),
Expand Down Expand Up @@ -93,3 +103,12 @@ describe('Authentication', () => {
expect(screen.queryByDisplayValue('someone-else-changed-this')).not.toBeInTheDocument();
});
});

it('blocks SAML changes and submission in the demo', () => {
demoMode.enabled = true;
renderAuthentication(rawSamlConfig);
expect(screen.getByDisplayValue('original-cert')).toHaveAttribute('readonly');
expect(screen.getByRole('button', { name: 'common.save' })).toBeDisabled();
fireEvent.submit(screen.getByRole('form', { name: 'team_seatings.authentication.header.saml_integration' }));
expect(mutateMock).not.toHaveBeenCalled();
});
21 changes: 18 additions & 3 deletions src/modules/teamSettings/authentication/Authentication.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isDemo } from '@/core/config/demo';
import Button from '@/core/theme/button';
import Checkbox from '@/core/theme/checkbox';
import { Input, TextArea } from '@/core/theme/inputs';
Expand Down Expand Up @@ -42,23 +43,26 @@ const Authentication = (): JSX.Element | null => {
);

const handleLanguageSelect = (option: LanguageOption): void => {
if (isDemo) return;
setSamlConfigDraft((current) => (current ? { ...current, langCode: option.value } : current));
};

const handleSamlConfigFlagChange = (field: 'isEnabled' | 'allowAccountInit') => (): void => {
if (isDemo) return;
setSamlConfigDraft((current) => (current ? { ...current, [field]: !current[field] } : current));
};

const handleSamlConfigPropertyChange =
(field: 'idpCert' | 'idpEntityId' | 'idpSsoUrl' | 'formattedValidFor') =>
(event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>): void => {
if (isDemo) return;
const { value } = event.target;
setSamlConfigDraft((current) => (current ? { ...current, [field]: value } : current));
};

const handleSubmit = (e: React.FormEvent<HTMLFormElement>): void => {
e.preventDefault();
if (!samlConfigDraft) return;
if (isDemo || !samlConfigDraft) return;

const { allowAccountInit, idpCert, idpEntityId, idpSsoUrl, isEnabled, langCode, formattedValidFor } =
samlConfigDraft;
Expand Down Expand Up @@ -89,8 +93,13 @@ const Authentication = (): JSX.Element | null => {
</p>
</div>
<LoadingArea loading={samlConfigQuery.isLoading || updateSamlConfigMutation.isPending}>
<form className={clsx(styles.ssoForm, styles.maxMarginBottom)} onSubmit={handleSubmit}>
<form
aria-label={t('team_seatings.authentication.header.saml_integration')}
className={clsx(styles.ssoForm, styles.maxMarginBottom)}
onSubmit={handleSubmit}
>
<Checkbox
disabled={isDemo}
className={styles.maxBottomMargin}
selected={isEnabled}
label={t('team_seatings.authentication.checkbox.enable_saml_authentication.label')}
Expand All @@ -99,6 +108,7 @@ const Authentication = (): JSX.Element | null => {
onClick={handleSamlConfigFlagChange('isEnabled')}
/>
<Checkbox
disabled={isDemo}
className={styles.maxBottomMargin}
selected={allowAccountInit}
label={t('team_seatings.authentication.checkbox.allow_automatic_user_creation.label')}
Expand All @@ -109,6 +119,7 @@ const Authentication = (): JSX.Element | null => {
/>
<div className={styles.inputsContainer}>
<TextArea
readOnly={isDemo}
label={t('team_seatings.authentication.text_area.idp_certificate.label')}
name="certificate"
infoText={t('team_seatings.authentication.text_area.idp_certificate.info_text')}
Expand All @@ -118,6 +129,7 @@ const Authentication = (): JSX.Element | null => {
onChange={handleSamlConfigPropertyChange('idpCert')}
/>
<Input
readOnly={isDemo}
label={t('team_seatings.authentication.input.idp_entity_id.label')}
name="entityId"
infoText={t('team_seatings.authentication.input.idp_entity_id.info_text')}
Expand All @@ -126,6 +138,7 @@ const Authentication = (): JSX.Element | null => {
onChange={handleSamlConfigPropertyChange('idpEntityId')}
/>
<Input
readOnly={isDemo}
label={t('team_seatings.authentication.input.sso_url.label')}
name="ssoUrl"
infoText={t('team_seatings.authentication.input.sso_url.info_text')}
Expand All @@ -136,6 +149,7 @@ const Authentication = (): JSX.Element | null => {

{/* TODO */}
<Select
readOnly={isDemo}
className={styles.maxWidth}
items={getLanguageOptions()}
selectedItem={selectedLanguageOption}
Expand All @@ -147,6 +161,7 @@ const Authentication = (): JSX.Element | null => {
size="normal"
/>
<Input
readOnly={isDemo}
label={t('team_seatings.authentication.input.session_valid_time.label')}
name="sessionValidTime"
value={formattedValidFor}
Expand All @@ -162,7 +177,7 @@ const Authentication = (): JSX.Element | null => {
size="large"
type="submit"
loading={updateSamlConfigMutation.isPending}
disabled={updateSamlConfigMutation.isPending}
disabled={isDemo || updateSamlConfigMutation.isPending}
/>
</form>
</LoadingArea>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,12 @@ describe('IntegrationClientDetailsModal', () => {
expect(baseProps.onRetryAudit).toHaveBeenCalledTimes(1);
});
});

it('keeps demo details and audit readable with mutation controls disabled', () => {
render(<IntegrationClientDetailsModal {...baseProps} client={{ ...client, status: 'Active' }} readOnly />);
expect(screen.getByRole('button', { name: 'Edit' })).toBeDisabled();
expect(screen.getByRole('button', { name: 'Rotate secret' })).toBeDisabled();
expect(screen.getByRole('button', { name: 'Revoke' })).toBeDisabled();
expect(screen.getByRole('button', { name: 'Close' })).toBeEnabled();
expect(screen.getByText('Audit history')).toBeVisible();
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type RequestState = 'idle' | 'loading' | 'success' | 'error';
export type DetailsFocusAction = 'edit' | 'revoke' | 'rotate';

interface IntegrationClientDetailsModalProps {
readOnly?: boolean;
auditEvents: readonly IntegrationClientAuditEvent[];
auditHasNextPage: boolean;
auditState: RequestState;
Expand Down Expand Up @@ -57,6 +58,7 @@ const IntegrationClientDetailsModal = ({
initialFocusAction = null,
onClose,
onEdit,
readOnly = false,
onInitialFocusHandled,
onLoadMoreAudit,
onRetryAudit,
Expand Down Expand Up @@ -156,7 +158,7 @@ const IntegrationClientDetailsModal = ({
<div className={styles.actions}>
{client.status === 'Active' && (
<Button
disabled={isBusy || !isDetailFresh}
disabled={readOnly || isBusy || !isDetailFresh}
forwardedRef={editRef}
label={t('team_seatings.integrations.action.edit')}
onClick={() => onEdit(client)}
Expand All @@ -166,7 +168,7 @@ const IntegrationClientDetailsModal = ({
)}
{client.status === 'Expired' && (
<Button
disabled={isBusy || !isDetailFresh}
disabled={readOnly || isBusy || !isDetailFresh}
forwardedRef={editRef}
label={t('team_seatings.integrations.action.renew')}
onClick={() => onEdit(client)}
Expand All @@ -176,7 +178,7 @@ const IntegrationClientDetailsModal = ({
)}
{client.status === 'Active' && (
<Button
disabled={isBusy || !isDetailFresh}
disabled={readOnly || isBusy || !isDetailFresh}
forwardedRef={rotateRef}
label={t('team_seatings.integrations.action.rotate')}
onClick={() => onRotate(client)}
Expand All @@ -186,7 +188,7 @@ const IntegrationClientDetailsModal = ({
)}
{client.status !== 'Revoked' && (
<Button
disabled={isBusy || !isDetailFresh}
disabled={readOnly || isBusy || !isDetailFresh}
forwardedRef={revokeRef}
label={t('team_seatings.integrations.action.revoke')}
onClick={() => onRevoke(client)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import styles from './IntegrationClientsTable.module.scss';

export interface IntegrationClientsTableProps {
actionsDisabled?: boolean;
readOnly?: boolean;
clients: IntegrationClient[];
count: number;
locale: string;
Expand All @@ -29,6 +30,7 @@ type ActionKey = 'details' | 'edit' | 'renew' | 'revoke' | 'rotate';

interface IntegrationClientActionsProps {
actionsDisabled: boolean;
readOnly: boolean;
client: IntegrationClient;
onDetails?: (client: IntegrationClient) => void;
onActionTriggerRef?: (clientId: string, button: HTMLButtonElement | null) => void;
Expand All @@ -39,6 +41,7 @@ interface IntegrationClientActionsProps {

const IntegrationClientActions = ({
actionsDisabled,
readOnly,
client,
onDetails,
onActionTriggerRef,
Expand Down Expand Up @@ -111,7 +114,7 @@ const IntegrationClientActions = ({
return (
<Button
aria-label={`${label}: ${client.name}`}
disabled={actionsDisabled}
disabled={actionsDisabled || (readOnly && key !== 'details')}
key={key}
label={label}
onClick={() => runAction(callback)}
Expand All @@ -128,6 +131,7 @@ const IntegrationClientActions = ({

const IntegrationClientsTable = ({
actionsDisabled = false,
readOnly = false,
clients,
count,
isLoadingMore = false,
Expand Down Expand Up @@ -196,6 +200,7 @@ const IntegrationClientsTable = ({
<td className={styles.metadataColumn}>{lastUsed}</td>
<td>
<IntegrationClientActions
readOnly={readOnly}
actionsDisabled={actionsDisabled}
client={client}
onDetails={onDetails}
Expand Down
Loading
Loading