@inherits ComponentBase

<TableContainer T="IndexViewModel"
    @ref="_container" 
    @bind-Search="_search" 
    Title="@_title" 
    Breadcrumbs="@_breadcrumbs" 
    Data="LoadDataAsync"
    OnAdd="()=>_createDialog?.ToggleAsync()">
    <Header>
        <MudTh>
            <MudTableSortLabel SortLabel="Name" T="IndexViewModel">
                Name
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Description" T="IndexViewModel">
                Description
            </MudTableSortLabel>
        </MudTh>
        <MudTh>
            <MudTableSortLabel SortLabel="Hosts" T="IndexViewModel">
                Hosts
            </MudTableSortLabel>
        </MudTh>
    </Header>
    <RowTemplate>
        <MudTd DataLabel="Name">
            <MudLink Href="@Navigation.Management.HostGroups.DetailsHref(context.Id.ToString())" Typo="Typo.inherit" Underline="Underline.None">
                @context?.Name
            </MudLink>
        </MudTd>
        <MudTd DataLabel="Description">
            <MudText>
                @context.Description
            </MudText>
        </MudTd>
        <MudTd DataLabel="Hosts">
            <MudLink Href="@Navigation.Management.HostGroups.HostsHref(context.Id.ToString())" Typo="Typo.inherit" Underline="Underline.None">
                @context.Hosts
            </MudLink>
        </MudTd>
    </RowTemplate>
    <ActionTemplate>
        <MudMenuItem OnClick="@(()=>_editDialog?.ToggleAsync(context.Id?.ToString()))">
            Edit
        </MudMenuItem>
        <MudMenuItem OnClick="@(()=>_deleteDialog?.ToggleAsync(context.Id?.ToString()))">
            Delete
        </MudMenuItem>
    </ActionTemplate>
</TableContainer>

<HostGroupCreateDialog @ref="_createDialog" OnChanges="OnRefreshAsync" />
<HostGroupEditDialog @ref="_editDialog" OnChanges="OnRefreshAsync" />
<HostGroupDeleteDialog @ref="_deleteDialog" OnChanges="OnRefreshAsync" />

 @code {
    private HostGroupCreateDialog? _createDialog;
    private HostGroupEditDialog? _editDialog;
    private HostGroupDeleteDialog? _deleteDialog;
}