Skip to content

ui - add an export domain button to download the domain as json - #3575

Open
NopeCharon wants to merge 1 commit into
AthenZ:masterfrom
NopeCharon:ui-export-domain-json
Open

NopeCharon wants to merge 1 commit into
AthenZ:masterfrom
NopeCharon:ui-export-domain-json

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Description

Fixes #1382.

The domain pages had no way to get a full copy of a domain's configuration from the UI. ZMS already returns every role, group, policy, service and entity of a domain through the signed domain API (GET /domain/{name}/signed), so the UI can offer it as a download without any ZMS change.

Changes:

  • server/handlers/api.js: a new domain-export fetchr service calls getJWSDomain, decodes the base64url payload and returns the DomainData object. If the payload can't be decoded, the service returns a 500 instead of throwing inside the callback.
  • api.js: a new exportDomain(domainName) call.
  • DomainDetails: a new Export Domain button next to "More Details" on the domain pages. It saves the domain data as a pretty-printed <domain>.json. If the export fails, the error appears in a dismissable alert.

Tests:

  • handlers/api.test.js: covers the fetchr service for success, a ZMS error and a payload that can't be decoded.
  • api.test.js: covers the client call.
  • DomainDetails.test.js: checks the downloaded file's name, type and content, and checks the error alert.
  • The domain page snapshots now include the button.

Without the source changes, the new tests fail. I ran the jest suites for api, handlers/api, DomainDetails and all pages/domain/[domain] pages, and checked the changed files with prettier (ci-lint).

Contribution Checklist:

  • The pull request does not introduce any breaking changes
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Attach Screenshots (Optional)

@havetisyan

Copy link
Copy Markdown
Collaborator

What's the use case for users to have the capability to download the domain data as json through the UI instead of just using zms-cli?

@NopeCharon

Copy link
Copy Markdown
Contributor Author

It's what #1382 asked for: a button on the domain page that downloads the domain as json. It's mainly for people who work in the UI and don't have zms-cli set up but want a quick snapshot of a domain's full config, for a backup or for review.

The domain pages had no way to get a full copy of a domain's
configuration from the UI. ZMS already returns every role, group,
policy, service and entity of a domain through the signed domain
api (GET /domain/{name}/signed), so the UI can offer it as a
download without adding anything to ZMS.

- server: new domain-export fetchr service that calls getJWSDomain,
  decodes the base64url payload and returns the DomainData object.
  A payload that cannot be decoded is reported as a 500 instead of
  throwing inside the callback.
- client: new exportDomain(domainName) api call.
- DomainDetails: new Export Domain button that saves the domain
  data as <domain>.json, pretty printed. A failed export is shown
  in a dismissable alert.

Tests cover the fetchr service (success, ZMS error and bad
payload), the client api call, and the download and error paths
of the button. The domain page snapshots now include the button.

Fixes AthenZ#1382

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@NopeCharon
NopeCharon force-pushed the ui-export-domain-json branch from 187402f to 39c0782 Compare November 2, 2026 07:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI - export domain as json

2 participants