Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
klen committed Jul 16, 2024
2 parents 875e866 + 8d04840 commit ab0283e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "muffin-admin",
"version": "3.12.2",
"version": "3.12.3",
"description": "NPM package for https://github.com/klen/muffin-admin",
"files": [
"src",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/MuffinAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { ConfirmationProvider } from "./common"
import { useMuffinAdminOpts } from "./hooks"
import { buildProvider, muffinTranslations } from "./i18n"
import { buildAdmin, findBuilder, findIcon, setupAdmin } from "./utils"
import { buildAdmin, deepMerge, findBuilder, findIcon, setupAdmin } from "./utils"

export function MuffinAdmin(props: AdminProps) {
const opts = useMuffinAdminOpts()
Expand All @@ -29,7 +29,7 @@ export function MuffinAdmin(props: AdminProps) {
? Object.fromEntries(
Object.entries(muffinTranslations).map(([locale, messages]) => [
locale,
{ ...messages, ...backendLocales[locale], ...(buildAdmin(["locale", locale]) || {}) },
deepMerge({}, messages, backendLocales[locale], buildAdmin(["locale", locale]) || {}),
])
)
: muffinTranslations
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,24 @@ export function buildIcon(icon?: string) {
const Icon = findIcon(icon)
if (Icon) return <Icon />
}

function isObject(item: any) {
return item && typeof item === "object" && !Array.isArray(item)
}

export function deepMerge(target: any, ...sources: any[]): any {
if (!sources.length) return target
const source = sources.shift()

if (isObject(target) && isObject(source)) {
for (const key in source) {
if (isObject(source[key])) {
if (!target[key]) Object.assign(target, { [key]: {} })
deepMerge(target[key], source[key])
} else {
Object.assign(target, { [key]: source[key] })
}
}
}
return deepMerge(target, ...sources)
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "muffin-admin"
version = "3.12.2"
version = "3.12.3"
description = "Admin interface for Muffin Framework"
readme = "README.rst"
license = "MIT"
Expand Down

0 comments on commit ab0283e

Please sign in to comment.