Comment, remove consoles, cleanup

pull/10616/head
Jared Scheib 2018-01-26 18:53:48 -08:00
parent 7134153cb5
commit 8d494d4588
5 changed files with 11 additions and 16 deletions

View File

@ -52,7 +52,6 @@ export const meChangeOrganizationFailed = () => ({
// re-hydrated. if `getMeAsync` is only being used to refresh me after creating // re-hydrated. if `getMeAsync` is only being used to refresh me after creating
// an organization, this is undesirable behavior // an organization, this is undesirable behavior
export const getMeAsync = ({shouldResetMe = false} = {}) => async dispatch => { export const getMeAsync = ({shouldResetMe = false} = {}) => async dispatch => {
console.log('getMeAsync dispatch', dispatch)
if (shouldResetMe) { if (shouldResetMe) {
dispatch(authRequested()) dispatch(authRequested())
dispatch(meGetRequested()) 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 // 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 // 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 // happening automatically because we are using a browser redirect to reload
// the application. if at some point we stop using a redirect and instead // 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 // make it a seamless SPA experience, a la issue #2463, we'll need to make sure
// links manually. // links are still refreshed.
export const meChangeOrganizationAsync = ( export const meChangeOrganizationAsync = (
url, url,
organization organization
) => async dispatch => { ) => async dispatch => {
dispatch(meChangeOrganizationRequested()) dispatch(meChangeOrganizationRequested())
try { try {
console.log('meChangeOrganizationAsync url', url)
const {data: me, auth, logoutLink} = await updateMeAJAX(url, organization) const {data: me, auth, logoutLink} = await updateMeAJAX(url, organization)
const currentRole = me.roles.find( const currentRole = me.roles.find(
r => r.organization === me.currentOrganization.id r => r.organization === me.currentOrganization.id

View File

@ -18,11 +18,9 @@ const linksGetFailed = () => ({
}) })
export const getLinksAsync = () => async dispatch => { export const getLinksAsync = () => async dispatch => {
console.log('getLinksAsync dispatch', dispatch)
dispatch(linksGetRequested()) dispatch(linksGetRequested())
try { try {
const {data} = await getLinksAJAX() const {data} = await getLinksAJAX()
console.log('getLinksAJAX links', data)
dispatch(linksGetCompleted(data)) dispatch(linksGetCompleted(data))
} catch (error) { } catch (error) {
const message = `Failed to retrieve api links from ${linksLink}` const message = `Failed to retrieve api links from ${linksLink}`

View File

@ -4,13 +4,12 @@ import {linksLink} from 'shared/constants'
export const getLinks = async () => { export const getLinks = async () => {
try { 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 return response
// call to setAJAXLinks is not necessary. see issue #1486
setAJAXLinks({updatedLinks: res.data})
return res
} catch (error) { } catch (error) {
console.error(error) console.error(error)
throw error throw error

View File

@ -14,7 +14,6 @@ import {SUPERADMIN_ROLE} from 'src/auth/Authorized'
class UserNavBlock extends Component { class UserNavBlock extends Component {
handleChangeCurrentOrganization = organizationID => async () => { handleChangeCurrentOrganization = organizationID => async () => {
const {router, links, meChangeOrganization} = this.props const {router, links, meChangeOrganization} = this.props
console.log('handleChangeCurrentOrganization', links.me)
await meChangeOrganization(links.me, {organization: organizationID}) await meChangeOrganization(links.me, {organization: organizationID})
router.push('') router.push('')
} }

View File

@ -67,8 +67,9 @@ const AJAX = async (
headers, headers,
}) })
// TODO: just return the unadulterated response, once auth, me, and // TODO: Just return the unadulterated response without grafting auth, me,
// logoutLink are refactored elsewhere // and logoutLink onto this object, once those are retrieved via their own
// AJAX request and action creator.
return links ? generateResponseWithLinks(response, links) : response return links ? generateResponseWithLinks(response, links) : response
} catch (error) { } catch (error) {
const {response} = error const {response} = error