Commit Graph

11906 Commits

Author SHA1 Message Date
Tom Byers
aeaa96124c Fix node version & lock down npm version
The intention behind the version of node in the
engines property was for that version to be the
minimum required so it was always missing the `>=`
prefix.

This adds that prefix and also adds a setting for
npm, to prevent use of insecure versions. See this
article for details:

https://github.blog/2021-09-08-github-security-update-vulnerabilities-tar-npmcli-arborist/
2021-09-22 12:05:47 +01:00
Tom Byers
55287e944d Update updateContent tests to reflect its use
The way we're using the updateContent.js code is
slightly different to expected and to the
scenarios in our tests. This changes the
tests to match that use.

The expected behaviour was for updates to a
module's HTML to happen to the HTML inside of the
div[data-module=update-content] element.

So with initial HTML of:

<div data-module="update-content" data-key="one">
  <div class="ajax-block-container">
    Existing content
  </div>
</div>

...should be updated to be:

<div data-module="update-content" data-key="one">
  <div class="ajax-block-container">
    New content
  </div>
</div>

Instead the HTML returned by the AJAX requests
replaced the div[data-module=update-content]
element.

So with initial HTML of:

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

...will be updated to be:

<div class="ajax-block-container">
  New content
</div>

This doesn't seem to create any noticable changes
to the visual interface so, I think, went
unnoticed. The assumption I am making, of this
being unintended, is based on the fact that the
div[data-module=update-content] element has an
aria-live attribute, which authors would normally
want to stay in the page when updates happen.

Note: This commit doesn't try and fix the problem,
as the behaviour still largely works and the lack
of aria-live actually seems to be a positive
thing, meaning non-visual users aren't told of
every update but can discover it themselves if
needed.
2021-09-22 12:05:47 +01:00
Tom Byers
87f54d1e88 Replace diffDOM library with domdiff
A while ago diffDOM moved its code to use ES6
modules and started using various language
features specific to ES6. These two things
happened independently btw.

The result of this is that the version of diffDOM
suitable for our build pipeline, structured as an
immediately invoked function evocation (IIFE),
now requires polyfills of some ES6 features to
work in the older browsers we support, like IE11.

It's also worth noting that in the move to ES6
the maintainers of diffDOM have adopted a process
whereby users who need to support older browsers
now have to add polyfill code for any ES6 features
they choose to use.

This commmit proposes a move to the domdiff
library instead because:
- it runs on all javascript runtimes with no
  polyfills
- it is 2KB instead of diffDOM's 25KB

Domdiff takes a different approach to diffDOM, in
that it compares existing nodes and new nodes and
replaces the existing ones with the new ones if
there are differences. By contrast, diffDOM will
make in-place changes to nodes if there are enough
similarities. In other words, in most situations,
diffDOM won't change the node in $component
whereas domdiff will.

Because of this, I've had to change the
updateContent.js code to cache the data-key
attribute's value so we don't lose access to it by
overwrite the $component variable with a different
jQuery selection.
2021-09-22 12:05:47 +01:00
Tom Byers
bec77a2c66 Bump gulp-sass
Intended to deal with this security vulnerability:

https://github.blog/2021-09-08-github-security-update-vulnerabilities-tar-npmcli-arborist/

Bumping gulp-sass to version 5 removes its
dependency on the tar package mentioned in that
article.

Version 5 requires you to specify a compiler
directly in the gulpfile so that code is changed
in line with this guidance:

https://github.com/dlmanning/gulp-sass/tree/master#migrating-to-version-5

Note: node-sass is now deprecated so this also
changes the sass compiler gulp-sass uses to
dart-sass (aka 'sass'), the compiler now
recommended by the Sass project:

https://sass-lang.com/dart-sass

This also bumps gulp and all its plugin modules to
their latest versions, for parity.
2021-09-22 12:05:47 +01:00
Ben Thorner
a02596c481 Merge pull request #4025 from alphagov/fix-showing-radios-on-error
Fix showing service type radios on error
2021-09-17 15:20:31 +01:00
Ben Thorner
41f44c51fe Fix showing service type radios on error
The radio buttons to select the type of service - central, etc. -
are only shown if we can't infer the type based on the user's email
/ default organisation. However, the code to render the page in the
error case didn't accommodate this, nor did it show the version of
the page for adding a local government service.

This fixes the bug by DRYing-up the logic to render the pages. I've
not added a test for this for a couple of reasons:

- It's not a critical bug: no one has complained about it and it
doesn't block the user from adding service.

- It's unlikely to reoccur because the bug involved writing _more_
code than was necessary.

- It's not trivial to test this due to the 3 versions of the page
involved - these are tested for the happy path.
2021-09-16 12:07:03 +01:00
Leo Hemsted
6ef39e2ebf Merge pull request #4022 from alphagov/contact-list-bst
fix contact list bst bug
2021-09-15 16:48:42 +01:00
Leo Hemsted
2494d6ce31 move contact list json to a constructor
reduces some duplication
2021-09-15 15:57:49 +01:00
Leo Hemsted
9e915703fd fix contact list bst bug
the api returns UTC timestamps, we should keep them as UTC timestamps
until the very last moment, and only convert them into BST when we know
we want to return to a user (ie: in contact-list.html and other places
like that)
2021-09-15 15:12:13 +01:00
Leo Hemsted
96b91f9e1a Merge pull request #3973 from alphagov/error-handling-js-178466639
show error banner rather than alert when registering an invalid key
2021-09-15 13:57:59 +01:00
Leo Hemsted
a96bfdb16e remove server-side error messages for webauthn
since we are hard-coding a generic error message on the front-end, we
have no need to do anything on the back end. This is also nice as it
standardises the two flows to behave more like each other (rather than
previously where one would `flash` an error message and the other would
return CBOR for the js to decode).

Note that the register flow returns 400 while the auth flow returns 403.
The js for both just checks `response.ok` so will handle both. The JS
completely discards any body returned if the status isn't 200 now.
2021-09-15 11:43:41 +01:00
Leo Hemsted
2c55f4d0ce hard-code html error message for errorBanner
turns out that we're only using errorBanner with a static message, and
it's also full of rich html content. This means that it's probably
better to put it in the html templates with other content, rather than
hidden away in js files if we can help it.

Since there are two places, had to dupe the error message but i think
that's fine as i don't anticipate this error message being used in
significantly more places.

making it a string is a bit gross and means we don't get nice syntax
highlighting on it, but as it needs to be passed in to a jinja macro
that's the way it has to go unfortunately.
2021-09-14 18:43:27 +01:00
Leo Hemsted
b7e50fc638 redirect non logged in users
previously it'd show an error because non logged in users don't have the
can_use_webauthn attribute. now we can just bounce them to the sign-in
page
2021-09-14 18:43:26 +01:00
Leo Hemsted
0b27d7e0a9 show error message in banner rather than an alert
the banner is a nicer user experience, and consistent with how we
display errors elsewhere in notify. For now pass through the error
message from JS, but we'll probably want to change that since the erorr
messages themselves are often a bit cryptic and unhelpful
2021-09-14 18:43:26 +01:00
Leo Hemsted
c96a1dc0b7 add new error banner module for showing users js errors
this ensures it's reusable by other components, and easier to unit test
by isolating the separate concerns

note: this is not in Modules since that's designed for classes that are
then bound to an element in the DOM as indicated by a data-module
attribute. This will just live at the window.GOVUK level since we want
there to only ever be one `.banner-dangerous` warning.
2021-09-14 18:43:25 +01:00
Pea Tyczynska
c42fc071b5 Merge pull request #4020 from alphagov/update-service-name-hint-text
Add additional instructions for the service name
2021-09-14 12:18:46 +01:00
karlchillmaid
385a17ca8b Add additional instructions for the service name
Add additional instructions for the service name - this is more consistent with the local government version of this page

Also update tests to use the new content.
2021-09-14 12:10:14 +01:00
Ben Thorner
674f0f6258 Merge pull request #4019 from alphagov/fix-incorrect-log-message-178986763
Fix incorrect log message for dodgy broadcasts
2021-09-14 11:22:50 +01:00
Ben Thorner
0073154c04 Merge pull request #4018 from alphagov/bump-utils-46-0-0
Bump utils to 46.0.0
2021-09-14 11:22:30 +01:00
Leo Hemsted
a231738a16 Merge pull request #3989 from alphagov/update-pricing-pages
Add a billing details page
2021-09-08 16:31:38 +01:00
Ben Thorner
c694529d2d Fix incorrect log message for dodgy broadcasts
This was logging the number of keys in the whole JSON blob, rather
than the number of IDs specified within it.
2021-09-08 15:22:40 +01:00
Ben Thorner
8e99f9d0d3 Bump utils to 46.0.0
This brings in some new polygon simplication code [1] so we need to
tweak any tests that rely on the exact number of polygons after this
operation.

[1]: https://github.com/alphagov/notifications-utils/pull/890
2021-09-08 14:30:10 +01:00
Ben Thorner
5fe1e4e19d Merge pull request #4017 from alphagov/ignore-out-of-sync-areas-178986763
Support broadcasts with unidentifiable areas
2021-09-08 14:24:28 +01:00
Ben Thorner
85aeebcdd5 Support broadcasts with unidentifiable areas
The original code to raise the exception was flawed: if a broadcast
only had a single area that was invalid, we would assume it was a
custom broadcast [1]. Since the recent changes [2] fixed the flaw
we're now getting exceptions for broadcasts of this kind.

It's not practical to go and manually fix the invalid broadcasts,
and the likelihood is there will be more in future as the set of
areas we support changes. This takes a pragmatic approach of simply
logging the issue and pretending such broadcasts are custom.

[1]: 926ada2f21
[2]: https://github.com/alphagov/notifications-admin/pull/4014/files#diff-2dd8f77d6df281e7674b20263cdf27a3d58b839dc5930c0087ac8b9749b313e4R92
2021-09-08 14:05:18 +01:00
Ben Thorner
20172b11bb Merge pull request #4016 from alphagov/fix-flask-shell
Fix "flask shell" not working on PaaS instances
2021-09-08 12:56:54 +01:00
Leo Hemsted
49d1208056 remove name from copy-to-clipboard invocations
name is designed for a human readable description of what the thing
you're copying belongs to. (while thing is supposed to describe what the
value represents.

For example on the reply-to email address page, thing="ID" because
you're copying a uuid, and name is the actual name of the email address.
So the talkback speech will read out "copy ID to clipboard for
my@email.com, button".

However, in our case, there's no need to add what the context is for
since each copyable item on the page is something different (a sort
code, a VAT number, etc).

Removing the name makes the talkback just read "Copy sort code to
clipboard", which is what we want. However the macro also only shows a
header if the name is present, so we have to add the header manually.
2021-09-08 10:19:47 +01:00
Leo Hemsted
546836b22f move pricing pages to their own file 2021-09-08 10:19:46 +01:00
Leo Hemsted
86c413557c move financial deets to an environment variable
lets us keep cabinet office financials safe in the credentials repo

the dict in the creds repo will either be an empty dict or a full dict,
so the env var on paas will always contain some parseable json. But
locally it might not, so if it's not set at all then default to the
string `null` so the json parsing doesn't throw a wobbly.
2021-09-08 10:19:46 +01:00
Leo Hemsted
2b8289a5d8 update content on how-to-pay page 2021-09-08 10:19:46 +01:00
Leo Hemsted
a0adf3c63c add new billing details page
contains both signed in and signed out versions (when signed in you can
see bank details etc)
2021-09-08 10:19:42 +01:00
Leo Hemsted
85f6881a56 rename api key component to copy_to_clipboard
does what it says on the tin, and is also consistent with prior art:
https://components.publishing.service.gov.uk/component-guide/copy_to_clipboard
2021-09-08 10:18:17 +01:00
Ben Thorner
1d4326b9b2 Merge pull request #4014 from alphagov/support-custom-broadcasts-178986763
Fix areas not showing for custom broadcasts
2021-09-08 09:40:42 +01:00
Ben Thorner
e801bacad3 Fix "flask shell" not working on PaaS instances
This is consistent with API [1]. Other apps don't need this as they
follow the Flask convention of it being the "app" module or package.

[1]: https://github.com/alphagov/notifications-api/blob/master/manifest.yml.j2#L112
2021-09-07 17:46:55 +01:00
Ben Thorner
bda49a4e0c Merge pull request #4012 from alphagov/remove-migration-command-178986763
Remove redundant command to migrate areas
2021-09-07 14:20:03 +01:00
Tom Byers
8d3ec9284b Merge pull request #3996 from alphagov/improve-map-accessibility
Accessibility fixes for interactive map
2021-09-07 11:37:51 +01:00
Tom Byers
c6ecbf647a Change comment about turning part of focus style off
Co-authored-by: Ben Thorner <benthorner@users.noreply.github.com>
2021-09-07 10:10:05 +01:00
Ben Thorner
748ba2fdee Remove pointless 'list-routes' command
This is superseded by the native 'flask routes' command.
2021-09-07 09:35:45 +01:00
Ben Thorner
fd6d7f8b7a Remove redundant command to migrate areas
The data migration is now complete.
2021-09-07 09:35:03 +01:00
Ben Thorner
cf3f69199a Support new broadcasts (without area IDs)
Previously we relied on the API defaulting this field to an empty
array [1], but that conflicts with using it to decide whether a
broadcast is custom or created in this app.

[1]: 3779146cc5/app/models.py (L2342)
2021-09-06 12:40:32 +01:00
Ben Thorner
baf20e0075 Support broadcasts with no areas data
Previously we used to return an empty CustomBroadcastAreas object,
which doesn't make sense for broadcasts created in this app.
2021-09-06 12:40:31 +01:00
Ben Thorner
411fda81c0 Support custom broadcasts (without area IDs)
Custom broadcasts created directly via the API app won't have area
IDs since [1], where we started to distinguish between "names" (all
broadcasts have these) and IDs (for broadcasts created in this app).
We forgot to propagate the distinction into the code here.

This code fixes the bug for all broadcasts created after [1]. Any
custom broadcasts created before [1] will have their "ids" field set
instead of "names" so we won't show anything for them. This seems
reasonable as we don't support custom broadcasts yet.

[1]: 023a06d5fb
2021-09-06 12:40:30 +01:00
Ben Thorner
47132d28d6 Remove redundant arguments for broadcast JSON
These are set automatically.
2021-09-06 12:40:27 +01:00
Ben Thorner
bab5c21148 Rename test to include method under test 2021-09-06 12:11:42 +01:00
Ben Thorner
b3cc10ac7d Merge pull request #4011 from alphagov/fix-area-migration-command-178986763
Small fixes for command to migrate areas
2021-09-03 16:36:39 +01:00
Ben Thorner
306394e011 Small fixes for command to migrate areas
Previously there was no way to run it for reals.
2021-09-03 13:24:24 +01:00
Tom Byers
87674aef08 Fixes for the comments in the map CSS
Based on a range of comments made in the
associated pull request:
- 7c2f4adfd5 (r701234728)
- 7c2f4adfd5 (r701235330)
- 7c2f4adfd5 (r701235586)
- 7c2f4adfd5 (r701242035)
- 7c2f4adfd5 (r701241659)

Co-authored-by: Ben Thorner <benthorner@users.noreply.github.com>
2021-09-03 12:13:15 +01:00
Tom Byers
c1c80802e2 Give outline reset same precedence as for focus
The CSS that cancelled outline on focus events not
fired by the :focus-visible heuristic is being
overridden by the higher precedence of the outline
style for :focus, due to its use of !important.

This adds !important to the cancelling CSS. This
brings that block up to the same level as that for
:focus, meaning the :focus-visible styles will win
because they sit lower in the stylesheet.
2021-09-03 11:20:41 +01:00
Tom Byers
7c2f4adfd5 Refactor JS
Based on these comments on the associated pull
request:
- add area/areas condition to the array used to
  build the label prefix
  e2af2f63a4 (r55831534)
- use a for loop instead of while when looping
  through nodes
  e2af2f63a4 (r55831693)
2021-09-02 14:43:07 +01:00
Tom Byers
6de836b2f2 Rewrite map CSS comments 2021-09-02 14:43:07 +01:00
Tom Byers
ee3e3c6c90 Change how line between map buttons is styled
There is a slight variance in how the line between
the map buttons is rendered when in forced-colors
mode and when not. This is not helped by it
alternately being rendered as either:
- a gap between buttons, showing the container
  colour
- a border-bottom on the first button

This attempts to flatten these styles so it is
only styled as a gap between the buttons so
changes to how its colour renders in different
modes can just be dealt with on the container.
2021-09-02 14:43:07 +01:00