diff --git a/cspell.json b/cspell.json
index bd0cb40a9..4da72da4a 100644
--- a/cspell.json
+++ b/cspell.json
@@ -34,6 +34,7 @@
"SOLR",
"unshare",
+ "qshare",
"validators",
"guid",
"polyfill",
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index dacb1bedd..50ebf8b0d 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -54,6 +54,7 @@ import { DirectivesModule } from './directives/directives.module';
import { ContextMenuModule } from './components/context-menu/context-menu.module';
import { ExtensionsModule } from '@alfresco/adf-extensions';
import { AppToolbarModule } from './components/toolbar/toolbar.module';
+import { AppSharedModule } from './components/shared/shared.module';
import { AppCreateMenuModule } from './components/create-menu/create-menu.module';
import { AppSidenavModule } from './components/sidenav/sidenav.module';
import { AppPermissionsModule } from './components/permissions/permissions.module';
@@ -90,6 +91,7 @@ import { AppHeaderModule } from './components/header/header.module';
ContextMenuModule,
AppInfoDrawerModule,
AppToolbarModule,
+ AppSharedModule,
AppSidenavModule,
AppCreateMenuModule,
AppPermissionsModule,
diff --git a/src/app/components/shared/shared.module.ts b/src/app/components/shared/shared.module.ts
new file mode 100644
index 000000000..82aeb3876
--- /dev/null
+++ b/src/app/components/shared/shared.module.ts
@@ -0,0 +1,42 @@
+/*!
+ * @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 .
+ */
+
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { CoreModule } from '@alfresco/adf-core';
+import { ContentNodeShareModule } from '@alfresco/adf-content-services';
+import { ExtensionsModule } from '@alfresco/adf-extensions';
+import { ToggleSharedModule } from './toggle-shared/toggle-shared.module';
+
+@NgModule({
+ imports: [
+ CommonModule,
+ CoreModule.forChild(),
+ ExtensionsModule,
+ ContentNodeShareModule,
+ ToggleSharedModule
+ ]
+})
+export class AppSharedModule {}
diff --git a/src/app/components/shared/toggle-shared/toggle-shared.component.html b/src/app/components/shared/toggle-shared/toggle-shared.component.html
new file mode 100644
index 000000000..8cdce6e41
--- /dev/null
+++ b/src/app/components/shared/toggle-shared/toggle-shared.component.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+ {{ 'APP.ACTIONS.SHARE' | translate }}
+
\ No newline at end of file
diff --git a/src/app/components/shared/toggle-shared/toggle-shared.component.spec.ts b/src/app/components/shared/toggle-shared/toggle-shared.component.spec.ts
new file mode 100644
index 000000000..2a9b4063b
--- /dev/null
+++ b/src/app/components/shared/toggle-shared/toggle-shared.component.spec.ts
@@ -0,0 +1,75 @@
+/*!
+ * @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 .
+ */
+
+import { ToggleSharedComponent } from './toggle-shared.component';
+import { of } from 'rxjs';
+
+describe('ToggleSharedComponent', () => {
+ let component;
+ let entry;
+
+ const storeMock = {
+ select: () => of({ first: { entry } }),
+ dispatch: jasmine.createSpy('dispatch')
+ };
+
+ beforeEach(() => {
+ entry = {
+ properties: {
+ 'qshare:sharedId': null
+ }
+ };
+
+ component = new ToggleSharedComponent(storeMock);
+ });
+
+ it('should get Store selection entry on initialization', done => {
+ component.ngOnInit();
+
+ component.selection$.subscribe(selection => {
+ expect(selection.first.entry).toEqual(entry);
+ done();
+ });
+ });
+
+ it('should return false when entry is not shared', () => {
+ component.ngOnInit();
+
+ expect(component.isShared({ first: { entry } })).toBe(false);
+ });
+
+ it('should return true when entry is shared', () => {
+ entry.properties['qshare:sharedId'] = 'some-id';
+ component.ngOnInit();
+
+ expect(component.isShared({ first: { entry } })).toBe(true);
+ });
+
+ it('should dispatch `SHARE_NODE` action on share', () => {
+ component.ngOnInit();
+ component.editSharedNode({ first: { entry } });
+ expect(storeMock.dispatch).toHaveBeenCalled();
+ });
+});
diff --git a/src/app/components/shared/toggle-shared/toggle-shared.component.ts b/src/app/components/shared/toggle-shared/toggle-shared.component.ts
new file mode 100644
index 000000000..3847c3a87
--- /dev/null
+++ b/src/app/components/shared/toggle-shared/toggle-shared.component.ts
@@ -0,0 +1,58 @@
+/*!
+ * @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 .
+ */
+
+import { Component, OnInit } from '@angular/core';
+import { Observable } from 'rxjs';
+import { Store } from '@ngrx/store';
+import { AppStore } from '../../../store/states/app.state';
+import { appSelection } from '../../../store/selectors/app.selectors';
+import { SelectionState } from '@alfresco/adf-extensions';
+import { ShareNodeAction } from '../../../store/actions';
+
+@Component({
+ selector: 'app-toggle-shared',
+ templateUrl: './toggle-shared.component.html'
+})
+export class ToggleSharedComponent implements OnInit {
+ selection$: Observable;
+
+ constructor(private store: Store) {}
+
+ ngOnInit() {
+ this.selection$ = this.store.select(appSelection);
+ }
+
+ isShared(selection) {
+ return (
+ selection.first.entry &&
+ selection.first.entry.properties &&
+ !!selection.first.entry.properties['qshare:sharedId']
+ );
+ }
+
+ editSharedNode(selection) {
+ this.store.dispatch(new ShareNodeAction(selection.first));
+ }
+}
diff --git a/src/app/components/shared/toggle-shared/toggle-shared.module.ts b/src/app/components/shared/toggle-shared/toggle-shared.module.ts
new file mode 100644
index 000000000..fd8fc4d01
--- /dev/null
+++ b/src/app/components/shared/toggle-shared/toggle-shared.module.ts
@@ -0,0 +1,48 @@
+/*!
+ * @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 .
+ */
+
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { CoreModule } from '@alfresco/adf-core';
+import { ContentNodeShareModule } from '@alfresco/adf-content-services';
+import { ExtensionsModule } from '@alfresco/adf-extensions';
+import { ToggleSharedComponent } from './toggle-shared.component';
+
+export function components() {
+ return [ToggleSharedComponent];
+}
+
+@NgModule({
+ imports: [
+ CommonModule,
+ CoreModule.forChild(),
+ ExtensionsModule,
+ ContentNodeShareModule
+ ],
+ declarations: components(),
+ exports: components(),
+ entryComponents: components()
+})
+export class ToggleSharedModule {}
diff --git a/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts b/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts
index 716c1065b..75191a3e4 100644
--- a/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts
+++ b/src/app/components/toolbar/toolbar-action/toolbar-action.component.ts
@@ -27,7 +27,9 @@ import {
Component,
ViewEncapsulation,
ChangeDetectionStrategy,
- Input
+ Input,
+ DoCheck,
+ ChangeDetectorRef
} from '@angular/core';
import { ContentActionRef } from '@alfresco/adf-extensions';
@@ -38,7 +40,7 @@ import { ContentActionRef } from '@alfresco/adf-extensions';
changeDetection: ChangeDetectionStrategy.OnPush,
host: { class: 'aca-toolbar-action' }
})
-export class ToolbarActionComponent {
+export class ToolbarActionComponent implements DoCheck {
@Input()
type = 'icon-button';
@@ -47,4 +49,14 @@ export class ToolbarActionComponent {
@Input()
actionRef: ContentActionRef;
+
+ constructor(private cd: ChangeDetectorRef) {}
+
+ // todo: review after ADF 2.6
+ // preview component : change detection workaround for children without input
+ ngDoCheck() {
+ if (this.actionRef.id.includes('app.viewer')) {
+ this.cd.markForCheck();
+ }
+ }
}
diff --git a/src/app/extensions/core.extensions.module.ts b/src/app/extensions/core.extensions.module.ts
index 76e01d4b1..892bca72e 100644
--- a/src/app/extensions/core.extensions.module.ts
+++ b/src/app/extensions/core.extensions.module.ts
@@ -33,6 +33,7 @@ import * as nav from './evaluators/navigation.evaluators';
import { AppExtensionService } from './extension.service';
import { ToggleInfoDrawerComponent } from '../components/toolbar/toggle-info-drawer/toggle-info-drawer.component';
import { ToggleFavoriteComponent } from '../components/toolbar/toggle-favorite/toggle-favorite.component';
+import { ToggleSharedComponent } from '../components/shared/toggle-shared/toggle-shared.component';
import { MetadataTabComponent } from '../components/info-drawer/metadata-tab/metadata-tab.component';
import { CommentsTabComponent } from '../components/info-drawer/comments-tab/comments-tab.component';
import { VersionsTabComponent } from '../components/info-drawer/versions-tab/versions-tab.component';
@@ -75,7 +76,8 @@ export class CoreExtensionsModule {
'app.components.tabs.comments': CommentsTabComponent,
'app.components.tabs.versions': VersionsTabComponent,
'app.toolbar.toggleInfoDrawer': ToggleInfoDrawerComponent,
- 'app.toolbar.toggleFavorite': ToggleFavoriteComponent
+ 'app.toolbar.toggleFavorite': ToggleFavoriteComponent,
+ 'app.shared-link.toggleSharedLink': ToggleSharedComponent
});
extensions.setAuthGuards({
diff --git a/src/assets/app.extensions.json b/src/assets/app.extensions.json
index 5a85ece58..8082ad3d2 100644
--- a/src/assets/app.extensions.json
+++ b/src/assets/app.extensions.json
@@ -420,28 +420,13 @@
},
{
"id": "app.toolbar.share",
+ "type": "custom",
"order": 600,
- "title": "APP.ACTIONS.SHARE",
- "icon": "share",
- "actions": {
- "click": "SHARE_NODE"
- },
+ "component": "app.shared-link.toggleSharedLink",
"rules": {
"visible": "app.selection.file.canShare"
}
},
- {
- "id": "app.toolbar.unshare",
- "order": 700,
- "title": "APP.ACTIONS.UNSHARE",
- "icon": "stop_screen_share",
- "actions": {
- "click": "UNSHARE_NODES"
- },
- "rules": {
- "visible": "app.selection.canUnshare"
- }
- },
{
"id": "app.toolbar.delete",
"order": 800,
@@ -532,12 +517,9 @@
},
{
"id": "app.context.menu.share",
- "title": "APP.ACTIONS.SHARE",
+ "type": "custom",
"order": 400,
- "icon": "share",
- "actions": {
- "click": "SHARE_NODE"
- },
+ "component": "app.shared-link.toggleSharedLink",
"rules": {
"visible": "app.selection.file.canShare"
}
@@ -749,12 +731,9 @@
},
{
"id": "app.viewer.share",
+ "type": "custom",
"order": 300,
- "title": "APP.ACTIONS.SHARE",
- "icon": "share",
- "actions": {
- "click": "SHARE_NODE"
- },
+ "component": "app.shared-link.toggleSharedLink",
"rules": {
"visible": "app.selection.file.canShare"
}
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index 7f12b2bf6..561703d7e 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -131,6 +131,7 @@
"VERSIONS": "Manage Versions",
"TOGGLE-SIDENAV": "Toggle side navigation bar",
"SHARE": "Share",
+ "CONTEXT_EDIT_SHARE": "Shared link settings",
"PRINT": "Print",
"FULLSCREEN": "Activate full-screen mode"
},