import { IBaseFleioObjectModel } from '@fleio-api/base-model/base-fleio-object.model';
import { IActionConfirmOptions } from './action-confirm-options';
import { NotificationService } from '@shared/ui-api/notification.service';
import { RefreshService } from '@shared/ui-api/refresh.service';
import { IIcon } from '@shared/ui/common/interfaces/icon';
import { ActionTypes } from '@objects-view/actions/action-types';
import { QueryParamsHandling } from '@angular/router';
import { IActionResult } from '@objects-view/interfaces/actions/action-result';

export type PostExecutionCallback = (action: IAction, result?: IActionResult) => void;

export interface IAction {
  object: IBaseFleioObjectModel;
  icon?: IIcon;
  name: string;
  internalName?: string;
  tooltip: string;
  primary: boolean;
  type: ActionTypes;
  routerUrl?: string;
  queryParamsHandling?: QueryParamsHandling;
  fragment?: string;
  queryParams?: Record<string, unknown>;

  displayMessages: boolean;
  confirmOptions?: IActionConfirmOptions;

  disabled?: boolean;
  ignoreFormInvalidity?: boolean;
  isRunning: boolean;
  noPermissions: boolean;
  featureName: string;
  refreshAfterExecute: boolean;
  postExecuteCallback?: PostExecutionCallback;

  execute(
    notificationService: NotificationService, refreshService: RefreshService,
    event?: MouseEvent, postExecuteCallback?: PostExecutionCallback,
  ): void;
}
