Skip to content

Commit

Permalink
fix: Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
abshierjoel committed Jul 5, 2023
1 parent 0d6bdde commit 7a9d186
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 23 deletions.
11 changes: 7 additions & 4 deletions src/operator/MigrateOrg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ import {
import React, {ChangeEvent, FC, useContext, useState} from 'react'
import {OverlayContext} from 'src/operator/context/overlay'
import {OperatorAccount, getOperatorAccount} from 'src/client/unityRoutes'
import MigrateOrgOverlay from './MigrateOrgOverlay'
import {MigrateOrgOverlay} from './MigrateOrgOverlay'
import {useDispatch} from 'react-redux'
import {notify} from 'src/shared/actions/notifications'
import {getAccountError} from 'src/shared/copy/notifications'

const MigrateOrg: FC = () => {
export const MigrateOrg: FC = () => {
const {organization, setMigrateOverlayVisible} = useContext(OverlayContext)
const [toAccountId, setToAccountId] = useState('')
const [toAccount, setToAccount] = useState<OperatorAccount>(null)
const dispatch = useDispatch()

const changeToAccountId = (event: ChangeEvent<HTMLInputElement>) => {
setToAccountId(event.target.value)
Expand All @@ -32,6 +36,7 @@ const MigrateOrg: FC = () => {
try {
const resp = await getOperatorAccount({accountId: toAccountId})
if (resp.status !== 200) {
dispatch(notify(getAccountError(toAccountId)))
return
}
setToAccount(resp.data)
Expand Down Expand Up @@ -79,5 +84,3 @@ const MigrateOrg: FC = () => {
</>
)
}

export default MigrateOrg
8 changes: 4 additions & 4 deletions src/operator/MigrateOrgOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ interface Props {

const MigrateOrgOverlay: FC<Props> = ({toAccount}) => {
const {
organization,
migrateOverlayVisible,
setMigrateOverlayVisible,
handleMigrateOrg,
migrateOverlayVisible,
migrateStatus,
organization,
setMigrateOverlayVisible,
} = useContext(OverlayContext)

const migrateOrg = () => {
Expand Down Expand Up @@ -89,4 +89,4 @@ const MigrateOrgOverlay: FC<Props> = ({toAccount}) => {
)
}

export default MigrateOrgOverlay
export {MigrateOrgOverlay}
6 changes: 2 additions & 4 deletions src/operator/OrgOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import LimitsField from 'src/operator/LimitsField'

// Constants
import {TOOLS_URL} from 'src/shared/constants'
import MigrateOrg from './MigrateOrg'
import {MigrateOrg} from './MigrateOrg'

const viewUsageButtonStyles = {marginRight: '12px'}
const reactivateOrgButtonStyles = {marginTop: '8px'}

const OrgOverlay: FC = () => {
export const OrgOverlay: FC = () => {
const {
limits,
limitsStatus,
Expand Down Expand Up @@ -399,5 +399,3 @@ const OrgOverlay: FC = () => {
</Overlay>
)
}

export default OrgOverlay
2 changes: 1 addition & 1 deletion src/operator/account/AccountView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import AccountViewHeader from 'src/operator/account/AccountViewHeader'
import AccountGrid from 'src/operator/account/AccountGrid'
import {AccountContext} from 'src/operator/context/account'
import PageSpinner from 'src/perf/components/PageSpinner'
import MigrateOrgsTool from './MigrateOrgs'
import {MigrateOrgsTool} from './MigrateOrgs'

const AccountView: FC = () => {
const {account, accountStatus} = useContext(AccountContext)
Expand Down
19 changes: 15 additions & 4 deletions src/operator/account/MigrateOrgs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ import {
FlexBox,
FlexDirection,
Form,
InfluxColors,
Input,
Label,
} from '@influxdata/clockface'
import React, {ChangeEvent, FC, useContext, useState} from 'react'
import {AccountContext} from '../context/account'
import MigrateOrgsOverlay from './MigrateOrgsOverlay'
import {MigrateOrgsOverlay} from './MigrateOrgsOverlay'
import {OperatorAccount, getOperatorAccount} from 'src/client/unityRoutes'
import {useDispatch} from 'react-redux'
import {notify} from 'src/shared/actions/notifications'
import {getAccountError} from 'src/shared/copy/notifications'

const MigrateOrgsTool: FC = () => {
export const MigrateOrgsTool: FC = () => {
const {account, setMigrateOverlayVisible} = useContext(AccountContext)
const [toAccountId, setToAccountId] = useState('')
const [toAccount, setToAccount] = useState<OperatorAccount>(null)
const dispatch = useDispatch()

const changeToAccountId = (event: ChangeEvent<HTMLInputElement>) => {
setToAccountId(event.target.value)
Expand All @@ -32,6 +38,7 @@ const MigrateOrgsTool: FC = () => {
try {
const resp = await getOperatorAccount({accountId: toAccountId})
if (resp.status !== 200) {
dispatch(notify(getAccountError(toAccountId)))
return
}
setToAccount(resp.data)
Expand All @@ -57,6 +64,12 @@ const MigrateOrgsTool: FC = () => {
alignItems={AlignItems.FlexStart}
margin={ComponentSize.Large}
>
<Label
id="accounts-migrate--account-id-label"
name="Please enter an Account ID to migrate to:"
description="Please enter an Account ID to migrate to:"
color={InfluxColors.Grey25}
/>
<Input
placeholder="Account ID to migrate resources to"
inputStyle={{width: '400px'}}
Expand All @@ -81,5 +94,3 @@ const MigrateOrgsTool: FC = () => {
</>
)
}

export default MigrateOrgsTool
8 changes: 3 additions & 5 deletions src/operator/account/MigrateOrgsOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ interface Props {
toAccount: OperatorAccount
}

const MigrateOrgsOverlay: FC<Props> = ({toAccount}) => {
export const MigrateOrgsOverlay: FC<Props> = ({toAccount}) => {
const {
account,
organizations,
migrateStatus,
handleMigrateOrgs,
setMigrateOverlayVisible,
migrateOverlayVisible,
migrateStatus,
setMigrateOverlayVisible,
} = useContext(AccountContext)

const migrateAccountOrgs = () => {
Expand Down Expand Up @@ -101,5 +101,3 @@ const MigrateOrgsOverlay: FC<Props> = ({toAccount}) => {
</Overlay>
)
}

export default MigrateOrgsOverlay
2 changes: 1 addition & 1 deletion src/operator/context/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ export const AccountProvider: FC<Props> = React.memo(({children}) => {
throw new Error(resp.data.message)
}

setMigrateOverlayVisible(false)
setMigrateStatus(RemoteDataState.Done)
setMigrateOverlayVisible(false)
history.push(`/operator/accounts/${toAccountId}`)
} catch (error) {
console.error({error})
Expand Down

0 comments on commit 7a9d186

Please sign in to comment.