mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-06 14:55:19 -04:00
0bbb0ff28f
Co-authored-by: KindlyFire <10267586+kindlyfire@users.noreply.github.com> Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Adam Havránek <adamhavra@seznam.cz> Co-authored-by: Aindriú Mac Giolla Eoin <aindriu80@gmail.com> Co-authored-by: Alexey <lewadedun@gmail.com> Co-authored-by: Anon Bitardov <timurvolga23+weblate@gmail.com> Co-authored-by: Ferran <ferrancette@gmail.com> Co-authored-by: Gneb <goozi12345@gmail.com> Co-authored-by: Robin Stolpe <robinstolpe@slashmad.com> Co-authored-by: 안세훈 <on9686@gmail.com> Co-authored-by: Tijl Van den Brugghen <contact@tijlvdb.me>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import {Observable} from "rxjs";
|
|
import {Action} from "./action";
|
|
import {User} from "../user/user";
|
|
import {Role} from "../../_services/account.service";
|
|
import {ActionResultCallback} from "./action-result";
|
|
|
|
/**
|
|
* Callback for an action
|
|
*/
|
|
export type ActionCallback<T> = (action: ActionItem<T>, entity: T) => void;
|
|
export type ActionShouldRenderFunc<T> = (action: ActionItem<T>, entity: T, user: User) => boolean;
|
|
|
|
export interface ActionItem<T> {
|
|
title: string;
|
|
description: string;
|
|
action: Action;
|
|
callback: ActionResultCallback<T>;
|
|
/**
|
|
* Roles required to be present for ActionItem to show. If empty, assumes anyone can see. At least one needs to apply.
|
|
*/
|
|
requiredRoles: Role[];
|
|
children: Array<ActionItem<T>>;
|
|
/**
|
|
* An optional class which applies to an item. ie) danger on a delete action
|
|
*/
|
|
class?: string;
|
|
/**
|
|
* Indicates that there exists a separate list will be loaded from an API.
|
|
* Rule: If using this, only one child should exist in children with the Action for dynamicList.
|
|
*/
|
|
dynamicList?: Observable<{title: string, data: any}[]> | undefined;
|
|
/**
|
|
* Extra data that needs to be sent back from the card item. Used mainly for dynamicList. This will be the item from dynamicList return
|
|
*/
|
|
_extra?: {title: string, data: any};
|
|
/**
|
|
* Will call on each action to determine if it should show for the appropriate entity based on state and user
|
|
*/
|
|
shouldRender: ActionShouldRenderFunc<T>;
|
|
}
|