X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fbuttons%2Faction-dropdown.component.ts;h=a4200f70f7ad97417fa98967a0f8872178b96e4a;hb=223b24e618146f85b20b5bf365bc18d14a5964cd;hp=275e2b51ecfbabd82e4816b18c3414f8e9a60dd7;hpb=f97c91f7ec4afc26ab790fbefa63d11b3060f40f;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/buttons/action-dropdown.component.ts b/client/src/app/shared/buttons/action-dropdown.component.ts index 275e2b51e..a4200f70f 100644 --- a/client/src/app/shared/buttons/action-dropdown.component.ts +++ b/client/src/app/shared/buttons/action-dropdown.component.ts @@ -1,12 +1,18 @@ import { Component, Input } from '@angular/core' +import { GlobalIconName } from '@app/shared/images/global-icon.component' export type DropdownAction = { label?: string + iconName?: GlobalIconName handler?: (a: T) => any linkBuilder?: (a: T) => (string | number)[] isDisplayed?: (a: T) => boolean } +export type DropdownButtonSize = 'normal' | 'small' +export type DropdownTheme = 'orange' | 'grey' +export type DropdownDirection = 'horizontal' | 'vertical' + @Component({ selector: 'my-action-dropdown', styleUrls: [ './action-dropdown.component.scss' ], @@ -16,14 +22,27 @@ export type DropdownAction = { export class ActionDropdownComponent { @Input() actions: DropdownAction[] | DropdownAction[][] = [] @Input() entry: T + @Input() placement = 'bottom-left' - @Input() buttonSize: 'normal' | 'small' = 'normal' + + @Input() buttonSize: DropdownButtonSize = 'normal' + @Input() buttonDirection: DropdownDirection = 'horizontal' + @Input() buttonStyled = true + @Input() label: string - @Input() theme: 'orange' | 'grey' = 'grey' + @Input() theme: DropdownTheme = 'grey' getActions () { if (this.actions.length !== 0 && Array.isArray(this.actions[0])) return this.actions return [ this.actions ] } + + areActionsDisplayed (actions: Array | DropdownAction[]>, entry: T): boolean { + return actions.some(a => { + if (Array.isArray(a)) return this.areActionsDisplayed(a, entry) + + return a.isDisplayed === undefined || a.isDisplayed(entry) + }) + } }