<vdr-action-bar>
    <vdr-ab-right>
        <vdr-action-bar-items locationId="channel-list"></vdr-action-bar-items>
        <a class="btn btn-primary" [routerLink]="['./create']" *vdrIfPermissions="'SuperAdmin'">
            <clr-icon shape="plus"></clr-icon>
            {{ 'settings.create-new-channel' | translate }}
        </a>
    </vdr-ab-right>
</vdr-action-bar>

<vdr-data-table [items]="channels$ | async">
    <vdr-dt-column>{{ 'common.code' | translate }}</vdr-dt-column>
    <vdr-dt-column></vdr-dt-column>
    <vdr-dt-column></vdr-dt-column>
    <ng-template let-channel="item">
        <td class="left align-middle">
            <vdr-channel-badge [channelCode]="channel.code"></vdr-channel-badge>
            {{ channel.code | channelCodeToLabel | translate }}
        </td>
        <td class="right align-middle">
            <vdr-table-row-action
                iconShape="edit"
                [label]="'common.edit' | translate"
                [linkTo]="['./', channel.id]"
            ></vdr-table-row-action>
        </td>
        <td class="right align-middle">
            <vdr-dropdown>
                <button type="button" class="btn btn-link btn-sm" vdrDropdownTrigger [disabled]="isDefaultChannel(channel.code)">
                    {{ 'common.actions' | translate }}
                    <clr-icon shape="caret down"></clr-icon>
                </button>
                <vdr-dropdown-menu vdrPosition="bottom-right">
                    <button
                        type="button"
                        class="delete-button"
                        (click)="deleteChannel(channel.id)"
                        [disabled]="!('SuperAdmin' | hasPermission)"
                        vdrDropdownItem
                    >
                        <clr-icon shape="trash" class="is-danger"></clr-icon>
                        {{ 'common.delete' | translate }}
                    </button>
                </vdr-dropdown-menu>
            </vdr-dropdown>
        </td>
    </ng-template>
</vdr-data-table>
