From c81b7589573b15831c3249e6d80a670f3b3853d7 Mon Sep 17 00:00:00 2001 From: Bucky Schwarz Date: Tue, 15 Oct 2019 13:54:33 -0700 Subject: [PATCH] feat(ui): add 403 signout handler to new api requests, upgrade to oats 0.5.0 --- .gitignore | 2 +- CHANGELOG.md | 3 +++ ui/package.json | 4 ++-- ui/src/client/index.ts | 12 ++++++++++++ ui/yarn.lock | 8 ++++---- 5 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 ui/src/client/index.ts diff --git a/.gitignore b/.gitignore index 91c522e035a..f4ab4023f1e 100644 --- a/.gitignore +++ b/.gitignore @@ -43,7 +43,7 @@ ui/src/api/.openapi-generator/VERSION ui/src/api/git_push.sh # UI generated typescript types -ui/src/client/index.ts +ui/src/client/generatedRoutes.ts http/swagger_gen.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ad6e059cce..a6b9fee03c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ ### Features 1. [15313](https://github.com/influxdata/influxdb/pull/15313): Add shortcut for toggling comments in script editor +### UI Improvements +1. [15426](https://github.com/influxdata/influxdb/pull/15426): Add 403 handler that redirects back to the sign-in page on oats-generated routes. + ### Bug Fixes 1. [15295](https://github.com/influxdata/influxdb/pull/15295): Ensures users are created with an active status 1. [15306](https://github.com/influxdata/influxdb/pull/15306): Added missing string values for CacheStatus type diff --git a/ui/package.json b/ui/package.json index 0a1c778a8a7..3c54d2f02a1 100644 --- a/ui/package.json +++ b/ui/package.json @@ -37,14 +37,14 @@ "tsc:cypress": "tsc -p ./cypress/tsconfig.json --noEmit --pretty --skipLibCheck", "cy": "CYPRESS_baseUrl=http://localhost:9999 cypress open", "cy:dev": "CYPRESS_baseUrl=http://localhost:8080 cypress open", - "generate": "oats ../http/swagger.yml > src/client/index.ts" + "generate": "oats ../http/swagger.yml > src/client/generatedRoutes.ts" }, "author": "", "devDependencies": { "@babel/core": "^7.5.5", "@babel/preset-env": "^7.5.5", "@cypress/webpack-preprocessor": "^4.0.3", - "@influxdata/oats": "0.4.0", + "@influxdata/oats": "0.5.0", "@types/chroma-js": "^1.3.4", "@types/codemirror": "^0.0.56", "@types/d3-color": "^1.2.1", diff --git a/ui/src/client/index.ts b/ui/src/client/index.ts new file mode 100644 index 00000000000..ed04cd45de5 --- /dev/null +++ b/ui/src/client/index.ts @@ -0,0 +1,12 @@ +import {setResponseHandler, postSignout} from './generatedRoutes' + +setResponseHandler((status, headers, data) => { + if (status === 403) { + postSignout({}) + window.location.href = '/signin' + } + + return {status, headers, data} +}) + +export * from './generatedRoutes' diff --git a/ui/yarn.lock b/ui/yarn.lock index b2fab2abf34..f0f1d19896b 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -1107,10 +1107,10 @@ resolved "https://registry.yarnpkg.com/@influxdata/influxdb-templates/-/influxdb-templates-0.9.0.tgz#d4b1f727c8949147d2ade63f5754425a0d1a0e9d" integrity sha512-R/QhYJz+nNPGT8LkWHXKOLYYUROavDPfIFoGP7sIrxhStjm+hb0TzHYeQ75HLPQqKh54zCB8cv/TINwRgijYBw== -"@influxdata/oats@0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@influxdata/oats/-/oats-0.4.0.tgz#709b288232473140802fd1a3871f9b0f7ae49fc2" - integrity sha512-VgzO2jU0UguGFmdBEuqMM7jQS9soW0pqj251LmLKQhlFbuL9AKCAIOO6rf6OFqC3sCloduxwgZRc+Y9EprQhmQ== +"@influxdata/oats@0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@influxdata/oats/-/oats-0.5.0.tgz#0fdd308524fa407303ffa6a3d60fe959777dcfcb" + integrity sha512-oBlSB5ROM6JMqsVBDLlJzkBiMvAom+b4dszH83LPdM9H+pUtj2SeUoMpQhj9/4ioCnUVZx8HFN58/a/pkmADAQ== dependencies: commander "^2.20.0" humps "^2.0.1"