mirror of https://github.com/ghostfolio/ghostfolio
committed by
GitHub
13 changed files with 148 additions and 68 deletions
@ -0,0 +1,2 @@ |
|||||
|
export type AccessLevel = |
||||
|
'CREATE_READ_UPDATE_DELETE' | 'READ' | 'READ_RESTRICTED'; |
||||
@ -0,0 +1,16 @@ |
|||||
|
<span class="align-items-center d-flex"> |
||||
|
@switch (accessLevel()) { |
||||
|
@case ('CREATE_READ_UPDATE_DELETE') { |
||||
|
<ion-icon class="mr-1" name="create-outline" /> |
||||
|
<ng-container i18n>View and manage</ng-container> |
||||
|
} |
||||
|
@case ('READ') { |
||||
|
<ion-icon class="mr-1" name="lock-open-outline" /> |
||||
|
<ng-container i18n>View</ng-container> |
||||
|
} |
||||
|
@case ('READ_RESTRICTED') { |
||||
|
<ion-icon class="mr-1" name="lock-closed-outline" /> |
||||
|
<ng-container i18n>Restricted view</ng-container> |
||||
|
} |
||||
|
} |
||||
|
</span> |
||||
@ -0,0 +1,42 @@ |
|||||
|
import { CommonModule } from '@angular/common'; |
||||
|
import { IonIcon } from '@ionic/angular/standalone'; |
||||
|
import { moduleMetadata } from '@storybook/angular'; |
||||
|
import type { Meta, StoryObj } from '@storybook/angular'; |
||||
|
|
||||
|
import { GfAccessLevelIconComponent } from './access-level-icon.component'; |
||||
|
|
||||
|
export default { |
||||
|
title: 'Access Level Icon', |
||||
|
component: GfAccessLevelIconComponent, |
||||
|
decorators: [ |
||||
|
moduleMetadata({ |
||||
|
imports: [CommonModule, IonIcon] |
||||
|
}) |
||||
|
], |
||||
|
argTypes: { |
||||
|
accessLevel: { |
||||
|
control: 'select', |
||||
|
options: ['CREATE_READ_UPDATE_DELETE', 'READ', 'READ_RESTRICTED'] |
||||
|
} |
||||
|
} |
||||
|
} as Meta<GfAccessLevelIconComponent>; |
||||
|
|
||||
|
type Story = StoryObj<GfAccessLevelIconComponent>; |
||||
|
|
||||
|
export const RestrictedView: Story = { |
||||
|
args: { |
||||
|
accessLevel: 'READ_RESTRICTED' |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
export const View: Story = { |
||||
|
args: { |
||||
|
accessLevel: 'READ' |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
export const ViewAndManage: Story = { |
||||
|
args: { |
||||
|
accessLevel: 'CREATE_READ_UPDATE_DELETE' |
||||
|
} |
||||
|
}; |
||||
@ -0,0 +1,24 @@ |
|||||
|
import { AccessLevel } from '@ghostfolio/common/types'; |
||||
|
|
||||
|
import { ChangeDetectionStrategy, Component, input } from '@angular/core'; |
||||
|
import { IonIcon } from '@ionic/angular/standalone'; |
||||
|
import { addIcons } from 'ionicons'; |
||||
|
import { |
||||
|
createOutline, |
||||
|
lockClosedOutline, |
||||
|
lockOpenOutline |
||||
|
} from 'ionicons/icons'; |
||||
|
|
||||
|
@Component({ |
||||
|
changeDetection: ChangeDetectionStrategy.OnPush, |
||||
|
imports: [IonIcon], |
||||
|
selector: 'gf-access-level-icon', |
||||
|
templateUrl: './access-level-icon.component.html' |
||||
|
}) |
||||
|
export class GfAccessLevelIconComponent { |
||||
|
public readonly accessLevel = input.required<AccessLevel>(); |
||||
|
|
||||
|
public constructor() { |
||||
|
addIcons({ createOutline, lockClosedOutline, lockOpenOutline }); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
export * from './access-level-icon.component'; |
||||
Loading…
Reference in new issue