Browse Source

Feature/include admin control panel in quick links of assistant (#4955)

* Include admin control panel in quick links of assistant

* Update changelog
pull/4963/head
Hash Palak 2 weeks ago
committed by GitHub
parent
commit
d8626ffab7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      CHANGELOG.md
  2. 4
      libs/common/src/lib/routes/interfaces/interfaces.ts
  3. 7
      libs/common/src/lib/routes/routes.ts
  4. 5
      libs/ui/src/lib/assistant/assistant.component.ts

4
CHANGELOG.md

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Added
- Included the admin control panel in the quick links of the assistant
### Changed ### Changed
- Adapted the options of the date range selector in the assistant dynamically based on the user’s first activity - Adapted the options of the date range selector in the assistant dynamically based on the user’s first activity

4
libs/common/src/lib/routes/interfaces/interfaces.ts

@ -1,5 +1,7 @@
import { User } from '@ghostfolio/common/interfaces';
export interface IRoute { export interface IRoute {
excludeFromAssistant?: boolean; excludeFromAssistant?: boolean | ((aUser: User) => boolean);
path: string; path: string;
routerLink: string[]; routerLink: string[];
subRoutes?: Record<string, IRoute>; subRoutes?: Record<string, IRoute>;

7
libs/common/src/lib/routes/routes.ts

@ -1,3 +1,6 @@
import { User } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions';
import '@angular/localize/init'; import '@angular/localize/init';
import { IRoute } from './interfaces/interfaces'; import { IRoute } from './interfaces/interfaces';
@ -21,7 +24,9 @@ export const internalRoutes: Record<string, IRoute> = {
title: $localize`Settings` title: $localize`Settings`
}, },
adminControl: { adminControl: {
excludeFromAssistant: true, excludeFromAssistant: (aUser: User) => {
return hasPermission(aUser?.permissions, permissions.accessAdminControl);
},
path: 'admin', path: 'admin',
routerLink: ['/admin'], routerLink: ['/admin'],
subRoutes: { subRoutes: {

5
libs/ui/src/lib/assistant/assistant.component.ts

@ -41,6 +41,7 @@ import { MatSelectModule } from '@angular/material/select';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { Account, AssetClass, DataSource } from '@prisma/client'; import { Account, AssetClass, DataSource } from '@prisma/client';
import { differenceInYears } from 'date-fns'; import { differenceInYears } from 'date-fns';
import { isFunction } from 'lodash';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { EMPTY, Observable, Subject, merge, of } from 'rxjs'; import { EMPTY, Observable, Subject, merge, of } from 'rxjs';
import { import {
@ -627,6 +628,10 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
const allRoutes = Object.values(internalRoutes) const allRoutes = Object.values(internalRoutes)
.filter(({ excludeFromAssistant }) => { .filter(({ excludeFromAssistant }) => {
if (isFunction(excludeFromAssistant)) {
return excludeFromAssistant(this.user);
}
return !excludeFromAssistant; return !excludeFromAssistant;
}) })
.reduce((acc, route) => { .reduce((acc, route) => {

Loading…
Cancel
Save