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

Admin-UI logo hook is broken #3493

Closed
dilignt opened this issue Aug 26, 2020 · 8 comments
Closed

Admin-UI logo hook is broken #3493

dilignt opened this issue Aug 26, 2020 · 8 comments

Comments

@dilignt
Copy link

dilignt commented Aug 26, 2020

Bug report

Describe the bug

Adding a logo hook to the Admin UI as described in https://www.keystonejs.com/keystonejs/app-admin-ui/#usage-1 doesn't work

To Reproduce

Follow instructions in the Admin UI App documentation page, create an index.js file in /admin-ui/ directory that exports logo pointing to a react component (just copy the existing KeystoneLogo.js component from /node_modules/@keystonejs/app-admin-ui/client/components and export that). Start the admin UI and try to sign-in but the page crashes with blank screen and the console displays

`Signin.js:139 Uncaught TypeError: getCustomLogo is not a function
at SignInPage (Signin.js:139)
at renderWithHooks (react-dom.development.js:14803)
at mountIndeterminateComponent (react-dom.development.js:17482)
at beginWork (react-dom.development.js:18596)
at HTMLUnknownElement.callCallback (react-dom.development.js:188)
at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
at invokeGuardedCallback (react-dom.development.js:292)
at beginWork$1 (react-dom.development.js:23203)
at performUnitOfWork (react-dom.development.js:22154)
at workLoopSync (react-dom.development.js:22130)

SignInPage @ Signin.js:139
renderWithHooks @ react-dom.development.js:14803
mountIndeterminateComponent @ react-dom.development.js:17482
beginWork @ react-dom.development.js:18596
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
beginWork$1 @ react-dom.development.js:23203
performUnitOfWork @ react-dom.development.js:22154
workLoopSync @ react-dom.development.js:22130
performSyncWorkOnRoot @ react-dom.development.js:21756
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
workLoop @ scheduler.development.js:597
flushWork @ scheduler.development.js:552
performWorkUntilDeadline @ scheduler.development.js:164
react-dom.development.js:19527 The above error occurred in the component:
in SignInPage (at public.js:41)
in Route (at public.js:41)
in Switch (at public.js:39)
in Router (created by BrowserRouter)
in BrowserRouter (at public.js:38)
in ToastProvider (at public.js:34)
in ApolloProvider (at public.js:33)
in HooksProvider (at public.js:32)
in Keystone (at public.js:56)
in AdminMetaProvider (at public.js:55)
in Suspense (at public.js:54)`

Expected behaviour

The signin screen should be displayed with the logo changed to the one exported in the hooks.

System information

  • OS: Windows
  • Browser: chrome
@jordanthornquest
Copy link

jordanthornquest commented Aug 27, 2020

+1, running into the same issue. Here's my file layout:

admin-ui/
  - index.js
  - logo.js
  - logo.png
lists/
node_modules/
# and so on

My index.js:

import aotLogo from "./logo";

export default {
  logo: aotLogo,
  pages: () => [
    // Ordering existing list pages
    {
      label: "Arts on Tour Data",
      children: [
        { listKey: "Season" },
        { listKey: "Event" },
        { listKey: "Artist" }
      ]
    },
    {
      label: "Media",
      children: [{ listKey: "Photo" }, { listKey: "Video" }]
    },
    {
      label: "Staff",
      children: [{ listKey: "User" }]
    }
  ]
};

My logo.js:

import React from "react";

const aotLogo = React.memo(({ ...props }) => {
  return <img alt="The Arts on Tour logo." style="display: block; width: 100%; height: auto; max-height: 220px" src="./logo.png" {...props} />;
});

export default aotLogo;

Error output in the browser console:

Signin.js:139 Uncaught TypeError: getCustomLogo is not a function
    at SignInPage (Signin.js:139)
    at renderWithHooks (react-dom.development.js:14803)
    at mountIndeterminateComponent (react-dom.development.js:17482)
    at beginWork (react-dom.development.js:18596)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at beginWork$1 (react-dom.development.js:23203)
    at performUnitOfWork (react-dom.development.js:22157)
    at workLoopSync (react-dom.development.js:22130)
SignInPage @ Signin.js:139
renderWithHooks @ react-dom.development.js:14803
mountIndeterminateComponent @ react-dom.development.js:17482
beginWork @ react-dom.development.js:18596
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
beginWork$1 @ react-dom.development.js:23203
performUnitOfWork @ react-dom.development.js:22157
workLoopSync @ react-dom.development.js:22130
performSyncWorkOnRoot @ react-dom.development.js:21756
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
workLoop @ scheduler.development.js:597
flushWork @ scheduler.development.js:552
performWorkUntilDeadline @ scheduler.development.js:164

react-dom.development.js:19527 The above error occurred in the <SignInPage> component:
    in SignInPage (at public.js:41)
    in Route (at public.js:41)
    in Switch (at public.js:39)
    in Router (created by BrowserRouter)
    in BrowserRouter (at public.js:38)
    in ToastProvider (at public.js:34)
    in ApolloProvider (at public.js:33)
    in HooksProvider (at public.js:32)
    in Keystone (at public.js:56)
    in AdminMetaProvider (at public.js:55)
    in Suspense (at public.js:54)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
logCapturedError @ react-dom.development.js:19527
logError @ react-dom.development.js:19564
update.callback @ react-dom.development.js:20708
callCallback @ react-dom.development.js:12490
commitUpdateQueue @ react-dom.development.js:12511
commitLifeCycles @ react-dom.development.js:19883
commitLayoutEffects @ react-dom.development.js:22803
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
commitRootImpl @ react-dom.development.js:22541
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
commitRoot @ react-dom.development.js:22381
finishSyncRender @ react-dom.development.js:21807
performSyncWorkOnRoot @ react-dom.development.js:21793
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
workLoop @ scheduler.development.js:597
flushWork @ scheduler.development.js:552
performWorkUntilDeadline @ scheduler.development.js:164

Signin.js:139 Uncaught TypeError: getCustomLogo is not a function
    at SignInPage (Signin.js:139)
    at renderWithHooks (react-dom.development.js:14803)
    at mountIndeterminateComponent (react-dom.development.js:17482)
    at beginWork (react-dom.development.js:18596)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at beginWork$1 (react-dom.development.js:23203)
    at performUnitOfWork (react-dom.development.js:22157)
    at workLoopSync (react-dom.development.js:22130)

This is on Chrome & MacOS.

@gautamsi
Copy link
Member

gautamsi commented Aug 28, 2020

@jordanthornquest try

logo: () => <AotLogo />, // change case for this logo component

@jordanthornquest
Copy link

Got things working, thank you for your help! Thanks to @gautamsi and some more React reading, here are my final files:

index.js:

import React from "react";
import AotLogo from "./logo";

export default {
  logo: () => <AotLogo />,
  pages: () => [
    // Ordering existing list pages
    {
      label: "Arts on Tour Data",
      children: [
        { listKey: "Season" },
        { listKey: "Event" },
        { listKey: "Artist" }
      ]
    },
    {
      label: "Media",
      children: [{ listKey: "Photo" }, { listKey: "Video" }]
    },
    {
      label: "Staff",
      children: [{ listKey: "User" }]
    }
  ]
};

logo.js:

import React from "react";
import logoImg from "./logo.png";

const AotLogo = React.memo(({ ...props }) => {
  const logoStyles = {
    display: "block",
    height: "100%",
    width: "100%",
    maxWidth: "350px"
  };

  return (
    <img
      alt="The Arts on Tour logo."
      style={logoStyles}
      src={logoImg}
      {...props}
    />
  );
});

export default AotLogo;

@dilignt
Copy link
Author

dilignt commented Sep 4, 2020

Just coming back to this now - thanks @gautamsi @jordanthornquest for sorting this out. I suppose this should now be a documentation update?

@Sylchi
Copy link

Sylchi commented Sep 11, 2020

Took me like 5 hours of pulling my hair out to get this working even with the help of this issue and code provided here. Better documentation how it works would be definately appreciated.

@wortkotze
Copy link

@jordanthornquest jordanthornquest : thx for the solution, I have some issues to load es6 modules into keystonejs. could you probably help here how you configured everything so that this works? thx

@stale
Copy link

stale bot commented Mar 19, 2021

It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :)

@stale stale bot added the needs-review label Mar 19, 2021
@bladey
Copy link
Contributor

bladey commented Apr 8, 2021

Keystone 5 has officially moved into active maintenance mode as we push towards the next major new version Keystone Next, you can find out more information about this transition here.

In an effort to sustain the project going forward, we're cleaning up and closing old issues such as this one. If you feel this issue is still relevant for Keystone Next, please let us know.

@bladey bladey closed this as completed Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants