-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
761 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
packages/phoenix-ng/projects/phoenix-app/src/app/sections/atlas/atlas.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/phoenix-ng/projects/phoenix-app/src/app/sections/cms/cms.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/phoenix-ng/projects/phoenix-app/src/app/sections/lhcb/lhcb.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
packages/phoenix-ng/projects/phoenix-app/src/assets/icons/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
packages/phoenix-ng/projects/phoenix-app/src/assets/icons/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
packages/phoenix-ng/projects/phoenix-app/src/assets/icons/server.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions
10
...ges/phoenix-ng/projects/phoenix-ui-components/lib/assets/icons/event-folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 6 additions & 8 deletions
14
packages/phoenix-ng/projects/phoenix-ui-components/lib/assets/icons/file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
packages/phoenix-ng/projects/phoenix-ui-components/lib/assets/icons/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
packages/phoenix-ng/projects/phoenix-ui-components/lib/assets/icons/server.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions
39
.../projects/phoenix-ui-components/lib/components/file-explorer/file-explorer.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<cdk-tree [dataSource]="dataSource" [treeControl]="treeControl"> | ||
<!-- This is the tree node template for leaf nodes --> | ||
<cdk-tree-node *cdkTreeNodeDef="let node" class="tree-node"> | ||
<button | ||
mat-button | ||
mat-stroked-button | ||
class="tree-node-button" | ||
(click)="onSelect(node.url)" | ||
> | ||
<svg class="node-icon"> | ||
<use href="assets/icons/file.svg#file"></use> | ||
</svg> | ||
{{ node.name }} | ||
</button> | ||
</cdk-tree-node> | ||
<!-- This is the tree node template for expandable nodes --> | ||
<cdk-nested-tree-node | ||
*cdkTreeNodeDef="let node; when: hasChildren" | ||
class="tree-node" | ||
> | ||
<button | ||
mat-button | ||
cdkTreeNodeToggle | ||
class="tree-node-button" | ||
[attr.aria-label]="'Toggle ' + node.name" | ||
> | ||
<svg | ||
class="node-icon" | ||
[class.node-icon-filled]="!treeControl.isExpanded(node)" | ||
> | ||
<use href="assets/icons/folder.svg#folder"></use> | ||
</svg> | ||
{{ node.name }} | ||
</button> | ||
<div [class.file-tree-invisible]="!treeControl.isExpanded(node)"> | ||
<ng-container cdkTreeNodeOutlet></ng-container> | ||
</div> | ||
</cdk-nested-tree-node> | ||
</cdk-tree> |
28 changes: 28 additions & 0 deletions
28
.../projects/phoenix-ui-components/lib/components/file-explorer/file-explorer.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.file-tree-invisible { | ||
display: none; | ||
} | ||
|
||
.tree-node { | ||
display: block; | ||
margin: 0.25rem 0; | ||
|
||
.tree-node { | ||
padding-left: 1rem; | ||
} | ||
} | ||
|
||
.tree-node-button { | ||
outline: none; | ||
padding: 0 0.75rem; | ||
} | ||
|
||
.node-icon { | ||
width: 1rem; | ||
height: 1rem; | ||
margin-right: 0.25rem; | ||
margin-top: -2px; | ||
|
||
&.node-icon-filled { | ||
--icon-fill: var(--phoenix-options-icon-path, #fff); | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...ojects/phoenix-ui-components/lib/components/file-explorer/file-explorer.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { CdkTreeModule } from '@angular/cdk/tree'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { FileExplorerComponent, FileNode } from './file-explorer.component'; | ||
|
||
const getMockFileNode = () => { | ||
const rootNode = new FileNode('RootNode'); | ||
const parentNode = new FileNode('ParentNode'); | ||
rootNode.children = { | ||
ParentNode: parentNode, | ||
}; | ||
parentNode.children = { | ||
TestChild1: new FileNode('TestChild1'), | ||
TestChild2: new FileNode('TestChild2'), | ||
}; | ||
|
||
return rootNode; | ||
}; | ||
|
||
describe('FileExplorerComponent', () => { | ||
let component: FileExplorerComponent; | ||
let fixture: ComponentFixture<FileExplorerComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [FileExplorerComponent], | ||
imports: [CdkTreeModule], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(FileExplorerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should update dataSource on changes in input', () => { | ||
const mockFileNode = getMockFileNode(); | ||
const sortedChildren = component.getSortedChildren(mockFileNode); | ||
|
||
expect(component.dataSource.data.length).toBe(0); | ||
component.ngOnChanges({ | ||
rootFileNode: { | ||
currentValue: mockFileNode, | ||
previousValue: undefined, | ||
firstChange: undefined, | ||
isFirstChange: () => true, | ||
}, | ||
}); | ||
|
||
expect(component.dataSource.data).toEqual(sortedChildren); | ||
}); | ||
|
||
it('should emit onFileSelect event on selection of file', () => { | ||
spyOn(component.onFileSelect, 'emit'); | ||
component.onSelect('http://example.com/file.json'); | ||
expect(component.onFileSelect.emit).toHaveBeenCalledWith( | ||
'http://example.com/file.json' | ||
); | ||
}); | ||
|
||
it('checks if node has children', () => { | ||
const testNode = new FileNode('TestNode'); | ||
expect(component.hasChildren(0, testNode)).toBeFalse(); | ||
|
||
testNode.children = { TestChild: new FileNode() }; | ||
expect(component.hasChildren(0, testNode)).toBeTrue(); | ||
}); | ||
}); |
Oops, something went wrong.