mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1607][ACA-1985] Leave library action (#824)
* [ACA-1607] leave library action * [ACA-1607] confirm leave action * [ACA-1607] confirm leave action * [ACA-1607] remove comment
This commit is contained in:
committed by
Denys Vuika
parent
62e33efbd0
commit
13db4fb339
@@ -63,6 +63,7 @@ export class FavoriteLibrariesComponent extends PageComponent
|
||||
this.content.libraryDeleted.subscribe(() => this.reloadList()),
|
||||
this.content.libraryUpdated.subscribe(() => this.reloadList()),
|
||||
this.content.libraryJoined.subscribe(() => this.reloadList()),
|
||||
this.content.libraryLeft.subscribe(() => this.reloadList()),
|
||||
this.content.favoriteLibraryToggle.subscribe(() => this.reloadList()),
|
||||
|
||||
this.breakpointObserver
|
||||
|
@@ -56,6 +56,7 @@ export class LibrariesComponent extends PageComponent implements OnInit {
|
||||
this.subscriptions.push(
|
||||
this.content.libraryDeleted.subscribe(() => this.reload()),
|
||||
this.content.libraryUpdated.subscribe(() => this.reload()),
|
||||
this.content.libraryLeft.subscribe(() => this.reload()),
|
||||
|
||||
this.breakpointObserver
|
||||
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
||||
|
@@ -79,6 +79,9 @@ export class SearchLibrariesResultsComponent extends PageComponent
|
||||
this.content.libraryDeleted.subscribe(() =>
|
||||
this.librariesQueryBuilder.update()
|
||||
),
|
||||
this.content.libraryLeft.subscribe(() =>
|
||||
this.librariesQueryBuilder.update()
|
||||
),
|
||||
|
||||
this.librariesQueryBuilder.updated.subscribe(() => {
|
||||
this.isLoading = true;
|
||||
|
@@ -220,6 +220,10 @@ export class ContentApiService {
|
||||
return from(this.api.sitesApi.deleteSite(siteId, opts));
|
||||
}
|
||||
|
||||
leaveSite(siteId?: string): Observable<any> {
|
||||
return from(this.api.sitesApi.removeSiteMember(siteId, '-me-'));
|
||||
}
|
||||
|
||||
createSite(
|
||||
siteBody: SiteBody,
|
||||
opts?: {
|
||||
|
@@ -83,6 +83,7 @@ export class ContentManagementService {
|
||||
libraryCreated = new Subject<SiteEntry>();
|
||||
libraryUpdated = new Subject<SiteEntry>();
|
||||
libraryJoined = new Subject<string>();
|
||||
libraryLeft = new Subject<string>();
|
||||
library400Error = new Subject<any>();
|
||||
joinLibraryToggle = new Subject<string>();
|
||||
linksUnshared = new Subject<any>();
|
||||
@@ -301,6 +302,38 @@ export class ContentManagementService {
|
||||
);
|
||||
}
|
||||
|
||||
leaveLibrary(siteId: string): void {
|
||||
const dialogRef = this.dialogRef.open(ConfirmDialogComponent, {
|
||||
data: {
|
||||
title: 'APP.DIALOGS.CONFIRM_LEAVE.TITLE',
|
||||
message: 'APP.DIALOGS.CONFIRM_LEAVE.MESSAGE',
|
||||
yesLabel: 'APP.DIALOGS.CONFIRM_LEAVE.YES_LABEL',
|
||||
noLabel: 'APP.DIALOGS.CONFIRM_LEAVE.NO_LABEL'
|
||||
},
|
||||
minWidth: '250px'
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if (result === true) {
|
||||
this.contentApi.leaveSite(siteId).subscribe(
|
||||
() => {
|
||||
this.libraryLeft.next(siteId);
|
||||
this.store.dispatch(
|
||||
new SnackbarInfoAction('APP.MESSAGES.INFO.LEFT_LIBRARY')
|
||||
);
|
||||
},
|
||||
() => {
|
||||
this.store.dispatch(
|
||||
new SnackbarErrorAction(
|
||||
'APP.MESSAGES.ERRORS.LEAVE_LIBRARY_FAILED'
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateLibrary(siteId: string, siteBody: SiteBody) {
|
||||
this.contentApi.updateLibrary(siteId, siteBody).subscribe(
|
||||
(siteEntry: SiteEntry) => {
|
||||
|
@@ -30,6 +30,7 @@ export const DELETE_LIBRARY = 'DELETE_LIBRARY';
|
||||
export const CREATE_LIBRARY = 'CREATE_LIBRARY';
|
||||
export const NAVIGATE_LIBRARY = 'NAVIGATE_LIBRARY';
|
||||
export const UPDATE_LIBRARY = 'UPDATE_LIBRARY';
|
||||
export const LEAVE_LIBRARY = 'LEAVE_LIBRARY';
|
||||
|
||||
export class DeleteLibraryAction implements Action {
|
||||
readonly type = DELETE_LIBRARY;
|
||||
@@ -50,3 +51,8 @@ export class UpdateLibraryAction implements Action {
|
||||
readonly type = UPDATE_LIBRARY;
|
||||
constructor(public payload?: SiteBody) {}
|
||||
}
|
||||
|
||||
export class LeaveLibraryAction implements Action {
|
||||
readonly type = LEAVE_LIBRARY;
|
||||
constructor(public payload?: string) {}
|
||||
}
|
||||
|
@@ -34,7 +34,9 @@ import {
|
||||
NavigateLibraryAction,
|
||||
NAVIGATE_LIBRARY,
|
||||
UpdateLibraryAction,
|
||||
UPDATE_LIBRARY
|
||||
UPDATE_LIBRARY,
|
||||
LeaveLibraryAction,
|
||||
LEAVE_LIBRARY
|
||||
} from '../actions';
|
||||
import { ContentManagementService } from '../../services/content-management.service';
|
||||
import { Store } from '@ngrx/store';
|
||||
@@ -73,6 +75,25 @@ export class LibraryEffects {
|
||||
})
|
||||
);
|
||||
|
||||
@Effect({ dispatch: false })
|
||||
leaveLibrary$ = this.actions$.pipe(
|
||||
ofType<LeaveLibraryAction>(LEAVE_LIBRARY),
|
||||
map(action => {
|
||||
if (action.payload) {
|
||||
this.content.leaveLibrary(action.payload);
|
||||
} else {
|
||||
this.store
|
||||
.select(appSelection)
|
||||
.pipe(take(1))
|
||||
.subscribe(selection => {
|
||||
if (selection && selection.library) {
|
||||
this.content.leaveLibrary(selection.library.entry.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@Effect()
|
||||
createLibrary$ = this.actions$.pipe(
|
||||
ofType<CreateLibraryAction>(CREATE_LIBRARY),
|
||||
|
@@ -122,6 +122,14 @@
|
||||
{ "type": "rule", "value": "app.selection.hasNoLibraryRole" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "app.libraries.toolbar.canLeaveLibrary",
|
||||
"type": "core.every",
|
||||
"parameters": [
|
||||
{ "type": "rule", "value": "app.selection.library" },
|
||||
{ "type": "rule", "value": "app.selection.hasLibraryRole" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "app.toolbar.canCopyNode",
|
||||
"type": "core.every",
|
||||
@@ -417,6 +425,18 @@
|
||||
"visible": "app.libraries.toolbar.canToggleJoin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "app.toolbar.leaveLibrary",
|
||||
"order": 705,
|
||||
"title": "APP.ACTIONS.LEAVE",
|
||||
"icon": "not_interested",
|
||||
"actions": {
|
||||
"click": "LEAVE_LIBRARY"
|
||||
},
|
||||
"rules": {
|
||||
"visible": "app.libraries.toolbar.canLeaveLibrary"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "app.toolbar.more",
|
||||
"type": "menu",
|
||||
@@ -649,6 +669,18 @@
|
||||
"visible": "app.libraries.toolbar.canToggleJoin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "app.context.leaveLibrary",
|
||||
"order": 703,
|
||||
"title": "APP.ACTIONS.LEAVE",
|
||||
"icon": "not_interested",
|
||||
"actions": {
|
||||
"click": "LEAVE_LIBRARY"
|
||||
},
|
||||
"rules": {
|
||||
"visible": "app.libraries.toolbar.canLeaveLibrary"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "app.context.menu.copy",
|
||||
"title": "APP.ACTIONS.COPY",
|
||||
|
@@ -200,7 +200,8 @@
|
||||
"PRINT": "Print",
|
||||
"FULLSCREEN": "Activate full-screen mode",
|
||||
"JOIN": "Join",
|
||||
"CANCEL_JOIN": "Cancel join"
|
||||
"CANCEL_JOIN": "Cancel join",
|
||||
"LEAVE": "Leave library"
|
||||
},
|
||||
"DIALOGS": {
|
||||
"CONFIRM_PURGE": {
|
||||
@@ -208,6 +209,12 @@
|
||||
"MESSAGE": "This will permanently remove the selected item(s).",
|
||||
"YES_LABEL": "Delete",
|
||||
"NO_LABEL": "Keep"
|
||||
},
|
||||
"CONFIRM_LEAVE": {
|
||||
"TITLE": "Leave this library?",
|
||||
"MESSAGE": "This will remove you as a member of this library.",
|
||||
"YES_LABEL": "OK",
|
||||
"NO_LABEL": "Cancel"
|
||||
}
|
||||
},
|
||||
"DOCUMENT_LIST": {
|
||||
@@ -267,7 +274,8 @@
|
||||
},
|
||||
"DELETE_LIBRARY_FAILED": "Cannot delete the library",
|
||||
"JOIN_REQUEST_FAILED": "Cannot join the library",
|
||||
"JOIN_CANCEL_FAILED": "Cannot cancel the request to join the library"
|
||||
"JOIN_CANCEL_FAILED": "Cannot cancel the request to join the library",
|
||||
"LEAVE_LIBRARY_FAILED": "Cannot leave this library"
|
||||
},
|
||||
"UPLOAD": {
|
||||
"ERROR": {
|
||||
@@ -315,7 +323,8 @@
|
||||
"LIBRARY_DELETED": "Library deleted",
|
||||
"JOINED": "Library joined",
|
||||
"JOIN_REQUESTED": "Join library request sent",
|
||||
"JOIN_CANCELED": "Canceled the request to join the library"
|
||||
"JOIN_CANCELED": "Canceled the request to join the library",
|
||||
"LEFT_LIBRARY": "You have left the library"
|
||||
}
|
||||
},
|
||||
"CONTENT_METADATA": {
|
||||
|
Reference in New Issue
Block a user