Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation Node visibility with custom nodeAccessibilityResolver #67

Merged
merged 24 commits into from
Sep 12, 2018
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
41bb5f8
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Jul 31, 2018
4349a3e
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 1, 2018
7cafa4b
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 7, 2018
f8a6a28
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 8, 2018
0ab8b3a
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 8, 2018
9e4e1f0
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 14, 2018
0d886e5
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 22, 2018
c0edce7
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 28, 2018
21fa6a4
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 30, 2018
63c3a61
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Aug 31, 2018
c0d06bc
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 4, 2018
282ddcc
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 5, 2018
7623ae3
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 6, 2018
0e95296
added sample navigationPermissionChecker and added functionality to n…
maxmarkus Sep 7, 2018
7029cbc
implemented nodeAccessibilityResolver for permission checking, added …
maxmarkus Sep 10, 2018
80b1988
renamed sample variable, bugfix for root node, added documentation
maxmarkus Sep 10, 2018
db5803f
Merge branch 'master' of github.com:kyma-project/luigi
maxmarkus Sep 10, 2018
b9bd141
Merge branch 'master' into feature/visibility-restriction-base
maxmarkus Sep 10, 2018
b7990ed
fixed non-working root-level check, added component for restricted view
maxmarkus Sep 11, 2018
8b9b731
aligned function inputs, more es5 for sample config
maxmarkus Sep 12, 2018
9de4b40
Merge branch 'master' into feature/visibility-restriction-base
maxmarkus Sep 12, 2018
6a6554b
const to var for ES5
maxmarkus Sep 12, 2018
4b1dd4a
documentation improvements
maxmarkus Sep 12, 2018
1e738cd
Merge branch 'feature/visibility-restriction-base' of github.com:maxm…
maxmarkus Sep 12, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { Miscellaneous2Component } from './project/miscellaneous2/miscellaneous2
import { ChildNode2Component } from './project/default-child/dps2/child-node-2.component';
import { ChildNode1Component } from './project/default-child/dps1/child-node-1.component';
import { OverviewComponent } from './overview/overview.component';
import { RestrictedComponent } from './restricted/restricted.component';

const routes: Routes = [
{ path: 'overview', component: OverviewComponent },
{ path: 'restricted', component: RestrictedComponent },
{ path: 'projects/:projectId', component: ProjectComponent },
{ path: 'projects/:projectId/users', component: UsersComponent },
{
Expand Down
4 changes: 3 additions & 1 deletion core/examples/luigi-sample-angular/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { CodeSnippetComponent } from './project/code-snippet/code-snippet.compon
import { ChildNode1Component } from './project/default-child/dps1/child-node-1.component';
import { ChildNode2Component } from './project/default-child/dps2/child-node-2.component';
import { OverviewComponent } from './overview/overview.component';
import { RestrictedComponent } from './restricted/restricted.component';

@NgModule({
declarations: [
Expand All @@ -39,7 +40,8 @@ import { OverviewComponent } from './overview/overview.component';
CodeSnippetComponent,
ChildNode1Component,
ChildNode2Component,
OverviewComponent
OverviewComponent,
RestrictedComponent
],
imports: [BrowserModule, FormsModule, AppRoutingModule],
providers: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<header class="fd-page__header">
<div class="fd-action-bar">
<div class="fd-action-bar__header">
<h1 class="fd-action-bar__title">
Restricted Area
</h1>
<p class="fd-action-bar__description">This page is visible to you.</p>
</div>
</div>
</header>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { RestrictedComponent } from './restricted.component';

describe('RestrictedComponent', () => {
let component: RestrictedComponent;
let fixture: ComponentFixture<RestrictedComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RestrictedComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(RestrictedComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-restricted',
templateUrl: './restricted.component.html',
styleUrls: ['./restricted.component.css']
})
export class RestrictedComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
40 changes: 32 additions & 8 deletions core/examples/luigi-sample-angular/src/assets/sampleconfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
var getAllProjects = function() {
return new Promise(function(resolve) {
var navigationPermissionChecker = function (nodeToCheckPermissionFor, parentNode, currentContext) {
maxmarkus marked this conversation as resolved.
Show resolved Hide resolved
// depending on the current path and context returns true or false
// true means the current node is accessible, false the opposite
const mockCurrentUserGroups = ['admins'];
if (nodeToCheckPermissionFor.constraints) {
// check if user has required groups
return nodeToCheckPermissionFor.constraints.filter(
function (c) {
return mockCurrentUserGroups.indexOf(c) !== -1;
maxmarkus marked this conversation as resolved.
Show resolved Hide resolved
}
).length !== 0;
}

return true;
};

var getAllProjects = function () {
return new Promise(function (resolve) {
resolve([
{
id: 'pr1',
Expand All @@ -13,8 +29,8 @@ var getAllProjects = function() {
});
};

var getProjectPlugins = function(projectId) {
return new Promise(function(resolve) {
var getProjectPlugins = function (projectId) {
return new Promise(function (resolve) {
if (projectId === 'pr2') {
resolve([
{
Expand Down Expand Up @@ -52,8 +68,8 @@ var getProjectPlugins = function(projectId) {
});
};

var projectDetailNavProviderFn = function(context) {
return new Promise(function(resolve) {
var projectDetailNavProviderFn = function (context) {
return new Promise(function (resolve) {
var projectId = context.currentProject;
var children = [
{
Expand Down Expand Up @@ -108,6 +124,7 @@ var projectDetailNavProviderFn = function(context) {
},
{
pathSegment: 'miscellaneous',
constraints: ['unicorns'],
label: 'Miscellaneous',
viewUrl: '/sampleapp.html#/projects/' + projectId + '/miscellaneous'
},
Expand Down Expand Up @@ -155,8 +172,8 @@ var projectDetailNavProviderFn = function(context) {
});
};

var projectsNavProviderFn = function(context) {
return new Promise(function(resolve) {
var projectsNavProviderFn = function (context) {
return new Promise(function (resolve) {
getAllProjects().then(result => {
var children = [];
result.forEach(project => {
Expand Down Expand Up @@ -270,6 +287,7 @@ Luigi.setConfig({
}
},
navigation: {
nodeAccessibilityResolver: navigationPermissionChecker,
nodes: () => [
{
pathSegment: 'overview',
Expand All @@ -288,6 +306,12 @@ Luigi.setConfig({
label: 'Hidden',
viewUrl: '/sampleapp.html#/projects/overview'
},
{
pathSegment: 'forbidden-sample',
label: 'Forbidden',
viewUrl: '/sampleapp.html#/restricted',
constraints: ['unicorns']
},
{
pathSegment: 'ext',
label: 'External Page',
Expand Down
Loading