| ... | @@ -67,6 +67,7 @@ import { | ... | @@ -67,6 +67,7 @@ import { |
| 67 | type WhenVariableOption, | 67 | type WhenVariableOption, |
| 68 | unknownWhenVariables, | 68 | unknownWhenVariables, |
| 69 | whenAstToExpression, | 69 | whenAstToExpression, |
| | 70 | whenNodeRemoveLabel, |
| 70 | } from "./KeybindingsSettings.logic"; | 71 | } from "./KeybindingsSettings.logic"; |
| 71 | import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout"; | 72 | import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout"; |
| 72 | import { searchableSetting } from "./settingsSearch"; | 73 | import { searchableSetting } from "./settingsSearch"; |
| ... | @@ -349,6 +350,37 @@ function WhenVariableSelect({ | ... | @@ -349,6 +350,37 @@ function WhenVariableSelect({ |
| 349 | ); | 350 | ); |
| 350 | } | 351 | } |
| 351 | | 352 | |
| | 353 | function WhenExpressionRemoveButton({ |
| | 354 | label, |
| | 355 | className, |
| | 356 | onRemove, |
| | 357 | }: { |
| | 358 | label: string; |
| | 359 | className?: string | undefined; |
| | 360 | onRemove: () => void; |
| | 361 | }) { |
| | 362 | return ( |
| | 363 | <Tooltip> |
| | 364 | <TooltipTrigger |
| | 365 | delay={200} |
| | 366 | render={ |
| | 367 | <Button |
| | 368 | type="button" |
| | 369 | variant="ghost" |
| | 370 | size="icon-sm" |
| | 371 | className={cn("size-7", className)} |
| | 372 | aria-label={label} |
| | 373 | onClick={onRemove} |
| | 374 | /> |
| | 375 | } |
| | 376 | > |
| | 377 | <MinusIcon aria-hidden className="size-3.5" /> |
| | 378 | </TooltipTrigger> |
| | 379 | <TooltipPopup side="top">{label}</TooltipPopup> |
| | 380 | </Tooltip> |
| | 381 | ); |
| | 382 | } |
| | 383 | |
| 352 | function WhenExpressionNodeEditor({ | 384 | function WhenExpressionNodeEditor({ |
| 353 | node, | 385 | node, |
| 354 | variables, | 386 | variables, |
| ... | @@ -388,16 +420,10 @@ function WhenExpressionNodeEditor({ | ... | @@ -388,16 +420,10 @@ function WhenExpressionNodeEditor({ |
| 388 | onChange={(value) => onChange(setConditionIdentifier(node, value))} | 420 | onChange={(value) => onChange(setConditionIdentifier(node, value))} |
| 389 | /> | 421 | /> |
| 390 | {onRemove ? ( | 422 | {onRemove ? ( |
| 391 | <Button | 423 | <WhenExpressionRemoveButton |
| 392 | type="button" | 424 | label={whenNodeRemoveLabel(node, depth)} |
| 393 | variant="ghost" | 425 | onRemove={onRemove} |
| 394 | size="icon-sm" | 426 | /> |
| 395 | className="size-7" | | |
| 396 | aria-label="Remove condition" | | |
| 397 | onClick={onRemove} | | |
| 398 | > | | |
| 399 | <MinusIcon className="size-3.5" /> | | |
| 400 | </Button> | | |
| 401 | ) : null} | 427 | ) : null} |
| 402 | </div> | 428 | </div> |
| 403 | ); | 429 | ); |
| ... | @@ -423,16 +449,11 @@ function WhenExpressionNodeEditor({ | ... | @@ -423,16 +449,11 @@ function WhenExpressionNodeEditor({ |
| 423 | Not | 449 | Not |
| 424 | </Toggle> | 450 | </Toggle> |
| 425 | {onRemove ? ( | 451 | {onRemove ? ( |
| 426 | <Button | 452 | <WhenExpressionRemoveButton |
| 427 | type="button" | 453 | label={whenNodeRemoveLabel(node, depth)} |
| 428 | variant="ghost" | 454 | className="ml-auto" |
| 429 | size="icon-sm" | 455 | onRemove={onRemove} |
| 430 | className="ml-auto size-7" | 456 | /> |
| 431 | aria-label="Remove negated group" | | |
| 432 | onClick={onRemove} | | |
| 433 | > | | |
| 434 | <MinusIcon className="size-3.5" /> | | |
| 435 | </Button> | | |
| 436 | ) : null} | 457 | ) : null} |
| 437 | </div> | 458 | </div> |
| 438 | <div className="relative pl-4"> | 459 | <div className="relative pl-4"> |
| ... | @@ -546,16 +567,11 @@ function WhenExpressionNodeEditor({ | ... | @@ -546,16 +567,11 @@ function WhenExpressionNodeEditor({ |
| 546 | Group | 567 | Group |
| 547 | </Button> | 568 | </Button> |
| 548 | {onRemove ? ( | 569 | {onRemove ? ( |
| 549 | <Button | 570 | <WhenExpressionRemoveButton |
| 550 | type="button" | 571 | label={whenNodeRemoveLabel(node, depth)} |
| 551 | variant="ghost" | 572 | className="ml-auto" |
| 552 | size="icon-sm" | 573 | onRemove={onRemove} |
| 553 | className="ml-auto size-7" | 574 | /> |
| 554 | aria-label="Remove group" | | |
| 555 | onClick={onRemove} | | |
| 556 | > | | |
| 557 | <MinusIcon className="size-3.5" /> | | |
| 558 | </Button> | | |
| 559 | ) : null} | 575 | ) : null} |
| 560 | </div> | 576 | </div> |
| 561 | <div className="space-y-2"> | 577 | <div className="space-y-2"> |