muffin-admin 9.4.1 → 9.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "9.4.1",
3
+ "version": "9.4.2",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -13,8 +13,10 @@ import {
13
13
  LayoutProps,
14
14
  localStorageStore,
15
15
  Login,
16
+ LoginProps,
16
17
  } from "react-admin"
17
18
 
19
+ import { useEffect } from "react"
18
20
  import { ConfirmationProvider } from "./common"
19
21
  import { useMuffinAdminOpts } from "./hooks"
20
22
  import { buildProvider, muffinTranslations } from "./i18n"
@@ -28,11 +30,11 @@ export function MuffinAdmin(props: AdminProps) {
28
30
  const muffinI18nProvider = buildProvider(
29
31
  backendLocales
30
32
  ? Object.fromEntries(
31
- Object.entries(muffinTranslations).map(([locale, messages]) => [
32
- locale,
33
- deepMerge({}, messages, backendLocales[locale], buildAdmin(["locale", locale]) || {}),
34
- ])
35
- )
33
+ Object.entries(muffinTranslations).map(([locale, messages]) => [
34
+ locale,
35
+ deepMerge({}, messages, backendLocales[locale], buildAdmin(["locale", locale]) || {}),
36
+ ])
37
+ )
36
38
  : muffinTranslations
37
39
  )
38
40
 
@@ -132,5 +134,20 @@ export function MuffinAppBar(props: AppBarProps) {
132
134
 
133
135
  setupAdmin(["appbar"], MuffinAppBar)
134
136
 
137
+ export function MuffinLogin(props: LoginProps) {
138
+ const {
139
+ auth: { loginURL },
140
+ } = useMuffinAdminOpts()
141
+ useEffect(() => {
142
+ if (loginURL) {
143
+ const { pathname, search } = window.location
144
+ const url = new URL(loginURL)
145
+ url.searchParams.set("redirect", pathname + search)
146
+ window.location.replace(url.toString())
147
+ }
148
+ }, [loginURL])
149
+ return <Login {...props} />
150
+ }
151
+
135
152
  // Initialize login page
136
- setupAdmin(["loginpage"], Login)
153
+ setupAdmin(["loginpage"], MuffinLogin)
package/src/index.tsx CHANGED
@@ -37,4 +37,4 @@ export async function initAdmin(prefix = "", containerId: string = "root") {
37
37
  )
38
38
  }
39
39
 
40
- export const VERSION = "9.4.1"
40
+ export const VERSION = "9.4.2"