keystonejs / keystone-classic

Node.js CMS and web app framework
http://v4.keystonejs.com
MIT License
14.63k stars 2.21k forks source link

Admin UI@Keystone 4.0.0: External link is not triggered #4688

Open yazevedopure opened 6 years ago

yazevedopure commented 6 years ago

Expected behavior

Clicking on an external link in Admin UI that link should be triggered

Actual/Current behavior

The link is shown, but nothing happens clicking on it

Steps to reproduce the actual/current behavior

Workaround

I've been able to solve the problem changing few lines in /keystone/admin/client/App/components/Navigation/Primary/index.js starting from line 92 (renderNavigation function)

return this.props.sections.map((section) => {
    // Get the link and the class name
    const href = section.lists[0].external ? section.lists[0].path : `${Keystone.adminPath}/${section.lists[0].path}`;
    const to = section.lists[0].external ? null : `${Keystone.adminPath}/${section.lists[0].path}`; // <- ADDED
    const isActive = this.props.currentSectionKey && this.props.currentSectionKey === section.key;
    const className = isActive ? 'primary-navbar__item--active' : null;

    return (
        <PrimaryNavItem
            active={isActive}
            key={section.key}
            label={section.label}
            className={className}
            to={to}
            href={href} // <- ADDED
        >
            {section.label}
        </PrimaryNavItem>
    );
});

The same problem, but slightily different, is present in /keystone/admin/client/App/components/Navigation/Secondary/NavItem.js In that case the onClick event should be removed if the link is external or modified in order to allow the default action (but I didn't tried that)

Since these links are external I'd suggest the use of target="_blank".

Environment

Software Version
Keystone 4.0.0-beta.5
Node.js 8.9.4
Browser Chrome
DaTebe commented 6 years ago

Hi, external links do not work in my case. What should be the expected outcome of an external link? I expect a link in the navbar.

In my case also a new entry (like any other model) is created in the admin interface:

bug

Is there something I did wrong? Also the need of an array of objects is not in the current documentation.

opposite-bracket commented 5 years ago

What's the resolution for this? We could also use this fix @stennie