[ACA-1432] unified selection and single info drawer (#385)

* track document list selection state

* selection management enhancements

* (fix) hide info drawer on selection reset

* use store selection

* remove event handler

* upgrade info drawer for personal files

* upgrade favorties

* upgrade recent files

* move info drawer to a separate component

* test fixes

* update tests

* test fixes

* remove obsolete directive

* use last selection entry

* switch back to first selected node

* selection improvements, versioning uses same node

* optimised toolbar visibility evaluation

* upgrade libs

* update js api

* test fixes

* test fixes

* test updates

* test fixes

* fix e2e tests

* show metadata for last clicked node
This commit is contained in:
Denys Vuika
2018-06-06 12:44:13 +01:00
committed by GitHub
parent a67dd43ad6
commit f0c0fe162b
39 changed files with 512 additions and 671 deletions

View File

@@ -24,17 +24,22 @@
*/
import { PageComponent } from './page.component';
import { MinimalNodeEntity } from 'alfresco-js-api';
class TestClass extends PageComponent {
node: any;
setSelection(selection: MinimalNodeEntity[] = []) {
this.onSelectionChanged(selection);
}
constructor() {
super(null, null);
super(null, null, null, null);
}
}
describe('PageComponent', () => {
let component;
let component: TestClass;
beforeEach(() => {
component = new TestClass();
@@ -56,47 +61,44 @@ describe('PageComponent', () => {
describe('hasSelection()', () => {
it('returns true when it has nodes selected', () => {
const hasSelection = component.hasSelection([ {}, {} ]);
expect(hasSelection).toBe(true);
component.setSelection([
{ entry: { isFile: true } },
{ entry: { isFile: true } }
]);
expect(component.hasSelection).toBe(true);
});
it('returns false when it has no selections', () => {
const hasSelection = component.hasSelection([]);
expect(hasSelection).toBe(false);
component.setSelection([]);
expect(component.hasSelection).toBe(false);
});
});
describe('isFileSelected()', () => {
describe('firstSelectedDocument', () => {
it('returns true if selected node is file', () => {
const selection = [ { entry: { isFile: true } } ];
expect(component.isFileSelected(selection)).toBe(true);
component.setSelection(selection);
expect(component.firstSelectedDocument).toBe(selection[0]);
});
it('returns false if selected node is folder', () => {
const selection = [ { entry: { isFolder: true } } ];
expect(component.isFileSelected(selection)).toBe(false);
});
it('returns false if there are more than one selections', () => {
const selection = [ { entry: { isFile: true } }, { entry: { isFile: true } } ];
expect(component.isFileSelected(selection)).toBe(false);
const selection = [ { entry: { isFile: false, isFolder: true } } ];
component.setSelection(selection);
expect(component.firstSelectedDocument).toBeFalsy();
});
});
describe('isFolderSelected()', () => {
describe('firstSelectedFolder', () => {
it('returns true if selected node is folder', () => {
const selection = [ { entry: { isFolder: true } } ];
expect(component.isFolderSelected(selection)).toBe(true);
const selection = [ { entry: { isFile: false, isFolder: true } } ];
component.setSelection(selection);
expect(component.firstSelectedFolder).toBe(selection[0]);
});
it('returns false if selected node is file', () => {
const selection = [ { entry: { isFile: true } } ];
expect(component.isFolderSelected(selection)).toBe(false);
});
it('returns false if there are more than one selections', () => {
const selection = [ { entry: { isFolder: true } }, { entry: { isFolder: true } } ];
expect(component.isFolderSelected(selection)).toBe(false);
const selection = [ { entry: { isFile: true, isFolder: false } } ];
component.setSelection(selection);
expect(component.firstSelectedFolder).toBeFalsy();
});
});
});