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
2 changes: 2 additions & 0 deletions ui/dashboard/src/@locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@
"and": "AND",
"or": "OR",
"see-more": "See more",
"show-count-user-segments_one": "{{count}} user segment selected",
"show-count-user-segments_other": "{{count}} user segments selected",
"default": "Default",
"sort-by": "Sort by: {{sortBy}}",
"sort-asc": "Ascending",
Expand Down
2 changes: 2 additions & 0 deletions ui/dashboard/src/@locales/ja/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@
"and": "AND",
"or": "OR",
"see-more": "もっと見る",
"show-count-user-segments_one": "ユーザーセグメントを{{count}}件選択中",
"show-count-user-segments_other": "ユーザーセグメントを{{count}}件選択中",
"default": "デフォルト",
"sort-by": "並び替え: {{sortBy}}",
"sort-asc": "昇順",
Expand Down
112 changes: 67 additions & 45 deletions ui/dashboard/src/elements/rule-clauses-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Dropdown from 'components/dropdown';
import Form from 'components/form';
import Icon from 'components/icon';
import Input from 'components/input';
import { Popover } from 'components/popover';
import { Tooltip } from 'components/tooltip';
import DropdownMenuWithSearch from 'elements/dropdown-with-search';
import FeatureFlagStatus from 'elements/feature-flag-status';
Expand Down Expand Up @@ -494,51 +495,34 @@ const RuleClausesForm = ({
}}
/>
) : isUserSegment ? (
<>
<Dropdown
options={segmentOptions}
multiselect
value={(value as string[]) || []}
labelCustom={
selectedSegments.length
? truncateBySide(
selectedSegments
.map(item => item.name)
.join(', '),
50
)
: ''
}
onChange={val => {
const current =
(value as string[]) || [];
const next = current.includes(
val as string
)
? current.filter(v => v !== val)
: [...current, val as string];
field.onChange(next);
}}
onClear={() => field.onChange([])}
placeholder={t('common:select-value')}
disabled={!segmentOptions?.length}
className="w-full [&>div>p]:truncate [&>div]:max-w-[calc(100%-36px)]"
/>
{selectedSegments.length > 0 && (
<div className="flex flex-col w-full gap-y-1 mt-2">
{selectedSegments.map(item => (
<Link
key={item.id}
target="_blank"
to={`/${currentEnvironment.urlCode}${PAGE_PATH_USER_SEGMENTS}/${item.id}`}
className="typo-para-small text-primary-500 hover:underline truncate w-fit max-w-full"
>
{`${item.name} (${getSegmentSummary(item, t)})`}
</Link>
))}
</div>
)}
</>
<Dropdown
options={segmentOptions}
multiselect
value={(value as string[]) || []}
labelCustom={
selectedSegments.length
? truncateBySide(
selectedSegments
.map(item => item.name)
.join(', '),
50
)
: ''
}
onChange={val => {
const current = (value as string[]) || [];
const next = current.includes(
val as string
)
? current.filter(v => v !== val)
: [...current, val as string];
field.onChange(next);
}}
onClear={() => field.onChange([])}
placeholder={t('common:select-value')}
disabled={!segmentOptions?.length}
className="w-full [&>div>p]:truncate [&>div]:max-w-[calc(100%-36px)]"
/>
) : isFlag ? (
<Dropdown
options={variationOptions}
Expand Down Expand Up @@ -575,6 +559,44 @@ const RuleClausesForm = ({
/>
)}
</Form.Control>
{isUserSegment && selectedSegments.length > 0 && (
Comment thread
steveninhle marked this conversation as resolved.
<div className="mt-0.5">
<Popover
align="start"
trigger={
<div>
<span className="typo-para-small font-medium text-primary-500">
{t(
'common:show-count-user-segments',
{
count: selectedSegments.length
Comment thread
steveninhle marked this conversation as resolved.
}
)}
</span>
</div>
}
triggerCls="w-fit justify-start"
className="flex flex-col w-[300px] gap-y-0.5 p-0 overflow-hidden"
>
<div className="flex flex-col gap-y-0.5 max-h-[220px] overflow-y-auto small-scroll p-2">
{selectedSegments.map(item => (
<div
key={item.id}
className="flex items-center w-full gap-x-1 rounded hover:bg-primary-50"
>
<Link
target="_blank"
to={`/${currentEnvironment.urlCode}${PAGE_PATH_USER_SEGMENTS}/${item.id}`}
className="typo-para-small text-primary-500 hover:underline truncate flex-1 min-w-0 px-1 py-1"
>
{`${item.name} (${getSegmentSummary(item, t)})`}
</Link>
</div>
))}
</div>
</Popover>
</div>
)}
<Form.Message />
</Form.Item>
);
Expand Down