Commit Graph

285 Commits

Author SHA1 Message Date
Tom Byers
dfcddb757e Revert "Re-introduce govuk checkboxes" 2020-07-15 13:41:34 +01:00
Tom Byers
e6e81ec2fe Add mixin & field to make collapsible checkboxes
Allows checkboxes to be collapsed so they take up
less space in the page. The collapsed state
includes a live summary tracking which of them are
selected.

Includes changes to the JS for collapsible
checkboxes to make it work with the GOVUK
Checkboxes component HTML.
2020-07-14 10:41:09 +01:00
Tom Byers
f0f461f5c9 Revert "Change checkboxes to GOVUK frontend" 2020-05-14 16:59:34 +01:00
Tom Byers
06027b447c Add mixin & field to make collapsible checkboxes
Allows checkboxes to be collapsed so they take up
less space in the page. The collapsed state
includes a live summary tracking which of them are
selected.

Includes changes to the JS for collapsible
checkboxes to make it work with the GOVUK
Checkboxes component HTML.
2020-05-13 16:16:21 +01:00
Chris Hill-Scott
8da16468ff Delay the initial AJAX call by 2 seconds
At the moment the first AJAX call is triggered as soon as the page
loads. We then look at its response time to work out how long to wait
until making the next call.

This isn’t great because:
- stuff is unlikely to have changed straight away, so it’s a waste of a
  call
- while the DOM is being updated it seems to introduce a delay in
  clicks on links, which is either more pronounced or more noticeable
  when it’s happening straight away, making the UI feel less snappy

I chose a value of 2 seconds as a rough proxy for the minimum time we’d
expect to see a notification go from created to delivered. Median
time-to-delivered was 2.9 seconds when we analysed it for
https://github.com/alphagov/notifications-admin/pull/2974#discussion_r286101286
2020-04-16 13:21:24 +01:00
Chris Hill-Scott
a2929ad748 Delay AJAX calls if the server is slow to respond
By default our AJAX calls were 2 seconds. Then they were 5 seconds
because someone reckoned 2 seconds was putting too much load on the
system. Then we made them 10 seconds while we were having an incident.
Then we made them 20 seconds for the heaviest pages, but back to 5
seconds or 2 seconds for the rest of the pages.

This is not a good situation because:
- it slows all services down equally, no  matter how much traffic they
  have, or which features they have  switched on
- it slows everything down by the same amount, no matter how much load
  the platform is under
- the values are set based on our worst performance, until we manually
  remember to switch them back
- we spend time during incidents deploying changes to slow down the
  dashboard refresh time because it’s a nothing-to-lose change that
  might relieve some symptoms, when we could be spending time digging
  into the underlying cause

This pull request makes the Javascript smarter about how long it waits
until it makes another AJAX call. It bases the delay on how long the
server takes to respond (as a proxy for how much load the server is
under).

It’s based on the square root of the response time, so is more sensitive
to slow downs early on, and less sensitive to slow downs later on. This
helps us give a more pronounced difference in delay between an AJAX call
that is fast (for example the page for a single notification) and one
that is slow (for example a dashboard for a service with lots of
traffic).

*Some examples of what this would mean for various pages*

Page | Response time | Wait until next AJAX call
---|---|---
Check a reply to address | 130ms | 1,850ms
Brand new service dashboard | 229ms | 2,783ms
HM Passport Office dashboard | 634ms | 5,294ms
NHS Coronavirus Service dashboard | 779ms | 5,977ms
_Example of the kind of slowness we’ve seen during an incident_ | 6,000ms | 18,364ms
GOV.UK email dashboard | `HTTP 504` | 😬
2020-04-09 12:05:18 +01:00
Tom Byers
6d620dd283 Fix timestamp used for clearing old cookies
The code in the test that added the 'old' cookies
uses Greenwich Mean Time (GMT) format:

https://github.com/alphagov/notifications-admin/blob/master/tests/javascripts/support/helpers/cookies.js#L19

The code that cleared any 'old' cookies doesn't
specify a time format so uses that set on the host
OS:

https://github.com/alphagov/notifications-admin/blob/master/app/assets/javascripts/cookieMessage.js#L12
https://github.com/alphagov/notifications-admin/blob/master/app/assets/javascripts/cookieMessage.js#L19

Cookies are deleted by setting the data to one
that has expired. Because of the hour difference
the date set to make the cookies expire didn't
work.

This fixes that by making the clearing up code use
GMT.
2020-04-08 08:51:53 +01:00
Katie Smith
076d99c9dc Replace column-full with govuk-grid-column-full 2020-03-06 11:11:41 +00:00
Katie Smith
b9b9a138f9 Replace grid-row with govuk-grid-row
Replaced all instances of `grid-row` in the HTML and JavaScript with
`govuk-grid-row`, which is the new GOV.UK Frontend class.
2020-03-06 11:11:41 +00:00
Leo Hemsted
1558d05be7 ensure highlighting div size always matches the relevant textarea 2020-03-05 16:38:26 +00:00
Tom Byers
346c4aa7f3 Update links in JavaScript 2020-02-25 10:47:30 +00:00
Tom Byers
5b306dde4d Revert "Convert all links to govuk frontend" 2020-02-24 11:56:38 +00:00
Tom Byers
97172cca30 Merge branch 'master' into convert-all-links-to-govuk-frontend 2020-02-24 10:12:58 +00:00
Tom Byers
8a98c73b08 Make analytics send the same title for all pages
Sets it on the tracker which means this value gets
sent for each:
- pageview
- event

See: https://developers.google.com/analytics/devguides/collection/analyticsjs/pages

We can only test that this has been set on the
tracker, not how that effects what is sent to GA,
in the JS tests.

This change has been tested in-browser with the
Chrome Analytics Debugger. This revealed the
contents of what is in the beacon sent to GA and
allowed confirmation the title was being set
correctly.

See: https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna/related
2020-02-20 11:46:19 +00:00
Tom Byers
c094f31b2b Update links in JavaScript 2020-02-20 09:11:26 +00:00
Katie Smith
e53a97423b Update radio-select to use govuk-frontend buttons 2020-02-17 08:05:05 +00:00
Katie Smith
0d0b71af63 Update buttons on api key pages to govuk-frontend buttons 2020-02-17 08:05:05 +00:00
Katie Smith
e53c5e17b3 Update file upload component to use govuk-frontend buttons 2020-02-17 08:05:05 +00:00
Katie Smith
2cbfaf1b6f Update the buttons on template folder form 2020-02-17 08:05:05 +00:00
Katie Smith
583a925e89 Add buttons for list entries
As part of updating the stylesheet, moved `.button-secondary` to the
global stylesheet, since this is not related to list entries but instead
affects all buttons with that class (this class wlil be removed once all
the buttons are using the new macro).
2020-02-17 08:05:05 +00:00
Katie Smith
4e42fa6f5d Update buttons for collapsible checkboxes
We use collapsible checkboxes when setting which folders team members
can see (on the manage folder page and on the edit team member page).
2020-02-17 08:05:05 +00:00
Katie Smith
66967e1d96 Import / require all code for the govuk frontend button 2020-02-17 08:05:05 +00:00
Tom Byers
6c2af9e696 Set cookie on document host by removing domain
Cookies using the hostname as a domain will be set
with a prefix of `.` by browsers, it seems to
ensure all subdomains are included in the scope.

When deleting the `seen_cookie_message` cookie we
want to set its domain without a `.` prefix, to
match the domain set by the original code.

Leaving the `domain` attribute out from the cookie
string will ensure the `.` prefix is not set.
2020-01-23 13:17:40 +00:00
Tom Byers
d68403f7dc Merge pull request #3272 from alphagov/stop-removing-ga-cookies
Stop removing GA cookies
2020-01-23 11:32:42 +00:00
Tom Byers
174c10c7ff Clear old cookies to be based on consent
We have been clearing all the Google Analytics
cookies on each page request.

It is now possible for a user to consent to having
Google Analytics cookies so this should have been
checking for that before deleting them.

This makes that change, with tests for those
scenarios.
2020-01-22 12:14:23 +00:00
Tom Byers
0885dde2c1 Update Google Analytics tracker config
Removes the following fields from the tracker
config:
- `name`, which was erroring due to it
  including a `.`
- `displayFeaturesTask` which seems to be
  deprecated

Also refactors the `create` command to put all
fields into the options parameter, as shown in the
developer docs:

https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers
2020-01-22 12:10:01 +00:00
Tom Byers
5de29f2389 Fix Google Analytics tracking code 2020-01-20 10:05:15 +00:00
Tom Byers
a67cd65f47 Make Google Analytics cookies expire in 1 year 2020-01-20 10:05:06 +00:00
Tom Byers
1d9c5e5da9 Default the cookie banner to be hidden
It should only be shown if JS is available and the
cookieMessage JS finds consent has not been set.
2020-01-20 10:04:58 +00:00
Tom Byers
1a97c6028c Add event tracking to window.GOVUK.analytics
app/assets/javascripts/errorTracking.js sent
events to `window.ga`.

This extends the API of `window.GOVUK.Analytics`
to include support for sending events so all
calls to `window.ga` can use it instead of direct
access.

This use of `window.ga` was missed from the
initial work on `window.GOVUK.Anaytics`.
2020-01-20 10:04:56 +00:00
Tom Byers
34b85cae10 Update cookies page
Includes:
- new content
- added option to turn analytics on/off
- non-js version for the on/off switch
- a banner to confirm user's choice was saved,
  shown when they click the save button
- the cookie banner that appears on all other
  pages removed from this page
2020-01-20 10:03:19 +00:00
Tom Byers
1d864943c5 Move code for deleting old cookies into banner JS
Removes the following cookies:
- seen_cookie_message (flags if banner was already
  shown)
- _gid (Google Analytics cookie)
- _ga (Google Analytics cookie)

These were set by default before so potentially
still around for some users.

The code for this now exists as a static method on
the cookieMessage module and is called when the JS
loads for the first time.
2020-01-20 10:03:19 +00:00
Tom Byers
fa7104d6c8 Add new cookie banner code.
Copies HTML and Sass from GOV.UK Pubishing
components cookie-banner with changes to content
and functionality to better suit Notify.

Changes are:
- adds a 'reject' button which the GOV.UK
  code doesn't have
- adds Sass from the GOV.UK Frontend button
  component which the GOV.UK version used so
  is included here
- removed click tracking from cookie banner
2020-01-20 10:03:18 +00:00
Tom Byers
181adc9940 On page load, call analytics based on consent 2020-01-20 10:03:18 +00:00
Tom Byers
0ecbff6a8b Add consent tracking to cookie functions
Taken from GOVUK components:

https://github.com/alphagov/govuk_publishing_components/blob/master/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js

Also includes:
- make new cookie functions handle notify domains
- addition of hasConsentFor function to allow easy
  checking of consent for categories of cookie
2020-01-20 10:03:18 +00:00
Tom Byers
a8d6df9b04 Wrap analytics code in GOVUK interface
Wraps our analytics code in a stripped down
version of GOVUK.Analytics to allow us to plug in
the GOVUK code for consent.
2020-01-20 10:03:18 +00:00
Leo Hemsted
66db735e09 Revert "Merge pull request #3238 from alphagov/cookies-update"
This reverts commit eec4bec761, reversing
changes made to 64480e2fff.
2020-01-15 14:40:48 +00:00
Tom Byers
749e199e63 Fix Google Analytics tracking code 2020-01-15 11:56:38 +00:00
Tom Byers
dce6a46df6 Make Google Analytics cookies expire in 1 year 2020-01-14 14:16:00 +00:00
Tom Byers
c18cb1e984 Default the cookie banner to be hidden
It should only be shown if JS is available and the
cookieMessage JS finds consent has not been set.
2020-01-14 12:11:40 +00:00
Tom Byers
b6e37a6ac8 Add event tracking to window.GOVUK.analytics
app/assets/javascripts/errorTracking.js sent
events to `window.ga`.

This extends the API of `window.GOVUK.Analytics`
to include support for sending events so all
calls to `window.ga` can use it instead of direct
access.

This use of `window.ga` was missed from the
initial work on `window.GOVUK.Anaytics`.
2020-01-14 11:28:06 +00:00
Tom Byers
ce52746f74 Update cookies page
Includes:
- new content
- added option to turn analytics on/off
- non-js version for the on/off switch
- a banner to confirm user's choice was saved,
  shown when they click the save button
- the cookie banner that appears on all other
  pages removed from this page
2020-01-03 17:28:33 +00:00
Tom Byers
f46dba8948 Move code for deleting old cookies into banner JS
Removes the following cookies:
- seen_cookie_message (flags if banner was already
  shown)
- _gid (Google Analytics cookie)
- _ga (Google Analytics cookie)

These were set by default before so potentially
still around for some users.

The code for this now exists as a static method on
the cookieMessage module and is called when the JS
loads for the first time.
2020-01-03 17:28:33 +00:00
Tom Byers
3a6537f49f Add new cookie banner code.
Copies HTML and Sass from GOV.UK Pubishing
components cookie-banner with changes to content
and functionality to better suit Notify.

Changes are:
- adds a 'reject' button which the GOV.UK
  code doesn't have
- adds Sass from the GOV.UK Frontend button
  component which the GOV.UK version used so
  is included here
- removed click tracking from cookie banner
2020-01-03 17:28:33 +00:00
Tom Byers
c3c5faad54 On page load, call analytics based on consent 2020-01-03 17:28:33 +00:00
Tom Byers
8fd9686c3d Add consent tracking to cookie functions
Taken from GOVUK components:

https://github.com/alphagov/govuk_publishing_components/blob/master/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js

Also includes:
- make new cookie functions handle notify domains
- addition of hasConsentFor function to allow easy
  checking of consent for categories of cookie
2020-01-03 17:28:33 +00:00
Tom Byers
0954435afb Wrap analytics code in GOVUK interface
Wraps our analytics code in a stripped down
version of GOVUK.Analytics to allow us to plug in
the GOVUK code for consent.
2020-01-03 17:28:33 +00:00
Tom Byers
afd3fe5781 Include details JS 2019-12-17 10:28:14 +00:00
Tom Byers
84f90a7e1c Remove redundant details polyfill
We're now using the GOV.UK Frontend one.
2019-12-17 10:27:15 +00:00
Tom Byers
de6281bc0e Revert "Add GOVUK Frontend details component" 2019-12-16 16:20:03 +00:00