From 8d494d4588aabe5eea9aea6d957a12b2453cc7fa Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Fri, 26 Jan 2018 18:53:48 -0800 Subject: [PATCH] Comment, remove consoles, cleanup --- ui/src/shared/actions/auth.js | 8 +++----- ui/src/shared/actions/links.js | 2 -- ui/src/shared/apis/links.js | 11 +++++------ ui/src/side_nav/components/UserNavBlock.js | 1 - ui/src/utils/ajax.js | 5 +++-- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/ui/src/shared/actions/auth.js b/ui/src/shared/actions/auth.js index d590520b4e..5e9913f4da 100644 --- a/ui/src/shared/actions/auth.js +++ b/ui/src/shared/actions/auth.js @@ -52,7 +52,6 @@ export const meChangeOrganizationFailed = () => ({ // re-hydrated. if `getMeAsync` is only being used to refresh me after creating // an organization, this is undesirable behavior export const getMeAsync = ({shouldResetMe = false} = {}) => async dispatch => { - console.log('getMeAsync dispatch', dispatch) if (shouldResetMe) { dispatch(authRequested()) dispatch(meGetRequested()) @@ -79,16 +78,15 @@ export const getMeAsync = ({shouldResetMe = false} = {}) => async dispatch => { // Global links state also needs to be refreshed upon organization change so // that Admin Chronograf / Current Org User tab's link is valid, but this is // happening automatically because we are using a browser redirect to reload -// the application. if at some point we stop using a redirect and instead -// make it a seamless SPA experience, a la issue #2463, we'll need to refresh -// links manually. +// the application. If at some point we stop using a redirect and instead +// make it a seamless SPA experience, a la issue #2463, we'll need to make sure +// links are still refreshed. export const meChangeOrganizationAsync = ( url, organization ) => async dispatch => { dispatch(meChangeOrganizationRequested()) try { - console.log('meChangeOrganizationAsync url', url) const {data: me, auth, logoutLink} = await updateMeAJAX(url, organization) const currentRole = me.roles.find( r => r.organization === me.currentOrganization.id diff --git a/ui/src/shared/actions/links.js b/ui/src/shared/actions/links.js index cea3259fb7..a9f90397d0 100644 --- a/ui/src/shared/actions/links.js +++ b/ui/src/shared/actions/links.js @@ -18,11 +18,9 @@ const linksGetFailed = () => ({ }) export const getLinksAsync = () => async dispatch => { - console.log('getLinksAsync dispatch', dispatch) dispatch(linksGetRequested()) try { const {data} = await getLinksAJAX() - console.log('getLinksAJAX links', data) dispatch(linksGetCompleted(data)) } catch (error) { const message = `Failed to retrieve api links from ${linksLink}` diff --git a/ui/src/shared/apis/links.js b/ui/src/shared/apis/links.js index c0f93c4915..00523d70e2 100644 --- a/ui/src/shared/apis/links.js +++ b/ui/src/shared/apis/links.js @@ -4,13 +4,12 @@ import {linksLink} from 'shared/constants' export const getLinks = async () => { try { - const res = await getAJAX(linksLink) + const response = await getAJAX(linksLink) + // TODO: Remove use of links entirely from within AJAX function so that + // call to setAJAXLinks is not necessary. See issue #1486. + setAJAXLinks({updatedLinks: response.data}) - // TODO: remove use of links entirely from within AJAX function so that - // call to setAJAXLinks is not necessary. see issue #1486 - setAJAXLinks({updatedLinks: res.data}) - - return res + return response } catch (error) { console.error(error) throw error diff --git a/ui/src/side_nav/components/UserNavBlock.js b/ui/src/side_nav/components/UserNavBlock.js index 8208daf7e1..4883dcf96e 100644 --- a/ui/src/side_nav/components/UserNavBlock.js +++ b/ui/src/side_nav/components/UserNavBlock.js @@ -14,7 +14,6 @@ import {SUPERADMIN_ROLE} from 'src/auth/Authorized' class UserNavBlock extends Component { handleChangeCurrentOrganization = organizationID => async () => { const {router, links, meChangeOrganization} = this.props - console.log('handleChangeCurrentOrganization', links.me) await meChangeOrganization(links.me, {organization: organizationID}) router.push('') } diff --git a/ui/src/utils/ajax.js b/ui/src/utils/ajax.js index 08e1745b2b..b298213ff9 100644 --- a/ui/src/utils/ajax.js +++ b/ui/src/utils/ajax.js @@ -67,8 +67,9 @@ const AJAX = async ( headers, }) - // TODO: just return the unadulterated response, once auth, me, and - // logoutLink are refactored elsewhere + // TODO: Just return the unadulterated response without grafting auth, me, + // and logoutLink onto this object, once those are retrieved via their own + // AJAX request and action creator. return links ? generateResponseWithLinks(response, links) : response } catch (error) { const {response} = error