Skip to content

Commit 0e29bed

Browse files
committed
feat: add support for logo in config
1 parent eff22fa commit 0e29bed

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

pkg/server/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func (cfg Config) grpcAddr() string { return fmt.Sprintf("%s:%d", cfg.Host, cfg.
2828
type UIConfig struct {
2929
Port int `yaml:"port" mapstructure:"port"`
3030
Title string `yaml:"title" mapstructure:"title"`
31+
Logo string `yaml:"logo" mapstructure:"logo"`
3132
}
3233

3334
type Config struct {

pkg/server/server.go

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const (
5757

5858
type UIConfigApiResponse struct {
5959
Title string `json:"title"`
60+
Logo string `json:"logo"`
6061
}
6162

6263
func ServeUI(ctx context.Context, logger log.Logger, uiConfig UIConfig, apiServerConfig Config) {
@@ -91,6 +92,7 @@ func ServeUI(ctx context.Context, logger log.Logger, uiConfig UIConfig, apiServe
9192
w.Header().Set("Content-Type", "application/json")
9293
confResp := UIConfigApiResponse{
9394
Title: uiConfig.Title,
95+
Logo: uiConfig.Logo,
9496
}
9597
json.NewEncoder(w).Encode(confResp)
9698
})

ui/src/components/page-title/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useContext, useEffect } from "react";
22
import { AppContext } from "~/contexts/App";
3+
import { defaultConfig } from "~/utils/constants";
34

45
interface PageTitleProps {
56
title?: string;
@@ -8,7 +9,7 @@ interface PageTitleProps {
89

910
export default function PageTitle({ title, appName }: PageTitleProps) {
1011
const { config } = useContext(AppContext);
11-
const titleAppName = appName || config?.title;
12+
const titleAppName = appName || config?.title || defaultConfig?.title;
1213
const fullTitle = title ? `${title} | ${titleAppName}` : titleAppName;
1314

1415
useEffect(() => {

ui/src/containers/login.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Header, MagicLink } from "@raystack/frontier/react";
55
import { useContext } from "react";
66
import PageTitle from "~/components/page-title";
77
import { AppContext } from "~/contexts/App";
8+
import { defaultConfig } from "~/utils/constants";
89

910
export default function Login() {
1011
const { config } = useContext(AppContext);
@@ -31,13 +32,13 @@ export default function Login() {
3132
logo={
3233
<Image
3334
alt="logo"
34-
src="logo.svg"
35+
src={config?.logo || "logo.svg"}
3536
width={80}
3637
height={80}
3738
style={{ borderRadius: "var(--pd-8)" }}
3839
/>
3940
}
40-
title={`Login to ${config?.title}`}
41+
title={`Login to ${config?.title || defaultConfig.title}`}
4142
/>
4243
<MagicLink open />
4344
</Flex>

ui/src/contexts/App.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ import {
1212
V1Beta1Plan,
1313
} from "@raystack/frontier";
1414
import { useFrontier } from "@raystack/frontier/react";
15+
import { Config, defaultConfig } from "~/utils/constants";
1516

1617
// TODO: Setting this to 1000 initially till APIs support filters and sorting.
1718
const page_size = 1000;
1819

1920
type OrgMap = Record<string, V1Beta1Organization>;
2021

21-
export interface Config {
22-
title: string;
23-
}
24-
2522
interface AppContextValue {
2623
orgMap: OrgMap;
2724
isAdmin: boolean;
@@ -34,10 +31,6 @@ interface AppContextValue {
3431
config: Config;
3532
}
3633

37-
const defaultConfig: Config = {
38-
title: "Frontier Admin",
39-
};
40-
4134
const AppContextDefaultValue = {
4235
orgMap: {},
4336
isAdmin: false,

ui/src/utils/constants.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ export const PERMISSIONS = {
44
OrganizationNamespace: "app/organization",
55
} as const;
66

7-
87
export const SUBSCRIPTION_STATUSES = [
9-
{label: 'Active', value: 'active'},
10-
{label: 'Trialing', value: 'trialing'},
11-
{label: 'Past due', value: 'past_due'},
12-
{label: 'Canceled', value: 'canceled'},
13-
{label: 'Ended', value: 'ended'}
14-
]
8+
{ label: "Active", value: "active" },
9+
{ label: "Trialing", value: "trialing" },
10+
{ label: "Past due", value: "past_due" },
11+
{ label: "Canceled", value: "canceled" },
12+
{ label: "Ended", value: "ended" },
13+
];
14+
15+
export interface Config {
16+
title: string;
17+
logo?: string;
18+
}
19+
20+
export const defaultConfig: Config = {
21+
title: "Frontier Admin",
22+
};

0 commit comments

Comments
 (0)