From ae5a69fe47fd9279b547c1a502e2ccd6ae1fced0 Mon Sep 17 00:00:00 2001 From: Kevin Abatan Date: Wed, 15 Jan 2025 13:11:34 +0100 Subject: [PATCH] style: updating the scenario homepage --- .../Scenario/TestRun/TestRunNudge.tsx | 35 +- .../Scenario/Workflow/WorkflowNudge.tsx | 36 +- .../src/repositories/LicenseRepository.ts | 41 +- .../src/repositories/init.server.ts | 3 +- .../scenarios+/$scenarioId+/home.tsx | 517 +++++++++--------- 5 files changed, 318 insertions(+), 314 deletions(-) diff --git a/packages/app-builder/src/components/Scenario/TestRun/TestRunNudge.tsx b/packages/app-builder/src/components/Scenario/TestRun/TestRunNudge.tsx index c4dfff95..461a4702 100644 --- a/packages/app-builder/src/components/Scenario/TestRun/TestRunNudge.tsx +++ b/packages/app-builder/src/components/Scenario/TestRun/TestRunNudge.tsx @@ -8,26 +8,23 @@ export const TestRunNudge = () => { const { t } = useTranslation(['scenarios']); return ( -
-

+
+

{t('scenarios:home.testrun')} -

-
-
- - -
- {t('scenarios:testrun.description')} -
-
- -
+

+ + + + {t('scenarios:testrun.description')} + +
+
); diff --git a/packages/app-builder/src/components/Scenario/Workflow/WorkflowNudge.tsx b/packages/app-builder/src/components/Scenario/Workflow/WorkflowNudge.tsx index 472051e5..2795d294 100644 --- a/packages/app-builder/src/components/Scenario/Workflow/WorkflowNudge.tsx +++ b/packages/app-builder/src/components/Scenario/Workflow/WorkflowNudge.tsx @@ -8,27 +8,23 @@ export const WorkflowNudge = () => { const { t } = useTranslation(['scenarios', 'workflows']); return ( -
-

+
+

{t('scenarios:home.workflow')} -

-
-
- - -
- {t('scenarios:home.workflow_description')} -
-
- -
+

+ + + + {t('scenarios:home.workflow_description')} + +
+
); diff --git a/packages/app-builder/src/repositories/LicenseRepository.ts b/packages/app-builder/src/repositories/LicenseRepository.ts index 7149f361..04ad72c9 100644 --- a/packages/app-builder/src/repositories/LicenseRepository.ts +++ b/packages/app-builder/src/repositories/LicenseRepository.ts @@ -9,27 +9,30 @@ export interface LicenseRepository { isSsoEnabled(): Promise; } -export const makeGetLicenseRepository = () => { - return (client: LicenseApi): LicenseRepository => ({ +export const makeGetLicenseRepository = + (isDev: boolean) => + (client: LicenseApi): LicenseRepository => ({ getEntitlements: async (organizationId: string) => { - if (import.meta.env.PROD) { - const { feature_access } = await client.getEntitlements(organizationId); - if (!import.meta.env.PROD) { - feature_access.webhooks = 'restricted'; - feature_access.analytics = 'restricted'; - } - return adaptLicenseEntitlements(feature_access); + const accesses: LicenseEntitlements = !isDev + ? adaptLicenseEntitlements( + (await client.getEntitlements(organizationId)).feature_access, + ) + : { + sanctions: 'allowed', + ruleSnoozes: 'allowed', + userRoles: 'allowed', + workflows: 'allowed', + testRun: 'allowed', + analytics: 'allowed', + webhooks: 'allowed', + }; + + if (isDev) { + accesses.webhooks = 'restricted'; + accesses.analytics = 'restricted'; } - return Promise.resolve({ - sanctions: 'allowed', - ruleSnoozes: 'test', - userRoles: 'allowed', - webhooks: 'restricted', - analytics: 'restricted', - workflows: 'allowed', - testRun: 'allowed', - }); + + return accesses; }, isSsoEnabled: async () => (await client.isSsoEnabled()).is_sso_enabled, }); -}; diff --git a/packages/app-builder/src/repositories/init.server.ts b/packages/app-builder/src/repositories/init.server.ts index 3618aae0..5037b3f8 100644 --- a/packages/app-builder/src/repositories/init.server.ts +++ b/packages/app-builder/src/repositories/init.server.ts @@ -33,6 +33,7 @@ import { makeGetUserRepository } from './UserRepository'; import { makeGetWebhookRepository } from './WebhookRepository'; export function makeServerRepositories({ + devEnvironment, sessionStorageRepositoryOptions, getLicenseApiClientWithoutAuth, getLicenseAPIClientWithAuth, @@ -80,7 +81,7 @@ export function makeServerRepositories({ getWebhookRepository: makeGetWebhookRepository(), getRuleSnoozeRepository: makeGetRuleSnoozeRepository(), getTestRunRepository: makeGetTestRunRepository(), - getLicenseRepository: makeGetLicenseRepository(), + getLicenseRepository: makeGetLicenseRepository(devEnvironment), }; } diff --git a/packages/app-builder/src/routes/_builder+/scenarios+/$scenarioId+/home.tsx b/packages/app-builder/src/routes/_builder+/scenarios+/$scenarioId+/home.tsx index eb041a46..5505cb48 100644 --- a/packages/app-builder/src/routes/_builder+/scenarios+/$scenarioId+/home.tsx +++ b/packages/app-builder/src/routes/_builder+/scenarios+/$scenarioId+/home.tsx @@ -185,30 +185,41 @@ export default function ScenarioHome() { ) : null} - - {featureAccess.isTestRunAvailable === 'restricted' ? ( - - ) : ( - - )} - {featureAccess.isWorkflowsAvailable === 'restricted' ? ( - - ) : ( - - )} +
+

+ {t('scenarios:home.execution')} +

+
+ + + {featureAccess.isTestRunAvailable === 'restricted' ? ( + + ) : ( + + )} + {featureAccess.isWorkflowsAvailable === 'restricted' ? ( + + ) : ( + + )} +
+
@@ -354,92 +365,137 @@ function TestRunSection({ ); return ( -
-

+
+

{t('scenarios:home.testrun')} -

-
-
- {access === 'test' ? ( - - ) : null} - {isExecutionOngoing ? ( -
- - {t('scenarios:home.execution.batch.ongoing')} -
- ) : null} - -
- {t('scenarios:testrun.description')} -
-
- -
- 0} - > - - - {currentTestRun.length > 0 ? ( - - {t('scenarios:testrun.current_run')} - - ) : null} - {testRuns.length > 1 ? ( - - {t('scenarios:home.other_versions_other', { - count: testRuns.filter((tr) => tr.status != 'up').length, - })} - - ) : null} -
+

+ + {access === 'test' ? ( + + ) : null} + + {isExecutionOngoing ? ( +
+ + {t('scenarios:home.execution.batch.ongoing')}
+ ) : null} + + {t('scenarios:testrun.description')} + +
+ 0} + > + + + {currentTestRun.length > 0 ? ( + + {t('scenarios:testrun.current_run')} + + ) : null} + + {testRuns.length > 1 ? ( + + {t('scenarios:home.other_versions_other', { + count: testRuns.filter((tr) => tr.status != 'up').length, + })} + + ) : null}
); } -function ExecutionSection({ +function RealTimeSection({ + scenarioId, + liveScenarioIteration, +}: { + scenarioId: string; + liveScenarioIteration?: ScenarioIterationWithType; +}) { + const { t } = useTranslation(['scenarios']); + const isLive = liveScenarioIteration !== undefined; + + return ( +
+

+ {t('scenarios:home.execution.real_time')} +

+ +
+ + , + }} + /> + + + {isLive ? ( + + scenario_id + + ), + }} + /> + ) : ( + t('scenarios:home.execution.real_time.callout.no_live_version') + )} + +
+
+
+ ); +} + +function BatchSection({ scenarioId, - isManualTriggerScenarioAvailable, scheduledExecutions, liveScenarioIteration, + isManualTriggerScenarioAvailable, }: { scenarioId: string; - isManualTriggerScenarioAvailable: boolean; scheduledExecutions: ScheduledExecution[]; + isManualTriggerScenarioAvailable: boolean; liveScenarioIteration?: ScenarioIterationWithType; }) { const { @@ -467,104 +523,60 @@ function ExecutionSection({ ); return ( -
-

- {t('scenarios:home.execution')} -

-
-
-

- {t('scenarios:home.execution.real_time')} -

- -
- - , - }} - /> - - - {isLive ? ( - - scenario_id - - ), - }} - /> - ) : ( - t( - 'scenarios:home.execution.real_time.callout.no_live_version', - ) - )} - -
-
+
+ {isExecutionOngoing ? ( +
+ + {t('scenarios:home.execution.batch.ongoing')}
-
- {isExecutionOngoing ? ( -
- - {t('scenarios:home.execution.batch.ongoing')} -
- ) : null} -

- {t('scenarios:home.execution.batch')} -

- -
- {t('scenarios:home.execution.batch.callout')} - {formattedSchedule ? ( - - , - }} - values={{ - schedule: formattedSchedule, - }} - /> - - ) : null} -
-
- -
- {isManualTriggerScenarioAvailable && isLive ? ( - + {t('scenarios:home.execution.batch')} + + +
+ {t('scenarios:home.execution.batch.callout')} + {formattedSchedule ? ( + + , + }} + values={{ + schedule: formattedSchedule, + }} /> - ) : null} - - {t('scenarios:home.execution.batch.scheduled_execution', { - count: scheduledExecutions.length, - })} - -
+ + ) : null}
+ + +
+ {isManualTriggerScenarioAvailable && isLive ? ( + + ) : null} + + {t('scenarios:home.execution.batch.scheduled_execution', { + count: scheduledExecutions.length, + })} +
-
+ ); } @@ -629,73 +641,68 @@ function WorkflowSection({ } return ( -
-

+
+

{t('scenarios:home.workflow')} -

-
-
- {access === 'test' ? ( - - ) : null} - -
- {t('scenarios:home.workflow_description')} -
-
- -
- {tag ? ( -
- {tag} - {tooltip ? ( - - - - - - {tooltip} - - - ) : null} -
+

+ + {access === 'test' ? ( + + ) : null} + + {t('scenarios:home.workflow_description')} + +
+ {tag ? ( +
+ {tag} + {tooltip ? ( + + + + + + {tooltip} + + ) : null} - - -

- {t( - isEdit - ? 'scenarios:home.workflow.edit' - : 'scenarios:home.workflow.create', - )} -

-
-
+ ) : null} + + + +

+ {t( + isEdit + ? 'scenarios:home.workflow.edit' + : 'scenarios:home.workflow.create', + )} +

+
);