Skip to content

Commit 2e2ae59

Browse files
feat: Hide Dashboard sidebar using user config (#521)
Signed-off-by: Alioune Gaye <alioune.gaye@secomind.com>
1 parent 84aa3e5 commit 2e2ae59

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

public/user-config/config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
{
77
"type": "token"
88
}
9-
]
9+
],
10+
"ui": {
11+
"hideSidebar": true
12+
}
1013
}

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ const DashboardSidebar = () => {
3535
const config = useConfig();
3636
const astarte = useAstarte();
3737
const { triggerDeliveryPoliciesSupported } = useAstarte();
38+
const isSidebarHidden = config.ui.hideSidebar;
3839

39-
if (!astarte.isAuthenticated) {
40+
if (!astarte.isAuthenticated || isSidebarHidden) {
4041
return null;
4142
}
4243

src/ConfigManager.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ type ConfigContextValue = {
4545
features: {
4646
flow: boolean;
4747
};
48+
ui: {
49+
hideSidebar: boolean;
50+
};
4851
};
4952

5053
const ConfigContext = createContext<ConfigContextValue | null>(null);
@@ -77,6 +80,9 @@ const ConfigProvider = ({
7780
features: {
7881
flow: !!config.enableFlowPreview,
7982
},
83+
ui: {
84+
hideSidebar: !!config.ui?.hideSidebar,
85+
},
8086
};
8187

8288
config.auth.forEach((authOption) => {

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fetch('/user-config/config.json')
3535
auth: json.auth,
3636
defaultAuth: json.default_auth,
3737
defaultRealm: json.default_realm,
38+
ui: json.ui,
3839
}))
3940
.catch(() => null)
4041
.then((config: DashboardConfig | null) => {

src/types/dashboardConfig.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ type DashboardConfig = {
4141
pairingApiUrl?: string;
4242
flowApiUrl?: string;
4343
enableFlowPreview: boolean;
44+
ui: {
45+
hideSidebar: boolean;
46+
};
4447
} & DashboardAuthConfig;
4548

4649
export type { DashboardConfig };

0 commit comments

Comments
 (0)