Skip to content

Commit

Permalink
Merge pull request #118 from curveball/all-links-option
Browse files Browse the repository at this point in the history
Add a flag allowing users to see 'all links'
  • Loading branch information
evert authored Jan 6, 2022
2 parents 5234e35 + 8c4b5af commit 6328967
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ settings:
* `hiddenRels` - List of relationship types that will be hidden from the user by
default. This can be used for links that are simply not interesting for a human
to see. (default: `['self', 'curies']`.
* `fullBody` - If turned on, full JSON bodies are always rendered. This can also
be turned on during runtime by adding a `?_browser-fullbody` query parameter.
* `allLinks` - By default the Browser will hide links from the 'Links' table
that will be rendered as 'navigation buttons', forms (templated links), or are
considered special (the 'self' link). While this might be a nicer interface
for an average user browsing the hypermedia graph, as a developer you might
just want to see all the links.
Example:
Expand Down
4 changes: 3 additions & 1 deletion src/components/links-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export function LinksTable(props: PageProps) {

for (const link of props.resourceState.links.getAll()) {

if (props.options.hiddenRels.includes(link.rel) || link.rel in props.options.navigationLinks || (link as any).rendered) {
if (!props.options.allLinks &&
(props.options.hiddenRels.includes(link.rel) || link.rel in props.options.navigationLinks || (link as any).rendered))
{
continue;
}

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ function normalizeOptions(options?: Partial<Options>): Options {
assetBaseUrl: '/_hal-browser/assets/',
serveAssets: true,
fullBody: false,
allLinks: false,
};

const tmpNavLinks = Object.assign(
Expand Down
12 changes: 12 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ export type Options = {
* query parameter
*/
fullBody: boolean;

/**
* By default the Browser will hide links from the 'Links' table that will
* be rendered as 'navigation buttons', forms (templated links), or are
* considered special (the 'self' link).
*
* While this might be a nicer interface for an average user browsing the
* hypermedia graph, as a developer you might just want to see all the links
*
* Turning 'allLinks' on ensures that everything always shows.
*/
allLinks: boolean;
};

/**
Expand Down

0 comments on commit 6328967

Please sign in to comment.