mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
library effects and actions (#441)
* library effects and actions * single selection and test fixes * navigate to site route * add experimental flag * disable test * update tests
This commit is contained in:
@@ -99,7 +99,7 @@ describe('Toolbar actions - single selection : ', () => {
|
||||
.then(done);
|
||||
});
|
||||
|
||||
it('actions not displayed for top level of File Libraries', () => {
|
||||
xit('actions not displayed for top level of File Libraries', () => {
|
||||
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
|
||||
.then(() => dataTable.waitForHeader())
|
||||
.then(() => dataTable.clickOnItemName(userSite))
|
||||
|
@@ -8,7 +8,9 @@
|
||||
"copyright":
|
||||
"© 2017 - 2018 Alfresco Software, Inc. All rights reserved."
|
||||
},
|
||||
"experimental": {},
|
||||
"experimental": {
|
||||
"libraries": true
|
||||
},
|
||||
"headerColor": "#2196F3",
|
||||
"languagePicker": false,
|
||||
"pagination": {
|
||||
|
@@ -29,6 +29,7 @@ import { Observable } from 'rxjs/Rx';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import {
|
||||
MinimalNodeEntity,
|
||||
MinimalNodeEntryEntity,
|
||||
PathInfoEntity,
|
||||
DeletedNodesPaging
|
||||
} from 'alfresco-js-api';
|
||||
@@ -230,12 +231,12 @@ export class NodeRestoreDirective {
|
||||
|
||||
if (message) {
|
||||
if (status.oneSucceeded && !status.someFailed) {
|
||||
const isSite = this.isSite(status.success[0].entry);
|
||||
const path: PathInfoEntity = status.success[0].entry.path;
|
||||
const parent = path.elements[path.elements.length - 1];
|
||||
const navigate = new NavigateRouteAction([
|
||||
'/personal-files',
|
||||
parent.id
|
||||
]);
|
||||
const route = isSite ? ['/libraries'] : ['/personal-files', parent.id];
|
||||
|
||||
const navigate = new NavigateRouteAction(route);
|
||||
|
||||
message.userAction = new SnackbarUserAction(
|
||||
'APP.ACTIONS.VIEW',
|
||||
@@ -247,6 +248,10 @@ export class NodeRestoreDirective {
|
||||
}
|
||||
}
|
||||
|
||||
private isSite(entry: MinimalNodeEntryEntity): boolean {
|
||||
return entry.nodeType === 'st:site';
|
||||
}
|
||||
|
||||
private refresh(): void {
|
||||
this.contentManagementService.nodesRestored.next();
|
||||
}
|
||||
|
@@ -34,4 +34,5 @@ export class ContentManagementService {
|
||||
nodesRestored = new Subject<any>();
|
||||
folderEdited = new Subject<any>();
|
||||
folderCreated = new Subject<any>();
|
||||
siteDeleted = new Subject<string>();
|
||||
}
|
||||
|
@@ -2,7 +2,24 @@
|
||||
<div class="inner-layout__header">
|
||||
<adf-breadcrumb root="APP.BROWSE.LIBRARIES.TITLE">
|
||||
</adf-breadcrumb>
|
||||
<adf-toolbar class="inline">
|
||||
<adf-toolbar class="inline" *ngIf="!selection.isEmpty">
|
||||
<ng-container *ifExperimental="'libraries'">
|
||||
<button
|
||||
color="primary"
|
||||
mat-icon-button
|
||||
title="{{ 'APP.ACTIONS.MORE' | translate }}"
|
||||
[matMenuTriggerFor]="actionsMenu">
|
||||
<mat-icon>more_vert</mat-icon>
|
||||
</button>
|
||||
<mat-menu #actionsMenu="matMenu" [overlapTrigger]="false">
|
||||
<button
|
||||
mat-menu-item
|
||||
(click)="deleteLibrary(selection.first)">
|
||||
<mat-icon>delete</mat-icon>
|
||||
<span>{{ 'APP.ACTIONS.DELETE' | translate }}</span>
|
||||
</button>
|
||||
</mat-menu>
|
||||
</ng-container>
|
||||
</adf-toolbar>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +27,7 @@
|
||||
<div class="inner-layout__panel">
|
||||
<adf-document-list acaDocumentList #documentList
|
||||
currentFolderId="-mysites-"
|
||||
selectionMode="none"
|
||||
selectionMode="single"
|
||||
[navigate]="false"
|
||||
[sorting]="[ 'title', 'asc' ]"
|
||||
(node-dblclick)="onNodeDoubleClick($event)">
|
||||
|
@@ -47,6 +47,8 @@ import { LibrariesComponent } from './libraries.component';
|
||||
import { StoreModule } from '@ngrx/store';
|
||||
import { appReducer } from '../../store/reducers/app.reducer';
|
||||
import { INITIAL_STATE } from '../../store/states/app.state';
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
import { ExperimentalDirective } from '../../directives/experimental.directive';
|
||||
|
||||
describe('Libraries Routed Component', () => {
|
||||
let fixture: ComponentFixture<LibrariesComponent>;
|
||||
@@ -91,7 +93,8 @@ describe('Libraries Routed Component', () => {
|
||||
NodeFavoriteDirective,
|
||||
DocumentListComponent,
|
||||
LibrariesComponent,
|
||||
AppConfigPipe
|
||||
AppConfigPipe,
|
||||
ExperimentalDirective
|
||||
],
|
||||
providers: [
|
||||
{ provide: TranslationService, useClass: TranslationMock },
|
||||
@@ -105,7 +108,9 @@ describe('Libraries Routed Component', () => {
|
||||
NodesApiService,
|
||||
DocumentListService,
|
||||
ThumbnailService,
|
||||
CustomResourcesService
|
||||
CustomResourcesService,
|
||||
|
||||
ContentManagementService
|
||||
],
|
||||
schemas: [ NO_ERRORS_SCHEMA ]
|
||||
})
|
||||
|
@@ -23,7 +23,7 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { NodesApiService } from '@alfresco/adf-core';
|
||||
import { ShareDataRow } from '@alfresco/adf-content-services';
|
||||
@@ -31,19 +31,31 @@ import { ShareDataRow } from '@alfresco/adf-content-services';
|
||||
import { PageComponent } from '../page.component';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../../store/states/app.state';
|
||||
import { DeleteLibraryAction } from '../../store/actions';
|
||||
import { SiteEntry } from 'alfresco-js-api';
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: './libraries.component.html'
|
||||
})
|
||||
export class LibrariesComponent extends PageComponent {
|
||||
export class LibrariesComponent extends PageComponent implements OnInit {
|
||||
|
||||
constructor(private nodesApi: NodesApiService,
|
||||
private route: ActivatedRoute,
|
||||
private content: ContentManagementService,
|
||||
store: Store<AppStore>,
|
||||
private router: Router) {
|
||||
super(store);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
|
||||
this.subscriptions.push(
|
||||
this.content.siteDeleted.subscribe(() => this.reload())
|
||||
);
|
||||
}
|
||||
|
||||
makeLibraryTooltip(library: any): string {
|
||||
const { description, title } = library;
|
||||
|
||||
@@ -84,4 +96,10 @@ export class LibrariesComponent extends PageComponent {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
deleteLibrary(node: SiteEntry) {
|
||||
if (node && node.entry) {
|
||||
this.store.dispatch(new DeleteLibraryAction(node.entry.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -30,3 +30,4 @@ export * from './actions/router.actions';
|
||||
export * from './actions/viewer.actions';
|
||||
export * from './actions/search.actions';
|
||||
export * from './actions/user.actions';
|
||||
export * from './actions/library.actions';
|
||||
|
33
src/app/store/actions/library.actions.ts
Normal file
33
src/app/store/actions/library.actions.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2018 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
export const DELETE_LIBRARY = 'DELETE_LIBRARY';
|
||||
|
||||
export class DeleteLibraryAction implements Action {
|
||||
readonly type = DELETE_LIBRARY;
|
||||
constructor(public payload: string) {}
|
||||
}
|
@@ -37,7 +37,8 @@ import {
|
||||
RouterEffects,
|
||||
DownloadEffects,
|
||||
ViewerEffects,
|
||||
SearchEffects
|
||||
SearchEffects,
|
||||
SiteEffects
|
||||
} from './effects';
|
||||
|
||||
@NgModule({
|
||||
@@ -53,7 +54,8 @@ import {
|
||||
RouterEffects,
|
||||
DownloadEffects,
|
||||
ViewerEffects,
|
||||
SearchEffects
|
||||
SearchEffects,
|
||||
SiteEffects
|
||||
]),
|
||||
!environment.production
|
||||
? StoreDevtoolsModule.instrument({ maxAge: 25 })
|
||||
|
@@ -29,3 +29,4 @@ export * from './effects/router.effects';
|
||||
export * from './effects/snackbar.effects';
|
||||
export * from './effects/viewer.effects';
|
||||
export * from './effects/search.effects';
|
||||
export * from './effects/library.effects';
|
||||
|
71
src/app/store/effects/library.effects.ts
Normal file
71
src/app/store/effects/library.effects.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2018 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Effect, Actions, ofType } from '@ngrx/effects';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { DeleteLibraryAction, DELETE_LIBRARY } from '../actions';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import {
|
||||
SnackbarInfoAction,
|
||||
SnackbarErrorAction
|
||||
} from '../actions/snackbar.actions';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppStore } from '../states/app.state';
|
||||
import { ContentManagementService } from '../../common/services/content-management.service';
|
||||
|
||||
@Injectable()
|
||||
export class SiteEffects {
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private store: Store<AppStore>,
|
||||
private apiService: AlfrescoApiService,
|
||||
private content: ContentManagementService
|
||||
) {}
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
deleteLibrary$ = this.actions$.pipe(
|
||||
ofType<DeleteLibraryAction>(DELETE_LIBRARY),
|
||||
map(action => {
|
||||
this.apiService.sitesApi.deleteSite(action.payload).then(
|
||||
() => {
|
||||
this.content.siteDeleted.next(action.payload);
|
||||
this.store.dispatch(
|
||||
new SnackbarInfoAction(
|
||||
'APP.MESSAGES.INFO.LIBRARY_DELETED'
|
||||
)
|
||||
);
|
||||
},
|
||||
err => {
|
||||
this.store.dispatch(
|
||||
new SnackbarErrorAction(
|
||||
'APP.MESSAGES.ERRORS.DELETE_LIBRARY_FAILED'
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
@@ -174,7 +174,8 @@
|
||||
"LOCATION_MISSING": "Can't restore {{ name }}, the original location no longer exists",
|
||||
"GENERIC": "There was a problem restoring {{ name }}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"DELETE_LIBRARY_FAILED": "Cannot delete the library"
|
||||
},
|
||||
"UPLOAD": {
|
||||
"ERROR": {
|
||||
@@ -218,7 +219,8 @@
|
||||
"PLURAL": "Partially moved {{ partially }} items.",
|
||||
"FAIL": "{{ failed }} couldn't be moved."
|
||||
}
|
||||
}
|
||||
},
|
||||
"LIBRARY_DELETED": "Library deleted"
|
||||
}
|
||||
},
|
||||
"CONTENT_METADATA": {
|
||||
|
Reference in New Issue
Block a user