<div *ngIf="showButton" mat-button [matMenuTriggerFor]="experimentMenu" class="p-0 cell menu-button btn al-icon sm-md al-ico-bars-menu al-color light-grey-blue"></div>
<div *ngIf="!showButton" #contextTrigger
     style="visibility: hidden; position: fixed"
     [style.left.px]="position.x"
     [style.top.px]="position.y"
     [matMenuTriggerFor]="experimentMenu">
</div>
<mat-menu #experimentMenu="matMenu" [hasBackdrop]="false">
  <button mat-menu-item (click)="toggleFullScreen(minimizedView)" [disabled]="isSharedAndNotOwner">
    <i [class]="'fa '+ ICONS.CHART"></i> {{minimizedView? 'View full screen': 'View in experiment table'}}
  </button>
  <button mat-menu-item (click)="manageQueueClicked()" [disabled]="experiment?.status !== TaskStatusEnum.Queued">
    <i [class]="'fa '+ ICONS.QUEUED"></i>Manage Queue
  </button>
  <button mat-menu-item (click)="viewWorkerClicked()" [disabled]="experiment?.status !== TaskStatusEnum.InProgress">
    <i [class]="'fa '+ ICONS.WORKER"></i>View Worker
  </button>
  <hr>
  <button mat-menu-item (click)="shareExperimentPopup()" *ngIf="isCommunity"
          [disabled]="isExample || numSelected > 1  || experiment?.system_tags.includes('archived')">
    <i class="fas fa-link"></i>Share
  </button>
  <button mat-menu-item (click)="restoreArchive()" [disabled]="selectionHasExamples || isSharedAndNotOwner">
    <i [class]="'fa ' + (experiment && experiment?.system_tags && experiment?.system_tags.includes('archived') ? ICONS.SHOW : ICONS.HIDE)"></i>
    {{experiment?.system_tags && experiment?.system_tags.includes('archived') ? 'Restore from archive' : 'Archive' + (numSelected > 1 ? ' (' + numSelected + ' items)' : '')}}
  </button>
  <button mat-menu-item (click)="enqueueDequeue()" [disabled]="isExample || enqueueDequeueDisabled()">
    <i [class]="'fa ' + enqueueDequeueIcon()"></i>{{enqueueDequeueLabel()}}
  </button>
  <button mat-menu-item (click)="resetPopup()" [disabled]="isExample || [TaskStatusEnum.Created, TaskStatusEnum.Published, TaskStatusEnum.Publishing].includes(experiment?.status)">
    <i class="fa fa-power-off"></i>Reset
  </button>
  <button mat-menu-item (click)="stopPopup()" [disabled]="isExample || TaskStatusEnum.InProgress !== experiment?.status">
    <i [class]="'fa ' + ICONS.STOPPED"></i>Abort
  </button>
  <button
    mat-menu-item
    (click)="publishPopup()"
    [disabled]="isExample || !([TaskStatusEnum.Stopped, TaskStatusEnum.Closed, 'completed', TaskStatusEnum.Failed].includes(experiment?.status))">
    <i [class]="'fa ' + ICONS.PUBLISHED"></i>Publish
  </button>
  <hr>
  <button mat-menu-item
          [matMenuTriggerFor]="tagMenu"
          [disabled]="isExample"
          (menuOpened)="tagMenuOpened()"
          (menuClosed)="tagMenuClosed()">
    <i class="fas fa-tag rotate-135"></i>
    <span>{{'Add Tag' + (numSelected > 1 ? ' (' + numSelected + ' items)' : '')}}</span>
  </button>
  <hr>
  <button mat-menu-item (click)="clonePopup()">
    <i class="fa fa-clone"></i>Clone
  </button>
  <button mat-menu-item (click)="moveToProjectPopup()" [disabled]="isExample">
    <i class="fa fa-arrow-right"></i>Move to Project
  </button>

</mat-menu>

<mat-menu #tagMenu="matMenu">
  <sm-tags-menu
    #tagMenuContent
    class="light-theme"
    [tags]="experiment?.tags"
    [tagsFilterByProject]="tagsFilterByProject"
    [projectTags]="projectTags"
    [companyTags]="companyTags"
    (tagSelected)="tagSelected.emit($event)">
  </sm-tags-menu>
</mat-menu>
