Add dashboard view for global env vars
This commit is contained in:
parent
52cf99b56d
commit
b99dd16343
37
apps/env/20260130-000000/index.tsx
vendored
37
apps/env/20260130-000000/index.tsx
vendored
|
|
@ -300,9 +300,35 @@ app.get('/', async c => {
|
|||
const appName = c.req.query('app')
|
||||
|
||||
if (!appName) {
|
||||
// Dashboard view: global env vars only
|
||||
const globalVars = parseEnvFile(GLOBAL_ENV_PATH)
|
||||
|
||||
return c.html(
|
||||
<Layout title="Environment Variables">
|
||||
<ErrorBox>Please specify an app name with ?app=<name></ErrorBox>
|
||||
<Layout title="Global Environment Variables">
|
||||
{globalVars.length === 0 ? (
|
||||
<EmptyState>No global environment variables</EmptyState>
|
||||
) : (
|
||||
<EnvList>
|
||||
{globalVars.map(v => (
|
||||
<EnvItem data-env-item>
|
||||
<EnvKey>{v.key}</EnvKey>
|
||||
<EnvValue data-value data-hidden={v.value}>{'••••••••'}</EnvValue>
|
||||
<EnvActions>
|
||||
<Button data-reveal>Reveal</Button>
|
||||
<form method="post" action={`/delete-global?key=${v.key}`} style="margin:0">
|
||||
<DangerButton type="submit">Delete</DangerButton>
|
||||
</form>
|
||||
</EnvActions>
|
||||
</EnvItem>
|
||||
))}
|
||||
</EnvList>
|
||||
)}
|
||||
<Form method="POST" action="/set-global">
|
||||
<Input type="text" name="key" placeholder="KEY" required />
|
||||
<Input type="text" name="value" placeholder="value" required />
|
||||
<Button type="submit">Add</Button>
|
||||
</Form>
|
||||
<Hint>Global vars are available to all apps. Changes take effect on next app restart.</Hint>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
|
@ -437,7 +463,6 @@ app.post('/delete', async c => {
|
|||
|
||||
app.post('/set-global', async c => {
|
||||
const appName = c.req.query('app')
|
||||
if (!appName) return c.text('Missing app', 400)
|
||||
|
||||
const body = await c.req.parseBody()
|
||||
const key = String(body.key).trim().toUpperCase()
|
||||
|
|
@ -455,17 +480,17 @@ app.post('/set-global', async c => {
|
|||
}
|
||||
|
||||
writeEnvFile(GLOBAL_ENV_PATH, vars)
|
||||
return c.redirect(`/?app=${appName}&tab=global`)
|
||||
return c.redirect(appName ? `/?app=${appName}&tab=global` : '/')
|
||||
})
|
||||
|
||||
app.post('/delete-global', async c => {
|
||||
const appName = c.req.query('app')
|
||||
const key = c.req.query('key')
|
||||
if (!appName || !key) return c.text('Missing app or key', 400)
|
||||
if (!key) return c.text('Missing key', 400)
|
||||
|
||||
const vars = parseEnvFile(GLOBAL_ENV_PATH).filter(v => v.key !== key)
|
||||
writeEnvFile(GLOBAL_ENV_PATH, vars)
|
||||
return c.redirect(`/?app=${appName}&tab=global`)
|
||||
return c.redirect(appName ? `/?app=${appName}&tab=global` : '/')
|
||||
})
|
||||
|
||||
export default app.defaults
|
||||
|
|
|
|||
3
apps/env/20260130-000000/package.json
vendored
3
apps/env/20260130-000000/package.json
vendored
|
|
@ -10,7 +10,8 @@
|
|||
},
|
||||
"toes": {
|
||||
"tool": ".env",
|
||||
"icon": "🔑"
|
||||
"icon": "🔑",
|
||||
"dashboard": true
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user