Prevent sources error notification from invalid showDatabases in CheckSources upon meChangeOrganization
parent
f32ba73dc6
commit
e1e81bee5e
|
@ -83,6 +83,20 @@ const CheckSources = React.createClass({
|
||||||
this.setState({isFetching: false})
|
this.setState({isFetching: false})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
shouldComponentUpdate(nextProps) {
|
||||||
|
const {auth: {isUsingAuth, me}} = nextProps
|
||||||
|
// don't update this component if currentOrganization is what has changed,
|
||||||
|
// or else the app will try to call showDatabases in componentWillUpdate,
|
||||||
|
// which will fail unless sources have been refreshed
|
||||||
|
if (
|
||||||
|
isUsingAuth &&
|
||||||
|
me.currentOrganization.id !== this.props.auth.me.currentOrganization.id
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
|
||||||
async componentWillUpdate(nextProps, nextState) {
|
async componentWillUpdate(nextProps, nextState) {
|
||||||
const {
|
const {
|
||||||
router,
|
router,
|
||||||
|
@ -129,6 +143,8 @@ const CheckSources = React.createClass({
|
||||||
if (!isFetching && !location.pathname.includes('/manage-sources')) {
|
if (!isFetching && !location.pathname.includes('/manage-sources')) {
|
||||||
// Do simple query to proxy to see if the source is up.
|
// Do simple query to proxy to see if the source is up.
|
||||||
try {
|
try {
|
||||||
|
// the guard around currentOrganization prevents this showDatabases
|
||||||
|
// invocation since sources haven't been refreshed yet
|
||||||
await showDatabases(source.links.proxy)
|
await showDatabases(source.links.proxy)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errorThrown(error, 'Unable to connect to source')
|
errorThrown(error, 'Unable to connect to source')
|
||||||
|
|
|
@ -73,6 +73,9 @@ export const meChangeOrganizationAsync = (
|
||||||
)
|
)
|
||||||
dispatch(meChangeOrganizationCompleted())
|
dispatch(meChangeOrganizationCompleted())
|
||||||
dispatch(meReceivedUsingAuth(data))
|
dispatch(meReceivedUsingAuth(data))
|
||||||
|
// TODO: reload sources upon me change org if non-refresh behavior preferred
|
||||||
|
// instead of current behavior on both invocations of meChangeOrganization,
|
||||||
|
// which is to refresh index via router.push('')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(errorThrown(error))
|
dispatch(errorThrown(error))
|
||||||
dispatch(meChangeOrganizationFailed())
|
dispatch(meChangeOrganizationFailed())
|
||||||
|
|
Loading…
Reference in New Issue