wu-sheng opened a new pull request, #11:
URL: https://github.com/apache/skywalking-horizon-ui/pull/11
## Two related fixes to the "You have unpublished local edits" prompt
### 1. Re-show after login
The prompt's `dismissed` flag is initialised from `sessionStorage` at
component construction:
```ts
const dismissed = ref<boolean>(
typeof sessionStorage !== 'undefined' &&
sessionStorage.getItem(SESSION_KEY) === '1',
);
```
`sessionStorage` is per-tab, not per-login — it survives logout / login in
the same browser tab. So an operator who dismissed the modal earlier could log
back in, find drafts they hadn't pushed, and never get reminded.
**Fix:** [`apps/ui/src/state/auth.ts`](apps/ui/src/state/auth.ts) —
`login()` now clears the prompt's session key on every successful login, right
next to the existing `useTemplatePreference().reset()`. Since `/login` lives
outside AppShell, the next AppShell mount re-reads the (now-clean)
sessionStorage and the modal opens reliably whenever drafts exist.
### 2. Align verb gates to `:write`
[`apps/ui/src/shell/TemplateConflictPrompt.vue`](apps/ui/src/shell/TemplateConflictPrompt.vue)
— the layer-draft gate was `dashboard:read` while the overview-draft gate was
`overview:write`. Comment-of-record above the component says *"kinds the user
can edit"*, so symmetric `:write` is the intended semantic. Bumped to
`dashboard:write` for the layer gate.
No behaviour change against the default policy — `dashboard:read` and
`dashboard:write` resolve to the same roles (operator + admin) today. The
change matters only against a custom policy that grants read-only dashboard
access; that role would have seen the prompt without being able to act on it.
## Behaviour after the PR
| Role | Sees prompt? | Notes |
|---|:-:|---|
| viewer | ❌ | No relevant write verbs; can't push drafts anyway. |
| maintainer | ❌ | Same as viewer for these verbs. |
| operator | ✅ | Reliably re-shown on every fresh login. |
| admin | ✅ | Reliably re-shown on every fresh login. |
- **Dismiss within a session** → stays dismissed across in-app navigations
(unchanged).
- **Hard refresh while logged in** → sessionStorage retained, stays
dismissed (unchanged).
- **Logout → login (same tab)** → sessionStorage cleared by `login()`,
prompt re-shows. (Was the bug.)
## Validation
- `pnpm --filter ui run type-check` ✓
- `pnpm --filter ui run test:unit` — 5 files / 69 tests ✓
- eslint on changed files ✓
- `license-eye header check` — 0 invalid ✓
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]