Skip to content

Commit 889ffb2

Browse files
fix review
1 parent 923517f commit 889ffb2

12 files changed

Lines changed: 112 additions & 35 deletions

File tree

packages/app-builder/src/components/Scenario/Actions/CreateScenario.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Callout } from '@app-builder/components';
22
import { ExternalLink } from '@app-builder/components/ExternalLink';
33
import { FormErrorOrDescription } from '@app-builder/components/Form/Tanstack/FormErrorOrDescription';
4-
import { FormInput } from '@app-builder/components/Form/Tanstack/FormInput';
5-
import { FormLabel } from '@app-builder/components/Form/Tanstack/FormLabel';
64
import { useLoaderRevalidator } from '@app-builder/contexts/LoaderRevalidatorContext';
75
import { DataModel } from '@app-builder/models';
86
import { useDataModelQuery } from '@app-builder/queries/data/get-data-model';
@@ -18,7 +16,7 @@ import { useHydrated } from '@tanstack/react-router';
1816
import * as React from 'react';
1917
import toast from 'react-hot-toast';
2018
import { Trans, useTranslation } from 'react-i18next';
21-
import { Modal, SelectV2, Tooltip } from 'ui-design-system';
19+
import { Input, Modal, SelectV2, Tooltip } from 'ui-design-system';
2220
import { Icon } from 'ui-icons';
2321

2422
export function CreateScenario({ children }: { children: React.ReactElement }) {
@@ -95,13 +93,14 @@ function CreateScenarioContent({ dataModel, onCreateSuccess }: { dataModel: Data
9593
>
9694
{(field) => (
9795
<div className="group flex w-full flex-col gap-sm">
98-
<FormLabel name={field.name}>{t('scenarios:create_scenario.name')}</FormLabel>
99-
<FormInput
96+
<label htmlFor={field.name}>{t('scenarios:create_scenario.name')}</label>
97+
<Input
10098
type="text"
99+
id={field.name}
101100
name={field.name}
102101
defaultValue={field.state.value}
103102
onChange={(e) => field.handleChange(e.currentTarget.value)}
104-
valid={field.state.meta.errors.length === 0}
103+
borderColor={field.state.meta.errors.length === 0 ? 'greyfigma-90' : 'redfigma-47'}
105104
placeholder={t('scenarios:create_scenario.name_placeholder')}
106105
/>
107106
<FormErrorOrDescription errors={getFieldErrors(field.state.meta.errors)} />
@@ -111,13 +110,14 @@ function CreateScenarioContent({ dataModel, onCreateSuccess }: { dataModel: Data
111110
<form.Field name="description">
112111
{(field) => (
113112
<div className="group flex w-full flex-col gap-sm">
114-
<FormLabel name={field.name}>{t('scenarios:create_scenario.description')}</FormLabel>
115-
<FormInput
113+
<label htmlFor={field.name}>{t('scenarios:create_scenario.description')}</label>
114+
<Input
116115
type="text"
116+
id={field.name}
117117
name={field.name}
118118
defaultValue={field.state.value}
119119
onChange={(e) => field.handleChange(e.currentTarget.value)}
120-
valid={field.state.meta.errors.length === 0}
120+
borderColor={field.state.meta.errors.length === 0 ? 'greyfigma-90' : 'redfigma-47'}
121121
placeholder={t('scenarios:create_scenario.description_placeholder')}
122122
/>
123123
<FormErrorOrDescription errors={getFieldErrors(field.state.meta.errors)} />
@@ -132,7 +132,7 @@ function CreateScenarioContent({ dataModel, onCreateSuccess }: { dataModel: Data
132132
>
133133
{(field) => (
134134
<div className="group flex w-full flex-col gap-sm">
135-
<FormLabel name={field.name} className="flex flex-row items-center gap-xs">
135+
<label htmlFor={field.name} className="flex flex-row items-center gap-xs">
136136
{t('scenarios:create_scenario.trigger_object_title')}
137137
<Tooltip.Default
138138
arrow={false}
@@ -144,12 +144,13 @@ function CreateScenarioContent({ dataModel, onCreateSuccess }: { dataModel: Data
144144
>
145145
<button
146146
type="button"
147+
aria-label={t('scenarios:create_scenario.trigger_object_tooltip_aria_label')}
147148
className="text-grey-disabled hover:text-grey-secondary cursor-pointer transition-colors"
148149
>
149150
<Icon icon="tip" className="size-5" />
150151
</button>
151152
</Tooltip.Default>
152-
</FormLabel>
153+
</label>
153154
<SelectV2
154155
placeholder={t('scenarios:create_scenario.trigger_object_placeholder')}
155156
value={field.state.value}

packages/app-builder/src/components/Scenario/Iteration/ScenarioIterationMenu.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ function ScenarioIterationContent({ labelledScenarioIteration, scenario }: Scena
9090
);
9191

9292
return (
93-
<MenuCommand.List>
94-
{iterations.length === 0 ? (
95-
<div className="text-grey-disabled w-full text-center">{t('common:help_center.no_results')}</div>
96-
) : (
93+
<>
94+
<MenuCommand.List>
9795
<MenuCommand.Group
9896
className="flex flex-col gap-sm"
9997
heading={<div className="px-sm">{t('scenarios:home.versions_label')}</div>}
@@ -102,6 +100,11 @@ function ScenarioIterationContent({ labelledScenarioIteration, scenario }: Scena
102100
<MenuCommand.Item
103101
key={iteration.id}
104102
value={iteration.id}
103+
keywords={[
104+
iteration.formattedVersion,
105+
iteration.formattedUpdatedAt,
106+
...(iteration.formattedLive ? [iteration.formattedLive] : []),
107+
]}
105108
asChild
106109
className="bg-surface-card aria-selected:border-purple-primary h-auto scroll-my-sm py-xs px-sm"
107110
>
@@ -126,7 +129,10 @@ function ScenarioIterationContent({ labelledScenarioIteration, scenario }: Scena
126129
</MenuCommand.Item>
127130
))}
128131
</MenuCommand.Group>
129-
)}
130-
</MenuCommand.List>
132+
<MenuCommand.Empty>
133+
<div className="text-grey-disabled w-full text-center">{t('common:help_center.no_results')}</div>
134+
</MenuCommand.Empty>
135+
</MenuCommand.List>
136+
</>
131137
);
132138
}

packages/app-builder/src/components/Scenario/Rules/ScreeningRuleEditPanel.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,9 @@ export function ScreeningRuleEditPanel({
491491
<div className="flex flex-col gap-sm">
492492
<span className="text-s inline-flex items-center gap-sm font-semibold">
493493
{t('scenarios:sanction_counterparty_id')}
494-
<FieldToolTip>{t('scenarios:sanction_counterparty_id.tooltip')}</FieldToolTip>
494+
<FieldToolTip label={t('scenarios:field_tooltip.aria_label')}>
495+
{t('scenarios:sanction_counterparty_id.tooltip')}
496+
</FieldToolTip>
495497
</span>
496498
<form.Field name="counterPartyId">
497499
{(field) => (
@@ -520,7 +522,9 @@ export function ScreeningRuleEditPanel({
520522
<div className="flex flex-col gap-xs">
521523
<span className="text-s inline-flex items-center gap-xs">
522524
{t('scenarios:edit_sanction.entity_type.heading')}
523-
<FieldToolTip>{t('scenarios:edit_sanction.entity_type.tooltip')}</FieldToolTip>
525+
<FieldToolTip label={t('scenarios:field_tooltip.aria_label')}>
526+
{t('scenarios:edit_sanction.entity_type.tooltip')}
527+
</FieldToolTip>
524528
</span>
525529
<form.Field name="entityType">
526530
{(field) => <FieldEntityType entityType={field.state.value} onChange={field.handleChange} />}
@@ -536,7 +540,9 @@ export function ScreeningRuleEditPanel({
536540
<div className="flex flex-col gap-xs">
537541
<span className="text-s inline-flex items-center gap-xs">
538542
{t('scenarios:screening.filter.name')}
539-
<FieldToolTip>{t('scenarios:screening.filter.name.tooltip')}</FieldToolTip>
543+
<FieldToolTip label={t('scenarios:field_tooltip.aria_label')}>
544+
{t('scenarios:screening.filter.name.tooltip')}
545+
</FieldToolTip>
540546
</span>
541547
<FieldNodeConcat
542548
value={value && isStringConcatAstNode(value) ? value : undefined}
@@ -573,7 +579,9 @@ export function ScreeningRuleEditPanel({
573579
<label htmlFor="exclude-numbers" className="text-s">
574580
{t('scenarios:edit_sanction.exclude_numbers')}
575581
</label>
576-
<FieldToolTip>{t('scenarios:edit_sanction.exclude_numbers.tooltip')}</FieldToolTip>
582+
<FieldToolTip label={t('scenarios:field_tooltip.aria_label')}>
583+
{t('scenarios:edit_sanction.exclude_numbers.tooltip')}
584+
</FieldToolTip>
577585
</div>
578586
)}
579587
</form.Field>
@@ -602,7 +610,7 @@ export function ScreeningRuleEditPanel({
602610
<label htmlFor="enable-entity-recognition" className="text-s">
603611
{t('scenarios:edit_sanction.enable_entity_recognition')}
604612
</label>
605-
<FieldToolTip>
613+
<FieldToolTip label={t('scenarios:field_tooltip.aria_label')}>
606614
{t('scenarios:edit_sanction.enable_entity_recognition.tooltip')}
607615
</FieldToolTip>
608616
<span className="text-xs rounded-full bg-purple-primary px-xs py-0.5 text-grey-white">
@@ -622,7 +630,7 @@ export function ScreeningRuleEditPanel({
622630
onBlur={field.handleBlur}
623631
/>
624632
<span className="text-s">{t('scenarios:edit_sanction.skip_entity_recognition')}</span>
625-
<FieldToolTip>
633+
<FieldToolTip label={t('scenarios:field_tooltip.aria_label')}>
626634
{t('scenarios:edit_sanction.skip_entity_recognition.tooltip')}
627635
</FieldToolTip>
628636
</div>

packages/app-builder/src/components/Scenario/Screening/FieldToolTip.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tooltip } from 'ui-design-system';
22
import { Icon } from 'ui-icons';
33

4-
export const FieldToolTip = ({ children }: { children: React.ReactNode }) => {
4+
export const FieldToolTip = ({ children, label }: { children: React.ReactNode; label: string }) => {
55
return (
66
<Tooltip.Default
77
arrow={false}
@@ -11,7 +11,11 @@ export const FieldToolTip = ({ children }: { children: React.ReactNode }) => {
1111
content={children}
1212
className="border-grey-border text-s flex w-fit max-w-80 border shadow-md"
1313
>
14-
<button type="button" className="hover:text-purple-primary text-purple-disabled cursor-pointer transition-colors">
14+
<button
15+
type="button"
16+
aria-label={label}
17+
className="hover:text-purple-primary text-purple-disabled cursor-pointer transition-colors"
18+
>
1519
<Icon icon="tip" className="size-5" />
1620
</button>
1721
</Tooltip.Default>

packages/app-builder/src/components/Scenario/Screening/ScreeningTermIgnoreList.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export const ScreeningTermIgnoreList = ({ value, onBlur, onChange, editor }: Scr
4141
<label htmlFor="remove-terms-from-list" className="text-s">
4242
{t('scenarios:edit_sanction.remove_terms_from_list')}
4343
</label>
44-
<FieldToolTip>{t('scenarios:edit_sanction.remove_terms_from_list.tooltip')}</FieldToolTip>
44+
<FieldToolTip label={t('scenarios:field_tooltip.aria_label')}>
45+
{t('scenarios:edit_sanction.remove_terms_from_list.tooltip')}
46+
</FieldToolTip>
4547
</div>
4648
{value ? (
4749
<div className="flex flex-col gap-xs">

packages/app-builder/src/components/Scenario/TestRun/Filters/FilterDetail/VersionsFilter.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ScenarioIterationSummaryWithType } from '@app-builder/models/scenario/i
22
import { matchSorter } from '@app-builder/utils/search';
33
import { toggle } from 'radash';
44
import { useDeferredValue, useMemo, useState } from 'react';
5+
import { match } from 'ts-pattern';
56
import { MenuCommand } from 'ui-design-system';
67
import { Icon } from 'ui-icons';
78
import { useRefVersionFilter, useTestVersionFilter } from '../TestRunsFiltersContext';
@@ -17,8 +18,10 @@ export function VersionsFilter({
1718
const { refVersion, setRefVersion } = useRefVersionFilter();
1819
const { testVersion, setTestVersion } = useTestVersionFilter();
1920
const deferredValue = useDeferredValue(value);
20-
const selected = (type === 'ref' ? refVersion : testVersion) ?? [];
21-
const setSelected = type === 'ref' ? setRefVersion : setTestVersion;
21+
const [selected, setSelected] = match(type)
22+
.with('ref', () => [refVersion ?? [], setRefVersion] as const)
23+
.with('test', () => [testVersion ?? [], setTestVersion] as const)
24+
.exhaustive();
2225

2326
const filteredIterations = scenarioIterations.filter(({ type }) => type !== 'draft');
2427

packages/app-builder/src/locales/ar/scenarios.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"create_scenario.title": "سيناريو جديد",
5252
"create_scenario.trigger_object_placeholder": "حدِّد كائنًا مُشغِّلًا",
5353
"create_scenario.trigger_object_title": "كائن المُشغِّل",
54+
"create_scenario.trigger_object_tooltip_aria_label": "مزيد من المعلومات حول كائن المُشغِّل",
5455
"create_testrun.callout": "قم بإنشاء اختبار تشغيل جديد للفرق بين نسختين",
5556
"create_testrun.end_date": "تاريخ الانتهاء",
5657
"create_testrun.end_date_placeholder": "حدد تاريخ الانتهاء",
@@ -307,6 +308,7 @@
307308
"enriched_metadata.tor_exit_node": "عقدة خروج Tor",
308309
"enriched_metadata.vpn": "نقطة وصول VPN",
309310
"enum_options": "خيارات:",
311+
"field_tooltip.aria_label": "مزيد من المعلومات حول هذا الحقل",
310312
"home.execution": "تنفيذ",
311313
"home.execution.batch": "حزمة",
312314
"home.execution.batch.callout": "التشغيل تلقائيًا أو يدويًا على البيانات التي يتم استيعابها",
@@ -333,6 +335,7 @@
333335
"home.workflow_type.add_to_case_if_possible.tooltip": "أضف القرار المطابق للمعايير إلى حالة موجودة أو أنشئ حالة جديدة",
334336
"home.workflow_type.create_case": "حالة جديدة",
335337
"home.workflow_type.create_case.tooltip": "أضف القرار المطابق للمعايير إلى حالة جديدة",
338+
"home.workflow_type.tooltip_aria_label": "مزيد من المعلومات حول نوع سير العمل هذا",
336339
"home.workflow.create": "سير عمل جديد",
337340
"home.workflow.edit": "تحرير سير العمل",
338341
"ip_flag.abuse": "إساءة استخدام",

packages/app-builder/src/locales/en/scenarios.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"create_scenario.title": "New Scenario",
5252
"create_scenario.trigger_object_placeholder": "Select a trigger object",
5353
"create_scenario.trigger_object_title": "Trigger Object",
54+
"create_scenario.trigger_object_tooltip_aria_label": "More information about the trigger object",
5455
"create_testrun.callout": "Create a new test run to diff between 2 versions",
5556
"create_testrun.end_date": "End date",
5657
"create_testrun.end_date_placeholder": "Select the end date",
@@ -307,6 +308,7 @@
307308
"enriched_metadata.tor_exit_node": "Tor exit node",
308309
"enriched_metadata.vpn": "VPN endpoint",
309310
"enum_options": "Options:",
311+
"field_tooltip.aria_label": "More information about this field",
310312
"home.execution": "Execution",
311313
"home.execution.batch": "Batch",
312314
"home.execution.batch.callout": "Run automatically or manually on ingested data",
@@ -333,6 +335,7 @@
333335
"home.workflow_type.add_to_case_if_possible.tooltip": "Add the decision matching the criteria to an existing case or create a new case",
334336
"home.workflow_type.create_case": "new case",
335337
"home.workflow_type.create_case.tooltip": "Add the decision matching the criteria to a new case",
338+
"home.workflow_type.tooltip_aria_label": "More information about this workflow type",
336339
"home.workflow.create": "New workflow",
337340
"home.workflow.edit": "Edit workflow",
338341
"ip_flag.abuse": "Abuse",

packages/app-builder/src/locales/fr/scenarios.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"create_scenario.title": "Nouveau scénario",
5252
"create_scenario.trigger_object_placeholder": "Sélectionner un objet déclencheur",
5353
"create_scenario.trigger_object_title": "Objet déclencheur",
54+
"create_scenario.trigger_object_tooltip_aria_label": "Plus d'informations sur l'objet déclencheur",
5455
"create_testrun.callout": "Créer un nouveau test pour comparer deux versions",
5556
"create_testrun.end_date": "Date de fin",
5657
"create_testrun.end_date_placeholder": "Sélectionner la date de fin",
@@ -307,6 +308,7 @@
307308
"enriched_metadata.tor_exit_node": "Nœud de sortie Tor",
308309
"enriched_metadata.vpn": "Point d'accès VPN",
309310
"enum_options": "Possibilités :",
311+
"field_tooltip.aria_label": "Plus d'informations sur ce champ",
310312
"home.execution": "Exécution",
311313
"home.execution.batch": "Par lots",
312314
"home.execution.batch.callout": "Exécuter automatiquement ou manuellement sur les données ingérées",
@@ -333,6 +335,7 @@
333335
"home.workflow_type.add_to_case_if_possible.tooltip": "Ajouter la décision correspondant aux critères à une investigation existante ou créer une nouvelle investigation",
334336
"home.workflow_type.create_case": "nouvelle investigation",
335337
"home.workflow_type.create_case.tooltip": "Ajouter la décision correspondant aux critères à une nouvelle investigation",
338+
"home.workflow_type.tooltip_aria_label": "Plus d'informations sur ce type d'automatisation",
336339
"home.workflow.create": "Créer une automatisation",
337340
"home.workflow.edit": "Éditer l'automatisation",
338341
"ip_flag.abuse": "Abus",

packages/app-builder/src/routes/_app/_builder/detection/scenarios/$scenarioId/home.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ function WorkflowSection({ scenario, access }: { scenario: Scenario; access: Fea
486486
>
487487
<button
488488
type="button"
489+
aria-label={t('scenarios:home.workflow_type.tooltip_aria_label')}
489490
className="text-purple-disabled hover:text-purple-primary cursor-pointer transition-colors"
490491
>
491492
<Icon icon="tip" className="size-5" />

0 commit comments

Comments
 (0)