influxdb/server
Timothy J. Raymond 67c2b98f68 Redirect to default source when deleting sources (#1074)
* Redirect to default source on invalid source ID

When supplied with an invalid source ID, the CheckSources component
would redirect the user to a "Create Source" page. This caused
surprising behavior when a source was deleted because that source ID
would become invalid. The effect being that deleting a source brought
users immediately to the create source page, rather than back to the
sources list.

This instead redirects users to the default source when provided an
invalid source id. The backend automatically re-assigns the "default"
source, so this will always succeed, since sources are fetched again
from the backend.

The regex used is slightly dependent on URL structure that has been
stable over the lifetime of this project. Also it relies on URL
structure more than the previous redirecting implementation.

* Force sources to reload after deletion

Deleting a source invalidates the state held by the client because of
automatic re-assignment of the default source by the backend. Without
duplicating backend logic, it is impossible for the frontend to discover
the new source without reloading sources.

The ManageSources page now uses an async-action creator which deletes
the requested source and reloads all sources. The source action creators
have also been refactored to use implicit returns like other action
creators.

* Remove Dead removeSource action

removeSource is no longer used because the API invalidates its
assumptions. For more information, see 04bf3ca.

* Update Changelog with source deletion redirect fix

Users are no longer unexpectedly redirected to the "create source" page
whenever they delete a source that they are connected to.

* Return 404 when deleting non-existent source

When deleting a source, a new default is assigned automatically. If a
non-existent source ID was provided, previously this would result in a
500. This is a violation of the Swagger docs. The solution is to examine
the error and if it was an ErrSourceNotFound, invoke the notFound
handler.

* Add Error handling to source deletion

There are two kinds of errors that can be encountered when deleting a
source: a 404 and a 500 (from either the delete or the subsequent
fetch).

The 404 is a precondition failure of the action creator. The source.id
requested can be non-existent for two reasons: 1) The action creator was
passed garbage by the caller. 2) A concurrent write occurred which
silently invalidated this session's state. For the first case, we can
ensure that the caller is sane by having an assertion check that the
requested source is among some set of sources. This could be
circumvented by a caller, but chances are good that both the full set of
sources and the desired source are both available to callers of this
action creator. The second case is not an error. In this case, we should
proceed reloading sources, since the deletion that was requested has
already been performed by someone else.

Finally, 500s can only occur if there is something broken with the API.
In this situation, we provide a notification that tells the user to
check the API logs for more information.

* Remove duplicate CHANGELOG entries

These were introduced due to a naive merge conflict resolution.

* Remove assertion

This was decided to be confusing and unnecessary.

* Remove remnants of removed assertion

These were needed for an assertion that has been removed. It's no longer
necessary to pass `sources` to the action creator.
2017-03-28 08:53:11 -07:00
..
assets.go Move URLPrefixer setup to mux, add default 2017-01-27 19:14:21 -05:00
dashboards.go Fix go dependency breaking master build 2017-03-24 13:34:56 -07:00
dashboards_test.go Create a new dashboard cell; Fix remaining bugs with Overlay (#1056) 2017-03-23 17:50:21 -07:00
databases.go Update rpResponse default to isDefault 2017-03-24 10:06:59 -07:00
databases_test.go Update RP JSON default to isDefault 2017-03-24 09:58:57 -07:00
hsts.go Add HSTS handler to add headers for upcoming TLS support 2017-02-12 18:21:49 -06:00
influx.go Enhance server logging for connection errors 2017-02-24 00:34:50 -06:00
kapacitors.go Update comments for go vet 2017-02-21 21:35:24 -06:00
layout.go Remove explorations from backend server 2017-02-01 15:09:02 -06:00
layout_test.go Refactor to remove autogenerated code. 2016-10-26 22:10:52 -05:00
logger.go Fix mux paths to be hardcoded; clarify server start; fix golint 2016-10-28 11:27:06 -05:00
logout.go Add unified OAuth2 logout route redirecting to provider logout 2017-02-15 16:29:13 -06:00
mappings.go Add server error logging 2016-11-19 11:41:06 -06:00
me.go Update user/role responses to return empty arrays 2017-03-10 13:24:48 -06:00
me_test.go Update user/role responses to return empty arrays 2017-03-10 13:24:48 -06:00
mux.go Merge pull request #1029 from influxdata/feature/db-manager 2017-03-24 10:57:12 -07:00
permissions.go Update user/role responses to return empty arrays 2017-03-10 13:24:48 -06:00
permissions_test.go Update user/role responses to return empty arrays 2017-03-10 13:24:48 -06:00
proxy.go Refactor proxy into influx 2017-02-17 14:02:02 -06:00
redoc.go Miscellaneous lint cleanup 2016-12-20 12:59:56 -08:00
roles.go Update roles to check if role already exists 2017-03-10 17:24:52 -06:00
roles_test.go Update roles to check if role already exists 2017-03-10 17:24:52 -06:00
routes.go Merge branch 'master' into feature/#54-tr-enterprise-client 2017-02-23 23:26:09 -06:00
server.go Merge pull request #1029 from influxdata/feature/db-manager 2017-03-24 10:57:12 -07:00
service.go Add retention policies to the database response 2017-03-23 13:53:28 -07:00
sources.go Redirect to default source when deleting sources (#1074) 2017-03-28 08:53:11 -07:00
sources_test.go Fix sources test to include databases link 2017-03-23 14:06:52 -07:00
swagger.go Miscellaneous lint cleanup 2016-12-20 12:59:56 -08:00
swagger.json Merge pull request #1029 from influxdata/feature/db-manager 2017-03-24 10:57:12 -07:00
url_prefixer.go Add structured logging to underlying http server 2017-03-06 15:16:45 -06:00
url_prefixer_test.go Make prefixer support multiple tags, chunked enc 2017-01-27 17:00:08 -05:00
users.go Update user's roles validation 2017-03-10 18:06:06 -06:00
users_test.go Update user/role responses to return empty arrays 2017-03-10 13:24:48 -06:00
version.go Update to fix go linter issues 2017-03-06 10:11:52 -06:00