<div class="row">
  <div class="col-sm-2"
       *ngIf="subVolumeGroups$ | async as subVolumeGroups">
    <cd-vertical-navigation title="Groups"
                            [items]="subvolumeGroupList"
                            inputIdentifier="group-filter"
                            (emitActiveItem)="selectSubVolumeGroup($event)"></cd-vertical-navigation>
  </div>
  <div class="col-10 vertical-line">
    <cd-table [data]="subVolumes$ | async"
              columnMode="flex"
              [columns]="columns"
              selectionType="single"
              [hasDetails]="false"
              (fetchData)="fetchData()"
              (updateSelection)="updateSelection($event)">

      <div class="table-actions">
        <cd-table-actions [permission]="permissions.cephfs"
                          [selection]="selection"
                          class="btn-group"
                          id="cephfs-subvolume-actions"
                          [tableActions]="tableActions">
        </cd-table-actions>
      </div>
    </cd-table>
  </div>
</div>

<ng-template #quotaUsageTpl
             let-row="data.row">
  <cd-usage-bar *ngIf="row.info.bytes_pcent && row.info.bytes_pcent !== 'undefined'; else noLimitTpl"
                [total]="row.info.bytes_quota"
                [used]="row.info.bytes_used"
                [title]="row.name"
                decimals="2"></cd-usage-bar>

  <ng-template #noLimitTpl>
    <span ngbTooltip="Quota limit is not set"
          *ngIf="row.info.bytes_pcent === 'undefined'"
          i18n-ngbTooltip>
      {{row.info.bytes_used | dimlessBinary}}</span>
  </ng-template>
</ng-template>

<ng-template #typeTpl
             let-value="data.value">
  <cd-label [value]="value"></cd-label>
</ng-template>

<ng-template #modeToHumanReadableTpl
             let-value="data.value">
  <cds-tag *ngFor="let result of (value | octalToHumanReadable)"
           [class]="result.class"
           [ngbTooltip]="result.toolTip">
    {{ result.content }}
</cds-tag>
</ng-template>

<ng-template #nameTpl
             let-row="data.row">
  <span class="fw-bold">{{row.name}}</span>

  <span *ngIf="row?.info?.state === 'complete'; else snapshotRetainedTpl">
    <i [ngClass]="[icons.success, icons.large]"
       ngbTooltip="{{row.name}} is ready to use"
       class="text-success"></i>
  </span>

  <ng-template #snapshotRetainedTpl>
    <i [ngClass]="[icons.warning, icons.large]"
       class="text-warning"
       ngbTooltip="{{row.name}} is removed after retaining the snapshots"></i>
  </ng-template>

  <cd-label [value]="row.info.type"
            *ngIf="row.info.type !== 'subvolume'"></cd-label>

  <cd-label value="namespaced"
            *ngIf="row.info.pool_namespace"
            [tooltipText]="row.info.pool_namespace"></cd-label>
</ng-template>

<ng-template #removeTmpl
             let-form="form">
  <ng-container [formGroup]="form">
    <ng-container formGroupName="child">
      <cd-alert-panel *ngIf="errorMessage.length > 1"
                      type="error">
              {{errorMessage}}
      </cd-alert-panel>
      <div class="form-item cds-pt-3">
        <cds-checkbox id="retainSnapshots"
                      formControlName="retainSnapshots"
                      autofocus
                      [required]="true"
                      modal-primary-focus
                      ariaLabel="confirmation"
                      i18n>Retain snapshots
          <cd-help-text>The subvolume can be removed retaining
                  existing snapshots using this option.
                   If snapshots are retained, the subvolume is considered empty for all
                    operations not involving the retained snapshots.</cd-help-text>
        </cds-checkbox>
      </div>
    </ng-container>
  </ng-container>
</ng-template>
