<div *ngIf="showButton" mat-button [matMenuTriggerFor]="modelMenu" 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]="modelMenu">
</div>
<mat-menu #modelMenu="matMenu" [hasBackdrop]="false">
  <button mat-menu-item (click)="publishPopup()" [disabled]="isExample || model?.ready">
    <i [class]="'fa ' + ICONS.PUBLISHED"></i>Publish
  </button>
  <button mat-menu-item (click)="archiveClicked()" [disabled]="isExample">
    <i [class]="'fa ' + (model?.system_tags?.includes('archived') ? ICONS.SHOW : ICONS.HIDE)"></i>
    {{model?.system_tags?.includes('archived') ? 'Restore from archive' : 'Archive'}}
  </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)="downloadModelFileClicked()" [disabled]="isLocalFile">
    <i [class]="'fa ' + ICONS.DOWNLOAD"></i>Download
  </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]="model?.tags"
    [tagsFilterByProject]="tagsFilterByProject"
    [projectTags]="projectTags"
    [companyTags]="companyTags"
    (tagSelected)="tagSelected.emit($event)">
  </sm-tags-menu>
</mat-menu>
