Files
notifications-admin/app/templates/components/api-key.html
Tom Byers a0e78e6102 Changes to API key component
Changes the interface so:
- `name` is a required argument
- the heading is only shown if `name` and `thing`
  match

These changes reflect a pattern observed in how
the component is used in pages.

It's first worth stating what the `thing` and
`name` arguments are.

`thing` is the type of thing the id is, for
example an reply-to email address.
`name` is which one of that type in the page, for
example the reply-to email address for user 1.

In pages where the id is the only one of its type,
these will have the same value.

When it is the only one of its type in a page, it
always has a heading so this makes the heading
appear based on `name` matching `thing`.
2020-08-25 10:54:42 +01:00

14 lines
481 B
HTML

{% macro api_key(key, name, thing="API key") %}
{% if name == thing %}
<h2 class="api-key__name">
{{ name }}
</h2>
{% endif %}
<div data-module="api-key" data-key="{{ key }}" data-thing="{{ thing }}" data-name="{{ name }}">
<span class="api-key__key">
{% if name != thing %}<span class="govuk-visually-hidden">{{ thing }}: </span>{% endif %}{{ key }}
</span>
<span class="api-key__notice" aria-live="assertive"></span>
</div>
{% endmacro %}