mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-8433] ACA: User Profile Service (#3957)
This commit is contained in:
@@ -27,8 +27,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AppStore, getUserProfile } from '@alfresco/aca-shared/store';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { UserProfileService } from '@alfresco/aca-shared';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -39,6 +38,7 @@ import { Store } from '@ngrx/store';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class UserInfoComponent {
|
||||
private store = inject<Store<AppStore>>(Store<AppStore>);
|
||||
user$ = this.store.select(getUserProfile);
|
||||
private userProfileService = inject(UserProfileService);
|
||||
|
||||
user$ = this.userProfileService.userProfile$;
|
||||
}
|
||||
|
@@ -28,9 +28,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { ToolbarMenuItemComponent } from '@alfresco/aca-shared';
|
||||
import { AppStore, getUserProfile } from '@alfresco/aca-shared/store';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { ToolbarMenuItemComponent, UserProfileService } from '@alfresco/aca-shared';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -42,8 +40,9 @@ import { Store } from '@ngrx/store';
|
||||
host: { class: 'aca-user-menu' }
|
||||
})
|
||||
export class UserMenuComponent implements OnInit {
|
||||
private store = inject<Store<AppStore>>(Store<AppStore>);
|
||||
user$ = this.store.select(getUserProfile);
|
||||
private userProfileService = inject(UserProfileService);
|
||||
|
||||
user$ = this.userProfileService.userProfile$;
|
||||
|
||||
@Input()
|
||||
actionRef: ContentActionRef;
|
||||
|
@@ -22,17 +22,10 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
AppStore,
|
||||
SetSelectedNodesAction,
|
||||
SnackbarErrorAction,
|
||||
SnackbarInfoAction,
|
||||
getAppSelection,
|
||||
getUserProfile
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { AppHookService } from '@alfresco/aca-shared';
|
||||
import { ProfileState, SelectionState } from '@alfresco/adf-extensions';
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { AppStore, SetSelectedNodesAction, SnackbarErrorAction, SnackbarInfoAction, getAppSelection } from '@alfresco/aca-shared/store';
|
||||
import { AppHookService, UserProfileService } from '@alfresco/aca-shared';
|
||||
import { SelectionState } from '@alfresco/adf-extensions';
|
||||
import { Component, inject, ViewEncapsulation } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs';
|
||||
import { LibraryMembershipDirective, LibraryMembershipErrorEvent, LibraryMembershipToggleEvent } from '@alfresco/adf-content-services';
|
||||
@@ -64,12 +57,13 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
host: { class: 'app-toggle-join-library' }
|
||||
})
|
||||
export class ToggleJoinLibraryButtonComponent {
|
||||
private userProfileService = inject(UserProfileService);
|
||||
|
||||
selection$: Observable<SelectionState>;
|
||||
profile$: Observable<ProfileState>;
|
||||
profile$ = this.userProfileService.userProfile$;
|
||||
|
||||
constructor(private store: Store<AppStore>, private appHookService: AppHookService) {
|
||||
this.selection$ = this.store.select(getAppSelection);
|
||||
this.profile$ = this.store.select(getUserProfile);
|
||||
}
|
||||
|
||||
onToggleEvent(event: LibraryMembershipToggleEvent) {
|
||||
|
@@ -22,10 +22,16 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { getUserProfile } from '@alfresco/aca-shared/store';
|
||||
import { DocumentListPresetRef, DynamicColumnComponent } from '@alfresco/adf-extensions';
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { ContextActionsDirective, PageComponent, PageLayoutComponent, PaginationDirective, ToolbarComponent } from '@alfresco/aca-shared';
|
||||
import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import {
|
||||
ContextActionsDirective,
|
||||
PageComponent,
|
||||
PageLayoutComponent,
|
||||
PaginationDirective,
|
||||
ToolbarComponent,
|
||||
UserProfileService
|
||||
} from '@alfresco/aca-shared';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { DocumentListModule } from '@alfresco/adf-content-services';
|
||||
@@ -52,7 +58,9 @@ import { DocumentListDirective } from '../../directives/document-list.directive'
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class TrashcanComponent extends PageComponent implements OnInit {
|
||||
user$ = this.store.select(getUserProfile);
|
||||
private userProfileService = inject(UserProfileService);
|
||||
|
||||
user$ = this.userProfileService.userProfile$;
|
||||
columns: DocumentListPresetRef[] = [];
|
||||
|
||||
ngOnInit() {
|
||||
|
@@ -92,32 +92,7 @@ export function appReducer(state: AppState = INITIAL_APP_STATE, action: Action):
|
||||
}
|
||||
|
||||
function updateUser(state: AppState, action: SetUserProfileAction): AppState {
|
||||
const newState = { ...state };
|
||||
const user = action.payload.person;
|
||||
const groups = [...(action.payload.groups || [])];
|
||||
|
||||
const id = user.id;
|
||||
const firstName = user.firstName || '';
|
||||
const lastName = user.lastName || '';
|
||||
const userName = `${firstName} ${lastName}`;
|
||||
const initials = [firstName[0], lastName[0]].join('');
|
||||
const email = user.email;
|
||||
|
||||
const capabilities = user.capabilities;
|
||||
const isAdmin = capabilities ? capabilities.isAdmin : true;
|
||||
|
||||
newState.user = {
|
||||
firstName,
|
||||
lastName,
|
||||
userName,
|
||||
initials,
|
||||
isAdmin,
|
||||
id,
|
||||
groups,
|
||||
email
|
||||
};
|
||||
|
||||
return newState;
|
||||
return { ...state, user: { ...action.payload } };
|
||||
}
|
||||
|
||||
function updateCurrentFolder(state: AppState, action: SetCurrentFolderAction) {
|
||||
|
Reference in New Issue
Block a user