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 as a link to an external page #121

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
18 changes: 9 additions & 9 deletions core/examples/luigi-sample-angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export class OverviewComponent {
link: '/projects/pr1/users/groups',
text: 'dynamic Nodes',
description: 'navigation Node configuration to set a specific node as dynamic'
},
{
link: 'http://google.com',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not link to an external page here. Maybe lets move the external Link from top navigation into the projects where we have also 'Default Child Node Example' and '(Isolated View)', so the features are grouped together. And link to /projects/pr1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave the external link in the top navigation to show the developer he can also put it there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think @maxmarkus ?

text: 'external URL node',
description: 'navigation Node configuration to set a specific node as dynamic'
}
];
}
81 changes: 55 additions & 26 deletions core/examples/luigi-sample-angular/src/assets/sampleconfig.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
var navigationPermissionChecker = function (nodeToCheckPermissionFor, parentNode, currentContext) {
var navigationPermissionChecker = function(
nodeToCheckPermissionFor,
parentNode,
currentContext
) {
// depending on the current path and context returns true or false
// true means the current node is accessible, false the opposite
var mockCurrentUserGroups = ['admins'];
if (nodeToCheckPermissionFor.constraints) {
// check if user has required groups
return nodeToCheckPermissionFor.constraints.filter(
function (c) {
return (
nodeToCheckPermissionFor.constraints.filter(function(c) {
return mockCurrentUserGroups.indexOf(c) !== -1;
}
).length !== 0;
}).length !== 0
);
}

return true;
};

function toTitleCase(str) {
return str.replace(/\w\S*/g, function (txt) {
return str.replace(/\w\S*/g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}

var getAllProjects = function () {
return new Promise(function (resolve) {
var getAllProjects = function() {
return new Promise(function(resolve) {
resolve([
{
id: 'pr1',
Expand All @@ -35,8 +39,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 @@ -74,8 +78,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 @@ -167,8 +171,8 @@ var projectDetailNavProviderFn = function (context) {
]
}
];
getProjectPlugins(projectId).then(function (result) {
result.forEach(function (plugin) {
getProjectPlugins(projectId).then(function(result) {
result.forEach(function(plugin) {
children.push({
category: plugin.category,
pathSegment: plugin.viewId,
Expand All @@ -182,11 +186,11 @@ var projectDetailNavProviderFn = function (context) {
});
};

var projectsNavProviderFn = function (context) {
return new Promise(function (resolve) {
getAllProjects().then(function (result) {
var projectsNavProviderFn = function(context) {
return new Promise(function(resolve) {
getAllProjects().then(function(result) {
var children = [];
result.forEach(function (project) {
result.forEach(function(project) {
children.push({
/**
* navigationContext:
Expand Down Expand Up @@ -227,7 +231,9 @@ Luigi.setConfig({
auth: {
use: 'mockAuth',
mockAuth: {
authorizeUrl: `${window.location.origin}/assets/auth-mock/login-mock.html`,
authorizeUrl: `${
window.location.origin
}/assets/auth-mock/login-mock.html`,
logoutUrl: `${window.location.origin}/assets/auth-mock/logout-mock.html`,
post_logout_redirect_uri: '/logout.html',
authorizeMethod: 'GET',
Expand All @@ -239,7 +245,7 @@ Luigi.setConfig({
authority: 'https://example-authority.com',
client_id: 'client',
scope: 'audience:server:client_id:client openid profile email groups',
logoutUrl: 'https://example-url.com/logout',
logoutUrl: 'https://example-url.com/logout'
// optional parameters
// redirect_uri: '',
// post_logout_redirect_uri: '/logout.html',
Expand Down Expand Up @@ -291,24 +297,24 @@ Luigi.setConfig({
},

events: {
onLogout: function () {
onLogout: function() {
console.log('onLogout');
},
onAuthSuccessful: function (data) {
onAuthSuccessful: function(data) {
console.log('onAuthSuccessful', data);
},
onAuthExpired: function () {
onAuthExpired: function() {
console.log('onAuthExpired');
},
// TODO: define luigi-client api for getting errors
onAuthError: function (err) {
onAuthError: function(err) {
console.log('authErrorHandler 1', err);
}
}
},
navigation: {
nodeAccessibilityResolver: navigationPermissionChecker,
nodes: function () {
nodes: function() {
return [
{
pathSegment: 'overview',
Expand Down Expand Up @@ -338,6 +344,13 @@ Luigi.setConfig({
label: 'Settings',
viewUrl: '/sampleapp.html#/settings'
},
{
label: 'Open Google in this tab',
externalLink: {
url: 'http://google.com',
sameWindow: true
}
},
{
pathSegment: 'ext',
label: 'External Page',
Expand All @@ -352,10 +365,26 @@ Luigi.setConfig({
pathSegment: 'two',
label: 'Two',
viewUrl: '/assets/sampleexternal.html#two'
},
{
label: 'Open Github in new tab',
category: 'Super useful Github links',
externalLink: {
url: 'http://github.com',
sameWindow: false
}
},
{
label: 'Open Github in this tab',
category: 'Super useful Github links',
externalLink: {
url: 'http://github.com',
sameWindow: true
}
}
]
}
]
];
}
},

Expand Down
Loading