mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
cleanup header actions module
This commit is contained in:
committed by
Yasa-Nataliya
parent
0ec1a5529e
commit
76cd1eca89
@@ -23,12 +23,14 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnDestroy, ViewEncapsulation } from '@angular/core';
|
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { ContentManagementService } from '../../services/content-management.service';
|
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||||
import { AppExtensionService, PageComponent } from '@alfresco/aca-shared';
|
|
||||||
import { SetCurrentFolderAction, AppStore } from '@alfresco/aca-shared/store';
|
import { SetCurrentFolderAction, AppStore } from '@alfresco/aca-shared/store';
|
||||||
|
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'aca-header-actions',
|
selector: 'aca-header-actions',
|
||||||
@@ -36,14 +38,38 @@ import { SetCurrentFolderAction, AppStore } from '@alfresco/aca-shared/store';
|
|||||||
styleUrls: ['./header-actions.component.scss'],
|
styleUrls: ['./header-actions.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class HeaderActionsComponent extends PageComponent implements OnDestroy {
|
export class HeaderActionsComponent implements OnInit, OnDestroy {
|
||||||
constructor(private router: Router, store: Store<AppStore>, content: ContentManagementService, extensions: AppExtensionService) {
|
private onDestroy$ = new Subject<boolean>();
|
||||||
super(store, extensions, content);
|
|
||||||
|
createActions: Array<ContentActionRef> = [];
|
||||||
|
uploadActions: Array<ContentActionRef> = [];
|
||||||
|
|
||||||
|
constructor(private router: Router, private store: Store<AppStore>, private extensions: AppExtensionService) {}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.extensions
|
||||||
|
.getCreateActions()
|
||||||
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
|
.subscribe((actions) => {
|
||||||
|
this.createActions = actions;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.extensions
|
||||||
|
.getUploadActions()
|
||||||
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
|
.subscribe((actions) => {
|
||||||
|
this.uploadActions = actions;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
this.onDestroy$.next(true);
|
||||||
|
this.onDestroy$.complete();
|
||||||
this.store.dispatch(new SetCurrentFolderAction(null));
|
this.store.dispatch(new SetCurrentFolderAction(null));
|
||||||
super.ngOnDestroy();
|
}
|
||||||
|
|
||||||
|
trackByActionId(_: number, action: ContentActionRef) {
|
||||||
|
return action.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private isPersonalFilesRoute(): boolean {
|
private isPersonalFilesRoute(): boolean {
|
||||||
@@ -59,11 +85,11 @@ export class HeaderActionsComponent extends PageComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canShowCreateButton(): boolean {
|
canShowCreateButton(): boolean {
|
||||||
return this.isPersonalFilesRoute() || this.isFavoriteLibrariesRoute() || this.isLibrariesRoute();
|
return this.createActions.length > 0 && (this.isPersonalFilesRoute() || this.isFavoriteLibrariesRoute() || this.isLibrariesRoute());
|
||||||
}
|
}
|
||||||
|
|
||||||
canShowUploadButton(): boolean {
|
canShowUploadButton(): boolean {
|
||||||
return this.isPersonalFilesRoute();
|
return this.uploadActions.length > 0 && this.isPersonalFilesRoute();
|
||||||
}
|
}
|
||||||
|
|
||||||
canShowSearchSeparator(): boolean {
|
canShowSearchSeparator(): boolean {
|
||||||
|
@@ -26,29 +26,13 @@
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CoreModule } from '@alfresco/adf-core';
|
import { CoreModule } from '@alfresco/adf-core';
|
||||||
import { ContentModule } from '@alfresco/adf-content-services';
|
|
||||||
import { AppCommonModule } from '../common/common.module';
|
|
||||||
import { AppToolbarModule } from '../toolbar/toolbar.module';
|
import { AppToolbarModule } from '../toolbar/toolbar.module';
|
||||||
import { DirectivesModule } from '../../directives/directives.module';
|
|
||||||
import { ContextMenuModule } from '../context-menu/context-menu.module';
|
|
||||||
import { AppSearchInputModule } from '../search/search-input.module';
|
import { AppSearchInputModule } from '../search/search-input.module';
|
||||||
import { HeaderActionsComponent } from './header-actions.component';
|
import { HeaderActionsComponent } from './header-actions.component';
|
||||||
import { MainActionModule } from '../main-action/main-action.module';
|
import { MainActionModule } from '../main-action/main-action.module';
|
||||||
import { PageLayoutModule } from '@alfresco/aca-shared';
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [CommonModule, CoreModule.forChild(), AppToolbarModule, AppSearchInputModule, MainActionModule],
|
||||||
CommonModule,
|
|
||||||
CoreModule.forChild(),
|
|
||||||
ContentModule.forChild(),
|
|
||||||
DirectivesModule,
|
|
||||||
AppCommonModule,
|
|
||||||
AppToolbarModule,
|
|
||||||
ContextMenuModule,
|
|
||||||
PageLayoutModule,
|
|
||||||
AppSearchInputModule,
|
|
||||||
MainActionModule
|
|
||||||
],
|
|
||||||
declarations: [HeaderActionsComponent],
|
declarations: [HeaderActionsComponent],
|
||||||
exports: [HeaderActionsComponent]
|
exports: [HeaderActionsComponent]
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user