Skip to content

Commit 96264fa

Browse files
committed
feat: #226 Add option to override logo url in the django settings
1 parent 89146d0 commit 96264fa

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

django_email_learning/platform/views.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ def get_shared_context(self) -> Dict[str, Any]:
6565
and getattr(self.request.user, "has_platform_admin_role", False)
6666
)
6767
),
68+
"customLogo": {
69+
"horizontalLight": DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO", {})
70+
.get("HORIZONTAL_LOCKUP", {})
71+
.get("LIGHT_BACKGROUND"),
72+
"horizontalDark": DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO", {})
73+
.get("HORIZONTAL_LOCKUP", {})
74+
.get("DARK_BACKGROUND"),
75+
"verticalLight": DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO", {})
76+
.get("VERTICAL_LOCKUP", {})
77+
.get("LIGHT_BACKGROUND"),
78+
"verticalDark": DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO", {})
79+
.get("VERTICAL_LOCKUP", {})
80+
.get("DARK_BACKGROUND"),
81+
}
82+
if DJANGO_EMAIL_LEARNING_SETTINGS.get("LOGO")
83+
else None,
6884
"isOrganizationAdmin": (
6985
self.request.user.is_superuser
7086
or (

django_service/settings.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@
110110
"COMPONENT_TAG": "<l-helix />",
111111
}
112112
},
113+
"LOGO": {
114+
"HORIZONTAL_LOCKUP": {
115+
"LIGHT_BACKGROUND": None,
116+
"DARK_BACKGROUND": None,
117+
},
118+
"VERTICAL_LOCKUP": {
119+
"LIGHT_BACKGROUND": None,
120+
"DARK_BACKGROUND": None,
121+
},
122+
},
113123
}
114124

115125

frontend/src/components/MenuBar.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,23 @@ function MenuBar({activeOrganizationId, changeOrganizationCallback, showOrganiza
5454
const [organizations, setOrganizations] = useState([])
5555
const [deliverContentsJobStatus, setDeliverContentsJobStatus] = useState(null)
5656
const [chip, setChip] = useState(null)
57-
const { localeMessages, isPlatformAdmin, isOrganizationAdmin, direction, apiBaseUrl, platformBaseUrl, sidebarCustomComponent } = useAppContext();
57+
const { localeMessages, isPlatformAdmin, isOrganizationAdmin, direction, apiBaseUrl, platformBaseUrl, sidebarCustomComponent, customLogo } = useAppContext();
5858

5959
const theme = useTheme();
6060
const isMdUpScreen = useMediaQuery(theme.breakpoints.up('md'));
6161

6262
const drawerVariant = isMdUpScreen ? "permanent" : "temporary";
63-
const logoHorizontalUrl = theme.palette.mode === 'light' ? logoHorizontalLightUrl : logoHorizontalDarkUrl;
64-
const logoVerticalUrl = theme.palette.mode === 'light' ? logoVerticalLightUrl : logoVerticalDarkUrl;
63+
let logoHorizontalUrl, logoVerticalUrl;
64+
if (customLogo) {
65+
logoHorizontalUrl = theme.palette.mode === 'light' ? (customLogo.horizontalLight ? customLogo.horizontalLight : customLogo.horizontalDark) : (customLogo.horizontalDark ? customLogo.horizontalDark : customLogo.horizontalLight);
66+
logoVerticalUrl = theme.palette.mode === 'light' ? (customLogo.verticalLight ? customLogo.verticalLight : customLogo.verticalDark) : (customLogo.verticalDark ? customLogo.verticalDark : customLogo.verticalLight);
67+
}
68+
if (!logoHorizontalUrl) {
69+
logoHorizontalUrl = theme.palette.mode === 'light' ? logoHorizontalLightUrl : logoHorizontalDarkUrl;
70+
}
71+
if (!logoVerticalUrl) {
72+
logoVerticalUrl = theme.palette.mode === 'light' ? logoVerticalLightUrl : logoVerticalDarkUrl;
73+
}
6574

6675
const jobsStatusMap = {
6776
"healthy": {

0 commit comments

Comments
 (0)