Skip to content

Commit f201ed8

Browse files
authored
feat: dev-mode only settings visibility (#42)
* feat: hide dev-only settings unless dev mode is active Add useDevMode hook that checks if any plugin is in dev mode. Filter devOnly settings in SettingsEntries so they are hidden by default. Mark telemetry endpoint/auth settings as devOnly. Update Wails TS binding with devOnly field. * chore: bump plugin-sdk to v0.4.1 and regenerate bindings Updates go.mod to use plugin-sdk v0.4.1 which includes the DevOnly field on Setting. Regenerates Wails bindings via make bindings.
1 parent e9db9b7 commit f201ed8

6 files changed

Lines changed: 28 additions & 5 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/hashicorp/go-hclog v1.6.3
1313
github.com/hashicorp/go-plugin v1.7.0
1414
github.com/nxadm/tail v1.4.11
15-
github.com/omniviewdev/plugin-sdk v0.4.0
15+
github.com/omniviewdev/plugin-sdk v0.4.1
1616
github.com/omniviewdev/registry v0.2.1
1717
github.com/stretchr/testify v1.11.1
1818
github.com/tidwall/gjson v1.18.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
131131
github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
132132
github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
133133
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
134-
github.com/omniviewdev/plugin-sdk v0.4.0 h1:0W9HTWTUYHv5s0yhU6KpxcPdEqLG7JfpkNjcGDllXmA=
135-
github.com/omniviewdev/plugin-sdk v0.4.0/go.mod h1:7EL5BfctDEQdflClkZMhgvSAGkDff79UteN7rcuBUho=
134+
github.com/omniviewdev/plugin-sdk v0.4.1 h1:DLZrKzm+szGrVslp3vvCN8Ao7yd4czCkjzxgZKU1+Rk=
135+
github.com/omniviewdev/plugin-sdk v0.4.1/go.mod h1:7EL5BfctDEQdflClkZMhgvSAGkDff79UteN7rcuBUho=
136136
github.com/omniviewdev/registry v0.2.1 h1:4CsiBZmlftBZV/3LyQNiI2plRkMAqgFD8Q4zffFCVYk=
137137
github.com/omniviewdev/registry v0.2.1/go.mod h1:/IZABypY6iIaHo2Gw5g5Ll4SIbUhEm5/02spR/svl3Q=
138138
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=

internal/settings/telemetry.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,23 @@ func buildTelemetrySettings() map[string]settings.Setting {
8181
Description: "OTLP HTTP endpoint for traces, metrics, and logs (e.g., localhost:4318)",
8282
Type: settings.Text,
8383
Default: defaults.OTLPEndpoint,
84+
DevOnly: true,
8485
},
8586
"endpoint_pyroscope": {
8687
ID: "endpoint_pyroscope",
8788
Label: "Pyroscope Endpoint",
8889
Description: "Pyroscope endpoint for continuous profiling (e.g., localhost:4040)",
8990
Type: settings.Text,
9091
Default: defaults.PyroscopeEndpoint,
92+
DevOnly: true,
9193
},
9294
"auth_header": {
9395
ID: "auth_header",
9496
Label: "Auth Header",
9597
Description: "HTTP header name for authentication (e.g., Authorization for Grafana Cloud)",
9698
Type: settings.Text,
9799
Default: defaults.AuthHeader,
100+
DevOnly: true,
98101
},
99102
"auth_value": {
100103
ID: "auth_value",
@@ -103,6 +106,7 @@ func buildTelemetrySettings() map[string]settings.Setting {
103106
Type: settings.Password,
104107
Default: defaults.AuthValue,
105108
Sensitive: true,
109+
DevOnly: true,
106110
},
107111
}
108112
}

packages/omniviewdev-runtime/src/wailsjs/go/models.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,6 +2580,7 @@ export namespace settings {
25802580
options: SettingOption[];
25812581
fileSelection?: SettingFileSelection;
25822582
sensitive: boolean;
2583+
devOnly: boolean;
25832584

25842585
static createFrom(source: any = {}) {
25852586
return new Setting(source);
@@ -2596,6 +2597,7 @@ export namespace settings {
25962597
this.options = this.convertValues(source["options"], SettingOption);
25972598
this.fileSelection = this.convertValues(source["fileSelection"], SettingFileSelection);
25982599
this.sensitive = source["sensitive"];
2600+
this.devOnly = source["devOnly"];
25992601
}
26002602

26012603
convertValues(a: any, classs: any, asMap: boolean = false): any {

ui/hooks/useDevMode.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { useInstalledPlugins } from '@/hooks/plugin/useInstalledPlugins';
2+
3+
/**
4+
* Returns true when at least one plugin is installed in dev mode,
5+
* which activates visibility of dev-only settings.
6+
*/
7+
export function useDevMode(): boolean {
8+
const { plugins } = useInstalledPlugins();
9+
return plugins.some(p => p.dev);
10+
}

ui/pages/settings/SettingsEntries.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Text } from '@omniviewdev/ui/typography';
99
import { type SectionSelection } from '.';
1010
import SettingsEntry from './SettingsEntry';
1111
import { type settings } from '@omniviewdev/runtime/models';
12+
import { useDevMode } from '@/hooks/useDevMode';
1213

1314
type Props = SectionSelection & {
1415
settings: Record<string, settings.Setting>;
@@ -20,6 +21,8 @@ type Props = SectionSelection & {
2021
* Displays and allows modification to application settings, given a settings namespace and section.
2122
*/
2223
const SettingsEntries: React.FC<Props> = ({ id: sectionID, settings, draftValues, setDraftValues }) => {
24+
const devMode = useDevMode();
25+
2326
const handleChange = (name: string, value: any) => {
2427
const id = `${sectionID}.${name}`;
2528
setDraftValues({ ...draftValues, [id]: value });
@@ -29,6 +32,10 @@ const SettingsEntries: React.FC<Props> = ({ id: sectionID, settings, draftValues
2932
return <></>;
3033
}
3134

35+
const visibleSettings = Object.entries(settings).filter(
36+
([, setting]) => !setting.devOnly || devMode,
37+
);
38+
3239
return (
3340
<Stack
3441
direction='column'
@@ -42,7 +49,7 @@ const SettingsEntries: React.FC<Props> = ({ id: sectionID, settings, draftValues
4249
scrollbarWidth: 'none',
4350
}}
4451
>
45-
{Object.entries(settings).map(([id, setting], index) => (
52+
{visibleSettings.map(([id, setting], index) => (
4653
<Box
4754
key={id}
4855
sx={{
@@ -51,7 +58,7 @@ const SettingsEntries: React.FC<Props> = ({ id: sectionID, settings, draftValues
5158
gap: { xs: 1, md: 4 },
5259
alignItems: { xs: 'stretch', md: 'flex-start' },
5360
py: 2.5,
54-
borderBottom: index < Object.keys(settings).length - 1 ? '1px solid' : 'none',
61+
borderBottom: index < visibleSettings.length - 1 ? '1px solid' : 'none',
5562
borderColor: 'divider',
5663
}}
5764
>

0 commit comments

Comments
 (0)