Commit Graph

12322 Commits

Author SHA1 Message Date
Katie Smith
4e409f7d93 Show preview of current branding
This adds a preview of the current branding to users on the page where
they can select which new branding they want. Also includes a tiny
content change to match the new content doc for this story.
2022-02-22 14:57:49 +00:00
Katie Smith
77e1c015c4 Update GOV.UK and org email branding content
To make it consistent with the GOV.UK email branding page content.
2022-02-22 13:21:34 +00:00
Katie Smith
5ada431da9 NHS and GOV.UK email branding pages now show preview and apply branding
The pages you were redirected to if you selected either GOV.UK branding
or NHS branding used to give information about the branding and have a
button that submitted a Zendesk ticket. Now, we show a preview of the
new branding and the button applies it.
2022-02-22 13:18:21 +00:00
Katie Smith
87e6737f9e Highlight "Settings" in menu if visiting govuk and org branding page
This was accidentally missed out of a previous PR. It ensures that
when you visit the `.email_branding_govuk_and_org` endpoint "Settings"
is highlighted in the left hand menu.
2022-02-22 13:18:21 +00:00
Katie Smith
d75c1ea398 Split out the govuk and govuk_and_org branding templates
The `.email_branding_govuk` and `.email_branding_govuk_and_org` routes
shared a template since the content was the same - the only difference
was in the action of the button. However, since the pages will no longer
be so similar (e.g. the govuk page will show a preview) this splits them
up to use separate templates.

It may be the case that when the branding work is complete these pages
are fairly similar and we decided that one template between the two
endpoints is the best option again.
2022-02-22 11:39:53 +00:00
Ben Thorner
9f45e4c5be Merge pull request #4160 from alphagov/redis-clear-all
Make it easy to clear cache for all key formats
2022-02-21 15:18:32 +00:00
Ben Thorner
ebbfd20472 Make it easy to clear cache for all key formats
Having to submit the form for each choice separately slowed us down
during an incident where Redis was unavailable and came back with
stale data, which we had to clear manually.

Note: we don't want to use the "flush" feature in case there are other
keys in Redis, which may not be safe to remove.
2022-02-21 15:09:03 +00:00
Ben Thorner
16a14cd642 Rewrite test for clear cache radio buttons
This was missing an existing option to clear for broadcasts.
2022-02-21 14:11:53 +00:00
Ben Thorner
8396412ce1 Report all cache keys that were deleted
This will make it easier to add another test / feature to clear all
the cache keys. It's debatable which of "sum" and "max" is useful:

- "max" is a better (although still not accurate) indicator of the
number of "things" affected e.g. templates, services, etc.

- "sum" makes sense in places where "max" doesn't e.g. when we clear
the "organisations" group, which doesn't equate to individual orgs.

Using "sum() ... across" seems like a reasonable compromise and makes
it clear that we're iterating over different kinds of keys.

While the pluralisation is nice, I don't think it's worth the effort
to make it work for both "object(s)" and "format(s)".
2022-02-21 14:11:49 +00:00
Tom Byers
902c55076c Merge pull request #4155 from alphagov/add-large-link-focus-variant
Fix current alerts focus styles - part 2
2022-02-18 14:33:07 +00:00
Tom Byers
8521d1e45f Add assertions against stray classes
In previous iterations of the classPersister, we
found issues with the implementation meant classes
it should have added back to elements were also
added to other elements. This adds tests for this
scenario to ensure it doesn't happen again.

Also includes changes to fix a linting error with
the JS which complained about a function being
defined in a loop while referencing variables in
the outer scope.
2022-02-18 12:07:41 +00:00
Tom Byers
85e14d302c Make a classesPersister per component instance
It makes more sense for something that operates on
a single component to be local to it.
2022-02-16 16:08:48 +00:00
Tom Byers
3a86bd1685 Change internals of classesPersister
The assumption that the classes you want to
persist will always have parity with the elements
that have those classes, at that point, won't
always be true.

Because of that, this changes the way elements
with those classes are stored, to be in a map
between classes and the elements with them (at
that point).

Also includes an extra test for a scenario where
more than one updating component is in the page
with classes that need to persist through updates.
2022-02-16 15:59:29 +00:00
Tom Byers
41ee340b45 Rewrite updateContent tests 2022-02-16 11:25:50 +00:00
Tom Byers
8c253309e4 Fix error in updateContent code
This was missed from these changes:

9646e17b03
2022-02-15 16:35:45 +00:00
Tom Byers
1d69f7ab61 Fix focus style gap at top in keyline-block
File-list items contained by div.keyline-block's
are pushed down 3px more than elsewhere which
creates a gap between the top of the focus style
and the keyline above. This extends the part of
the focus style made up by a box-shadow by 3px so
it covers the gap.
2022-02-15 13:02:39 +00:00
Tom Byers
776f210e7b Add comments about deleting this code in future
If the :has pseudo-class becomes available in the
browsers we support in future, the code this
branch/pull request adds will be redundant as its
behaviour will be possible only using CSS.

This adds comments to note this to the parts of
the code you'd need to remove.
2022-02-15 11:26:17 +00:00
Tom Byers
467be3a339 Fixes for updateContent based on PR comments
Includes the following:

Guard for adding duplicate classNames

Stops the code that allows classNames to persist
across updates to the component HTML from adding a
className multiple times to the list of those to
persist. From this comment on the associated pull
request:

https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804639058

Add comment explaining guard for operations on
elements no longer in the DOM

The value of this guard can be unclear and why it
is needed so we add a comment to explain this.
From this comment on the associated pull request:

https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804697189
2022-02-15 11:11:45 +00:00
Tom Byers
e310ff3469 Quick fixes for updateContent tests
To address issues in these comments:
- https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804641078
- https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804642005
2022-02-11 16:36:49 +00:00
Tom Byers
9646e17b03 Make classNames used by classesPersister private
Both the remove and replace methods rely on it
having parity with the $els array property so it
is a good idea to stop it, and $els, being
changable by other code. As noted in:

https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804639058
2022-02-11 15:40:47 +00:00
Tom Byers
4f59396a00 Change classesToPersist to classesPersister
Makes it sounds less like a list and more like a
thing that makes classes persist, as noted in:

https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804638407
2022-02-11 15:35:04 +00:00
Tom Byers
51594e7d46 Add test for changes to component HTML on start
The updateContent JS was changed in this commit so
the replacement of the original HTML (with GOVUK
modules data-attributes) was moved into the start
method rather than being a slightly odd side
effect of the render function diffing:

476ed1593c

This adds a test to make it more clear this
happens, as requested in this comment:

https://github.com/alphagov/notifications-admin/pull/4155#discussion_r804689618
2022-02-11 15:10:23 +00:00
Tom Byers
99df8542b4 Add guard against elements removed from the DOM
We can't guarantee that elements we stored a
reference to with `classesToPersist.remove` will
still exist so we need to guard against this.

Note: it checks for whether the node is still
attached to the DOM rather than whether it exists
because the standard way to delete a node just
detaches it from the DOM and relies on garbage
collection to delete it from memory.
2022-02-11 12:30:07 +00:00
Tom Byers
476ed1593c Make updateContent handle all AJAX the same
The current updateContent JS replaces the in-page
HTML with the HTML from the server the first time
an AJAX request is fired, even if the HTML from
the server has no changes. This is because the
code that compares the two operates on two
different things:

The HTML in the page is the component HTML, with
all the data attributes and the partial HTML
(marked with the 'ajax-block-container' class) as
its first child:

```
<div data-module="update-content" data-url="...">
  <div class="ajax-block-container">
    ...
  </div>
</div>
```

The HTML from the server only contains the
partial:

```
<div class="ajax-block-container">
  ...
</div>
```

The diffing code just sees them as different at
the top level so replaces the page HTML with the
partial from the server. This means all subsequent
diffs are between partial HTML and partial HTML so
only update on actual changes.

These replace the component with the partial, as
part of the component initialising. This means all
code that runs on an AJAX response will only
compare like-for-like so will result in actual
changes (or none at all), not just swapping one
element out for another.

Note: this commit also removes the
aria-live="polite" from the ajax_block component.
It has always been overwritten by the first
response so never announces anything to assistive
technologies. Removing it makes this more clear.
2022-02-09 12:25:15 +00:00
Tom Byers
d76648b67b Mark focus of link on parent heading in file-list
Includes:
- JS to add a class to the heading when the link
  is focused
- CSS to apply the enlarged focus style via a
  selector which uses that class
- changes to the partial to hook in the JS to
  track focus on links and to tell the
  updateContent JS to persist the classes added
  between updates to the HTML
2022-02-09 12:25:14 +00:00
Tom Byers
3fa2650ffa Make updateContent persist specified classNames
Wrap the code that updates the HTML with changes
from the server with code that stores and
re-applies specified classes.

This is to allow other JS to add classes which
change the visual state of the HTML without them
being considered by the code that diffs our
in-page HTML against that from the server.

They are called classesToPersist because this
should make the visual state they create persist
between updates.

Includes the addition of tests for updateContent
that cover the addition/deletion of elements so we
can write a test for classNames persisting through
updates. The existing tests only cover updates
that change the content of elements. Just adding
the test for these changes to those would simulate
a scenario that doesn't exist in the app. Writing
extra tests for the kind of updates these changes
act on keeps them in line with the app code.
2022-02-09 12:24:59 +00:00
Tom Byers
73cc034676 Merge pull request #4141 from alphagov/refactor-current-alerts-html
Fix current alerts focus styles - part 1
2022-02-09 11:23:07 +00:00
Chris Hill-Scott
6fe766ffaf Merge pull request #4152 from alphagov/bump-utils-53
Bump utils to 53.0.0
2022-02-08 09:56:15 +00:00
Katie Smith
d8b421a9d6 Merge pull request #4151 from alphagov/brand-new-branding-tidy-ups
Tidy up new email branding routes
2022-02-08 08:53:00 +00:00
Chris Hill-Scott
d660db84b9 Merge pull request #4147 from alphagov/refactor-mixins
Refactor mixins for reuse and clearer naming
2022-02-07 09:26:23 +00:00
Chris Hill-Scott
61660134ff Bump utils to 53.0.0
Changes:

53.0.0
---

* `notifications_utils.columns.Columns` has moved to
  `notifications_utils.insensitive_dict.InsensitiveDict`
* `notifications_utils.columns.Rows` has moved to
  `notifications_utils.recipients.Rows`
* `notifications_utils.columns.Cell` has moved to
  `notifications_utils.recipients.Cell`

52.0.0
---

* Deprecate the following unused `redis_client` functions:
  - `redis_client.increment_hash_value`
  - `redis_client.decrement_hash_value`
  - `redis_client.get_all_from_hash`
  - `redis_client.set_hash_and_expire`
  - `redis_client.expire`

51.3.1
---

* Bump govuk-bank-holidays to cache holidays for next year.

51.3.0
---

* Log exception and stacktrace when Celery tasks fail.
2022-02-04 10:43:36 +00:00
Katie Smith
a7a593fd8b Make separate endpoints for GOV.UK email branding options
The endpoint to change the email branding to "GOV.UK" branding and
"GOV.UK and organisation" branding was the same but with a query string
used to determine which of the two options had been selected. This makes
them two separate endpoints, which makes the code a bit simpler and
hopefully means there is less chance of things not working as expected.
2022-02-03 11:31:25 +00:00
Katie Smith
194fec9009 Remove old branding URLs
We've changed the URLs for these endpoints but needed to keep the old
URLs in place in addition to the new URLs in case anyone was in the
middle of changing their branding as the change was being deployed.
We can now safely remove the old URLs.
2022-02-03 11:03:16 +00:00
Katie Smith
14cb883ed9 Merge pull request #4145 from alphagov/brand-new-branding
Email branding changes, step one
2022-02-03 10:27:51 +00:00
Katie Smith
c5db847543 Change both existing branding URLs
This changes the URLs for someone to request new email or letter
branding to match the new URLs we've agreed for the new email branding
changes. The old URLs are still in place for now too to keep backwards
compatibility.
2022-02-03 09:59:21 +00:00
Katie Smith
f92167de71 Only show branding description pages if branding allowed for service
It shouldn't be possible to view the page to confirm that you want a
particular type of email branding if that branding is not allowed for
your service. Although we don't show banned branding options on the
branding form, it would have been possible to visit the relevant URLs
directly.

We now give a `404` status page if you visit a page to select branding
that isn't allowed.
2022-02-03 09:59:21 +00:00
Katie Smith
f9c551a558 Add and use textarea component from GOV.UK Frontend
For the "Something else" branding form we want the form label to be the
title. This brings in the textarea component from GOV.UK Frontend in
order to do this since that contains code to set a the textarea label as
the page heading in an accessible way.

The rest of the textarea fields have not been switched to use the new
component yet.
2022-02-03 09:59:21 +00:00
Katie Smith
88a003ff72 Minor change to hint text for branding
This adds a fullstop to the hint text for all the branding forms,
as an agreed content change.
2022-02-03 09:59:21 +00:00
Katie Smith
92f76638c8 Split up email branding form into separate pages
We were showing the form to request email branding with a button which
submits your choice immediately. Now, we only submit the form
immediately if "Something else" is the only branding option available to
you. If you select any other radio button (or select "Something else"
when it's not the only option) we take you to another page which either
contains more information or a textbox to fill in the details for the
branding you want.

There is currently some duplication between the new pages and their
tests, but these will be changed in future versions of the work so will
start to differ more.
2022-02-03 09:59:21 +00:00
Katie Smith
d45265fcce Split out existing tests related to submitting branding
The existing tests were parameterized to contain the cases both where
the branding form is successfully submitted and those where it isn't. We
were using `pytest.mark.xfail` to check that the tests fail as expected
if there were errors on the form. However, since I'll be changing how
the form validation works, I want to make sure that these tests were
actually failing because of the form validation and not because of
another reason, such as a slight difference in Zendesk ticket output.

This creates separate tests for cases where data entered in the form
is invalid.
2022-02-03 09:59:21 +00:00
Katie Smith
d4454a982d Split branding-options.html into two
This splits the template into separate templates for emails and letters
since the journey for email branding is about to change.
2022-02-03 09:59:21 +00:00
Katie Smith
4226193346 Split up the branding_request endpoint
The endpoint used to handle both email and letter branding, but this
replaces `.branding_request` with `.email_branding_request` and
`.letter_branding_request` instead. This is in preparation for changing
how email branding works.

The `from_template` arg was only possible for letter branding, so I've
removed that from the `.email_branding_request` endpoint.
2022-02-03 09:59:21 +00:00
Chris Hill-Scott
caccbb98d8 Merge pull request #4150 from alphagov/pass-admin-url-reset-password
Pass admin URL to API when resetting password
2022-02-03 09:20:35 +00:00
Tom Byers
10ab1dfe72 Fix focus bug in Safari
Most browsers apply the focus style when a link is
clicked but Safari just applies the active style.
This meant our large links, with expanded click
areas, didn't get the focus style themselves but
their psuedo-elements (which create the expanded
click area) did.

This adds the focus styles to the active state of
links with the expanded click area, to ensure all
of their click area gets the focus style.
2022-02-02 20:24:14 +00:00
Tom Byers
5ad8f41123 Add large link, no hint variant to file-list
At present the file-list pattern assumes each
item has hint text below the link and so increases
the hit area to overlap the hint. This adds a
variant for items without one and uses it on the
page for choosing an alert sub-area.
2022-02-02 20:23:58 +00:00
Chris Hill-Scott
70186dbe9f Pass admin URL to API when resetting password
This follows the pattern for invite emails where the admin app tells the
API which domain to use when generating the link.
2022-02-02 16:55:44 +00:00
Rebecca Law
876c7969e1 Merge pull request #4149 from alphagov/fix-link-on-roadmap
Add missing </a> tag
2022-02-02 09:20:27 +00:00
karlchillmaid
aeabafa488 Add missing </a> tag 2022-02-02 09:09:17 +00:00
Rebecca Law
3c7f222066 Merge pull request #4148 from alphagov/add-blog-link-to-roadmap
Add a link to the Celery 5 blog post from our roadmap
2022-02-02 07:59:42 +00:00
Rebecca Law
453a1a699f Merge pull request #4107 from alphagov/mark-letter-invalid-if-over-10-sheets-169209742
Show validation-failed status for templated letters over 10 pages
2022-02-02 07:58:34 +00:00