Commit Graph

70 Commits

Author SHA1 Message Date
Chris Hill-Scott
8e1c75883a Add Leaflet.js for rendering slippy maps
Leaflet seems to be the go-to library for rendering maps these days. It
will be useful for the broadcast work.

This commit add the leaflet Javascript and CSS to our asset pipeline.
The Javascript is already minified so all we need to do is copy it. The
CSS is uncompressed so we put it through the same pipe as our other
stylesheets.

I’m keeping these as separate files because they’re quite heavy (or the
JS is at least – 38kb minified) so I want them to only be loaded on the
pages where they’re used. Most users of Notify will never need to see a
map.
2020-07-03 09:53:41 +01:00
dependabot[bot]
6b31d37fbd Bump jquery from 3.4.1 to 3.5.0
Bumps [jquery](https://github.com/jquery/jquery) from 3.4.1 to 3.5.0.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](https://github.com/jquery/jquery/compare/3.4.1...3.5.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-04-29 22:56:45 +00: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
eccd943c1a Rewrite URLs in CSS based on environment
Fix for issue that caused this revert:

https://github.com/alphagov/notifications-admin/pull/3196

Note:

gulp-css-url-adjuster operates on an Abstract
Syntax Tree (AST) derived from `main.css`. The
CSS output from this loses the compression
gulp-sass applies.

This moves compression out of Sass, to a step
after the URLs are adjusted.
2019-11-27 14:15:32 +00:00
Tom Byers
bb9b7f9005 Switch to using gulp-better-rollup
Means our rollup bundling doesn't leave any
artefact files lying around that we'd then have to
deal with.

Also includes:
- removal of some JSHint config' marking the
  artefacts as scripts to ignore
- use of streamqueue package to allow the same
  ordering of scripts as before
2019-11-27 14:15:32 +00:00
Tom Byers
e1dc6ddaef Clean up JS files created by modules build
Any files left over can effect future builds.
2019-11-27 14:15:32 +00:00
Tom Byers
cd877fe0db Add JS modules support & use for GOVUKFrontend
The JS for GOVUKFrontend components is available
individually so you can only include what you
need:

https://github.com/alphagov/govuk-frontend/blob/v2.13.0/docs/installation/installing-with-npm.md#option-2-import-javascript

This uses the JS Modules syntax:

*[JS module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)

Our JS is delivered as one file so we need to use
a bundler to convert the modules to a single file.

This adds a build step to transpile all modules
into a single file, which is then added to the
files combined into the one that get delivered.

Rollup is used as the simplest bundler to use for
this purpose. It also introduces the least
boilerplate JS.

Note: the CommonJS plugin is needed as GOV.UK
Frontend components are published as UMD modules.

In future, this work should let us work on this
story dependencies:

https://www.pivotaltracker.com/story/show/165380360
2019-11-27 14:15:32 +00:00
Tom Byers
ae27e94a35 Remove GOVUK Template files
Includes Sass that targeted GOV.UK Template HTML
and also moves some link styles to `globals.scss`.

Also removes bits of frontend build that copied
over GOVUK Template files.
2019-11-27 14:15:32 +00:00
Tom Byers
e09d510ab8 Revert "Replace govuk template with govuk frontend components - rewrite" 2019-11-26 12:14:09 +00:00
Tom Byers
0e10879ef2 Switch to using gulp-better-rollup
Means our rollup bundling doesn't leave any
artefact files lying around that we'd then have to
deal with.

Also includes:
- removal of some JSHint config' marking the
  artefacts as scripts to ignore
- use of streamqueue package to allow the same
  ordering of scripts as before
2019-11-25 11:43:30 +00:00
Tom Byers
e034f5b77a Clean up JS files created by modules build
Any files left over can effect future builds.
2019-11-25 11:43:30 +00:00
Tom Byers
85f0543b11 Add JS modules support & use for GOVUKFrontend
The JS for GOVUKFrontend components is available
individually so you can only include what you
need:

https://github.com/alphagov/govuk-frontend/blob/v2.13.0/docs/installation/installing-with-npm.md#option-2-import-javascript

This uses the JS Modules syntax:

*[JS module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)

Our JS is delivered as one file so we need to use
a bundler to convert the modules to a single file.

This adds a build step to transpile all modules
into a single file, which is then added to the
files combined into the one that get delivered.

Rollup is used as the simplest bundler to use for
this purpose. It also introduces the least
boilerplate JS.

Note: the CommonJS plugin is needed as GOV.UK
Frontend components are published as UMD modules.

In future, this work should let us work on this
story dependencies:

https://www.pivotaltracker.com/story/show/165380360
2019-11-25 11:43:30 +00:00
Tom Byers
c8de91c161 Remove GOVUK Template files
Includes Sass that targeted GOV.UK Template HTML
and also moves some link styles to `globals.scss`.

Also removes bits of frontend build that copied
over GOVUK Template files.
2019-11-25 11:43:30 +00:00
Tom Byers
e02f94f238 Revert "Replace govuk template with govuk frontend components" 2019-11-25 10:37:35 +00:00
Tom Byers
aff73293e4 Switch to using gulp-better-rollup
Means our rollup bundling doesn't leave any
artefact files lying around that we'd then have to
deal with.

Also includes:
- removal of some JSHint config' marking the
  artefacts as scripts to ignore
- use of streamqueue package to allow the same
  ordering of scripts as before
2019-11-22 17:45:45 +00:00
Tom Byers
3f420be0b7 Clean up JS files created by modules build
Any files left over can effect future builds.
2019-11-22 17:45:45 +00:00
Tom Byers
efe7e2f35e Add JS modules support & use for GOVUKFrontend
The JS for GOVUKFrontend components is available
individually so you can only include what you
need:

https://github.com/alphagov/govuk-frontend/blob/v2.13.0/docs/installation/installing-with-npm.md#option-2-import-javascript

This uses the JS Modules syntax:

*[JS module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)

Our JS is delivered as one file so we need to use
a bundler to convert the modules to a single file.

This adds a build step to transpile all modules
into a single file, which is then added to the
files combined into the one that get delivered.

Rollup is used as the simplest bundler to use for
this purpose. It also introduces the least
boilerplate JS.

Note: the CommonJS plugin is needed as GOV.UK
Frontend components are published as UMD modules.

In future, this work should let us work on this
story dependencies:

https://www.pivotaltracker.com/story/show/165380360
2019-11-22 17:45:45 +00:00
Tom Byers
278a70ecc7 Remove GOVUK Template files
Includes Sass that targeted GOV.UK Template HTML
and also moves some link styles to `globals.scss`.

Also removes bits of frontend build that copied
over GOVUK Template files.
2019-11-22 17:45:45 +00:00
Tom Byers
059fb66fae Merge pull request #3173 from alphagov/dependabot/npm_and_yarn/jquery-3.4.1
Bump jquery from 1.12.4 to 3.4.1
2019-11-11 14:23:06 +00:00
dependabot[bot]
f2b7c42f53 Bump jquery from 1.12.4 to 3.4.1
Bumps [jquery](https://github.com/jquery/jquery) from 1.12.4 to 3.4.1.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](https://github.com/jquery/jquery/compare/1.12.4...3.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2019-11-01 12:09:59 +00:00
Chris Hill-Scott
6c0e853db4 Rename module
HighlightTags was bad because:
- we haven’t called placeholders ‘tags’ for a long time
- it also does resizing of the `<textarea>`, not just highlighting the
  placeholders
2019-10-31 17:53:44 +00:00
Tom Byers
5321685a87 Add GOVUK Frontend NPM module
The GOVUK Frontend Jinja extension adds this as an
extra location to source templates from.
2019-10-07 13:12:26 +01:00
Tom Byers
0131f0c1b1 Move setup/teardown out of tests 2019-06-12 16:03:18 +01:00
Tom Byers
b11ab2c384 Remove peer dependencies
Peer dependencies are defined by projects intended
to be used by other projects (ie, libraries).

This doesn't apply to this project so removing the
peer dependencies field.

I'm also not sure why the `request` dependency was
there as it isn't a peer dependency of any of the
packages that use it in this project's dependency
tree.
2019-04-24 11:26:55 +01:00
Tom Byers
1f948cc0b4 Run Jest along with other JS tests 2019-04-24 10:46:55 +01:00
Tom Byers
2e558744a5 Add Jest and peer dependencies 2019-04-24 10:46:55 +01:00
Tom Byers
8914434573 Bump diff-dom to latest without Object.entries
Versions past this make use of Object.entries
which is not supported in IE11 (so causes an
error). This is meant to be taken care of by
polyfills but our frontend build pipeline isn't
set up to polyfill NPM modules at the moment.

This moves the version bump to the latest that
will still work with our current pipeline.
2019-04-16 13:11:24 +01:00
Tom Byers
1d88324175 Revert "Update diff-dom package to 3.1.0"
This reverts commit 01b97986f6.
2019-04-16 13:09:15 +01:00
Tom Byers
b4cc4c9bea Revert bump to library to unblock functional tests
Version 3.1.3 of govuk-elements-sass makes
everything with the `heading-small` class
`display: block`.

https://github.com/alphagov/govuk_elements/pull/552

We use that class in many places just to make the
text bold with the assumption that it the styles
it applies will not prevent our text rendering
inline. This change breaks that assumption.

We do need to swap these classes out for utility
classes that just apply the bold styles but it can
be done at a later date and we aren't missing out
on much by reverting this library.
2019-04-16 11:16:19 +01:00
Tom Byers
4766390f17 Remove gulp-load-plugins
It's not being updated at the moment and has a few
vulnerabilities listed against its dependencies.
2019-04-12 15:36:57 +01:00
Tom Byers
a8a29698cb Replace gulp-base64 with gulp-base64-inline
The gulp-base64 package has 11 dependencies with
vulnerabilities listed against them as of this
time. It also doesn't seem to be maintained any
more. The last commit was in 2015 and there are
issues and pull requests up to bump the
dependencies.

This replaces it with gulp-base64-inline.

gulp-base64-inline takes a single path, which it
prepends to any image paths it finds. Our image
paths are actually URLs, not filesystem paths so
we need to send it a relative path to repoint the
URL.

This commit includes changes that remove a few
`@import`s from one of our sass partials.

They aren't needed as those files are imported
further up the stack and `_typography.scss` has an
import in it that overwrites the new
`_url-helpers.scss` we added here.
2019-04-12 15:36:57 +01:00
Tom Byers
fa851dcfec Bump remaining NPM packages used on client-side
Means that only the following packages will now be
out of date:

1. govuk_template_jinja
2. jquery

Reasons:

GOVUK Template Jinja

This bumps it to 0.24.1, after which the only
changes are to add analytics tracking to the
GOV.UK logo and cookie banner.

We don't need to track either of these and they
were added for GOVUK analytics work.

jQuery

jQuery stops supporting IE<9 after version
1.12. This is pretty much our support now but if
we move to IE>8 we shouldn't do it by bumping the
version. This would just increase the amount of
broken JS we ship to IE8.

Also: both are deprecated and we will move off
them in the near future.
2019-04-12 15:36:57 +01:00
Tom Byers
01b97986f6 Update diff-dom package to 3.1.0
Since it moved to ES Modules in version 2.3.1,
diff-dom stopped including the `diffDOM.js` file
in its NPM package.

We don't do any kind of bundling in our build yet,
just concatenation of our scripts and some
minification of the results so we can't take
advantage of this yet.

The `diffDOM.js` file is still available in the
Github release so this moves to referencing that
in the `package.json` instead, until we start
using a bundler.

I opened an issue to check this is what the author
intended:

https://github.com/fiduswriter/diffDOM/issues/84

The latest version also adds Rollup as a peer
dependency.
2019-04-12 15:36:57 +01:00
Tom Byers
05f3cb6797 Bump JSHint 2019-04-12 15:36:57 +01:00
Tom Byers
fed3381209 Bump Babel to 7.4.0
Requires replacing `babel-preset-es2015` for
`babel-preset-env` as Babel switched to this as of
version 6:

https://babeljs.io/docs/en/babel-preset-es2015

Note: this also moves all Babel packages to using
the scoped packages syntax, descended from the
`@babel` namespace.

https://docs.npmjs.com/about-scopes
2019-04-12 15:36:57 +01:00
Tom Byers
c3a1e6ed59 Bump Gulp to 4.0.0
Brings in a new API which is a breaking change:

https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md#400

Requires gulpfile.babel.js to be a CommonJS module
and for all tasks to be exported.

Replaces using ES6 modules for the CommonJS to
include other packages to match the type of module
the gulpfile now is.

Updates to 4.0.0 include `series` and `parallel`
methods which remove the need for the
`run-sequence` package.

Also bumps gulp-specific libraries.
2019-04-12 15:36:57 +01:00
Tom Byers
c7f3b688cd Bump version of NodeJS to 10.15.3
Updates the README to reference this.

If running this locally, it's recommended to use
the 'n' NPM package to manage your version of
NodeJS, as described in the README:

https://github.com/alphagov/notifications-admin#first-time-setup
2019-04-12 15:36:57 +01:00
Tom Byers
d1c028e7d4 Add library for tracking carets in textareas 2019-03-25 15:58:23 +00:00
Chris Hill-Scott
0d3642148c Always pin to exact versions 2019-02-06 16:16:28 +00:00
Chris Hill-Scott
06a9e56589 Ensure Gulp tasks run sequentially
So that images are always copied into place before trying to build the
SASS.
2019-02-06 16:09:39 +00:00
Katie Smith
fb95e08f97 Pin patch version of govuk-elements-sass
Version 3.1.3 changed heading classes to display block - https://github.com/alphagov/govuk_elements/pull/552
This is a breaking change for us since we are using the heading classes
to make font bold - 3.1.3 adds line breaks in places where we don't want
them and causes some functional tests to fail.

Since we will be replacing govuk-elements with the new design system,
this commit pins the version of govuk-elements instead of updating all
the code to work with the lastest version.
2018-08-08 11:21:39 +01:00
Chris Hill-Scott
0b331f3e23 Upgrade GOV.UK template to newest version
Changes: https://github.com/alphagov/govuk_template/compare/v0.23.0...v0.24.0

Includes a new way of serving the font files which will:
- save us ~300kb on non-cachd requests
- speed up the parsing of the CSS file
2018-04-27 14:12:02 +01:00
snyk-bot
34bd1883c3 fix: package.json to reduce vulnerabilities
The following vulnerabilities are fixed with an upgrade:
- https://snyk.io/vuln/npm:minimatch:20160620

Latest report for alphagov/notifications-admin:
https://snyk.io/test/github/alphagov/notifications-admin
2018-03-29 02:10:58 +00:00
Chris Hill-Scott
35e7260d6f Fix bug with disappearing AJAX content in IE 9/10
We had a user report that the ‘inbound messages’ part of their dashboard
was appearing for a split second then disappearing.

This was caused by the Javascript on the page throwing an exception as
it was trying to re-render this part of the page. This meant it gave up
and rendered nothing.

The exception was caused by passing `undefined` as the second argument
to `.insertBefore`. This is acceptable in most browsers, but not older
versions of IE. This is fixed in the latest version of diffDOM (the 3rd
party library we use to do the AJAX stuff) by defaulting the second
argument to `.insertBefore` to `null`, which is acceptable in old IE
versions.

See the fix here: 8833d87e9d
2018-02-12 11:39:38 +00:00
Chris Hill-Scott
ef7a93bfde Restrict gulp-sass-lint to version 1.2.0
Version 1.3.0 introduced some breaking changes to do with file output.
Don’t have time to fix them now…
2018-01-18 10:34:29 +00:00
Chris Hill-Scott
4559fc9d29 Update NPM packages to the latest version 2018-01-17 16:50:39 +00:00
Chris Hill-Scott
48b49ebdd3 Update versions of GOV.UK packages
GOV.UK elements:
- Changelog: https://github.com/alphagov/govuk_elements/blob/master/packages/govuk-elements-sass/CHANGELOG.md#311
- Full changes: https://github.com/alphagov/govuk_elements/compare/v3.0.3...v3.1.1

GOV.UK template:
- Changelog: https://github.com/alphagov/govuk_template/blob/master/CHANGELOG.md
- Full changes: https://github.com/alphagov/govuk_template/compare/v0.19.2...v0.22.3

GOV.UK frontend toolkit:
- Changelog: https://github.com/alphagov/govuk_frontend_toolkit/blob/master/CHANGELOG.md#701
- Full changes: https://github.com/alphagov/govuk_frontend_toolkit/compare/v5.2.0...v7.0.1
2017-09-25 15:20:35 +01:00
Chris Hill-Scott
bb9fe35ab5 Upgrade GOV.UK toolkit, template and elements
We should make sure that the parts of the UI that we inherit from these
packages are kept up to date.

This commit:
- updates each dependency to the latest version
- makes patch (bug fixing) version bumps automatic because
  - it makes less work for us
  - we don’t get so far behind
  - we should be able to trust dependencies that are coming from other
    teams in this building

Full changes that this brings in:

GOV.UK Template
---

- Increase skiplink colour contrast ([GOV.UK Template PR #263](https://github.com/alphagov/govuk_template/pull/263))

GOV.UK Elements
---
- Too many to show – see
  https://github.com/alphagov/govuk_elements/compare/v1.1.1...v3.0.2#diff-4ac32a78649ca5bdd8e0ba38b7006a1e

GOV.UK Frontend Toolkit
---
- Too many to show – see
  https://github.com/alphagov/govuk_frontend_toolkit/compare/v4.6.0...v5.2.0#diff-4ac32a78649ca5bdd8e0ba38b7006a1e
2017-04-10 14:02:41 +01:00
Chris Hill-Scott
06e66cdee0 Upgrade Gulp SASS
Gulp was spitting out a lot of noise about stuff being out of date. The
cause seemed to be our outdated version of Gulp SASS. This commit
upgrades Gulp SASS to the latest version.

Changes:
---
https://github.com/dlmanning/gulp-sass/compare/v2.3.1...v3.1.0

This is a breaking change because one of the underlying libraries
includes a breaking change. But looking at their release notes, it
doesn’t seem to affect any SASS features that we’re using:

https://github.com/sass/libsass/releases/tag/3.4.0
2017-03-13 13:40:46 +00:00
Chris Hill-Scott
67e28cac7e Don’t halt Gulp watch on JS/SASS errors
Problem
---
You make a minor typo, save the file and your Gulp process dies without
you realising. You then spend 5 minutes trying to work out why your
changes aren’t appearing, no matter what edits you make.

Solution
---

Catch errors raised in processing the JS/SASS files and log them,
without killing the process.

How
---

Use a handy plugin called
[Gulp PrettyError](https://www.npmjs.com/package/gulp-prettyerror).
2017-03-13 13:17:20 +00:00