|
19 | 19 | constraintResponseMap, |
20 | 20 | constraintResponses, |
21 | 21 | constraintVisibilityMap, |
| 22 | + constraints, |
22 | 23 | constraintsMap, |
23 | 24 | constraintsStatus, |
24 | 25 | getConstraintDefaultsKey, |
|
51 | 52 | import { required } from '../../utilities/validators'; |
52 | 53 | import CollapsibleListControls from '../CollapsibleListControls.svelte'; |
53 | 54 | import DatePickerField from '../form/DatePickerField.svelte'; |
54 | | - import Loading from '../Loading.svelte'; |
55 | 55 | import GridMenu from '../menus/GridMenu.svelte'; |
| 56 | + import AsyncContentState from '../ui/AsyncContentState.svelte'; |
56 | 57 | import DatePickerActionButton from '../ui/DatePicker/DatePickerActionButton.svelte'; |
57 | 58 | import Panel from '../ui/Panel.svelte'; |
58 | 59 | import PanelHeaderActionButton from '../ui/PanelHeaderActionButton.svelte'; |
59 | 60 | import PanelHeaderActions from '../ui/PanelHeaderActions.svelte'; |
60 | 61 | import ConstraintListItem from './ConstraintListItem.svelte'; |
61 | 62 |
|
| 63 | + const constraintPlanSpecsError = constraintPlanSpecs.error; |
| 64 | + const constraintsError = constraints.error; |
| 65 | +
|
62 | 66 | export let gridSection: ViewGridSection; |
63 | 67 | export let user: User | null; |
64 | 68 |
|
|
138 | 142 | filterText, |
139 | 143 | showConstraintsWithNoViolations, |
140 | 144 | ); |
141 | | - $: numOfPrivateConstraints = ($constraintPlanSpecs || []).length - $allowedConstraintPlanSpecs.length; |
| 145 | + $: numOfPrivateConstraints = $constraintPlanSpecs.length - $allowedConstraintPlanSpecs.length; |
142 | 146 |
|
143 | 147 | // Fetch effective arguments for JAR type constraints when specs and metadata are available |
144 | 148 | // Need to depend on both $allowedConstraintPlanSpecs and $constraintsMap to avoid race condition |
|
498 | 502 | </CollapsibleListControls> |
499 | 503 |
|
500 | 504 | <div class="pt-2"> |
501 | | - {#if $initialConstraintsLoading || $initialConstraintPlanSpecsLoading} |
502 | | - <div class="p-1"> |
503 | | - <Loading /> |
504 | | - </div> |
505 | | - {:else if !filteredConstraintPlanSpecifications.length} |
506 | | - <div class="st-typography-label filter-label-row pt-1"> |
507 | | - <div class="filter-label">No constraints found</div> |
508 | | - <div class="private-label"> |
509 | | - {#if numOfPrivateConstraints > 0} |
510 | | - {numOfPrivateConstraints} constraint{numOfPrivateConstraints !== 1 ? 's' : ''} |
511 | | - {numOfPrivateConstraints > 1 ? 'are' : 'is'} private and not shown |
512 | | - {/if} |
| 505 | + <AsyncContentState |
| 506 | + loading={$initialConstraintsLoading || $initialConstraintPlanSpecsLoading} |
| 507 | + error={$constraintsError || $constraintPlanSpecsError || null} |
| 508 | + errorMessage="Failed to load constraints" |
| 509 | + showRetry |
| 510 | + empty={!filteredConstraintPlanSpecifications.length} |
| 511 | + on:retry={() => { |
| 512 | + constraints.restartSocket(); |
| 513 | + constraintPlanSpecs.restartSocket(); |
| 514 | + }} |
| 515 | + > |
| 516 | + <svelte:fragment slot="empty"> |
| 517 | + <div class="st-typography-label filter-label-row pt-1"> |
| 518 | + <div class="filter-label">No constraints found</div> |
| 519 | + <div class="private-label"> |
| 520 | + {#if numOfPrivateConstraints > 0} |
| 521 | + {numOfPrivateConstraints} constraint{numOfPrivateConstraints !== 1 ? 's' : ''} |
| 522 | + {numOfPrivateConstraints > 1 ? 'are' : 'is'} private and not shown |
| 523 | + {/if} |
| 524 | + </div> |
513 | 525 | </div> |
514 | | - </div> |
515 | | - {:else} |
| 526 | + </svelte:fragment> |
| 527 | + |
516 | 528 | <div class="st-typography-label filter-label-row pt-1"> |
517 | 529 | <div class="filter-label"> |
518 | 530 | {#if $cachedConstraintsStatus} |
|
572 | 584 | /> |
573 | 585 | {/if} |
574 | 586 | {/each} |
575 | | - {/if} |
| 587 | + </AsyncContentState> |
576 | 588 | </div> |
577 | 589 | </svelte:fragment> |
578 | 590 | </Panel> |
|
0 commit comments