Skip to content

Commit a50d0b6

Browse files
authored
feat(aim): Add Reactivate Org Button (#6347)
* chore(aim): Add Reactivate Org Button * fix(aim): Move styles to consts * chore(aim): Fix OpenAPI SHA
1 parent 49f95ab commit a50d0b6

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"cy": "CYPRESS_dexUrl=https://$INGRESS_HOST:$PORT_HTTPS CYPRESS_baseUrl=http://localhost:9999 cypress open",
5353
"cy:dev": "source ../monitor-ci/.env && CYPRESS_dexUrl=CLOUD CYPRESS_baseUrl=https://$INGRESS_HOST:$PORT_HTTPS cypress open --config testFiles='{cloud,shared}/**/*.*'",
5454
"cy:dev-oss": "source ../monitor-ci/.env && CYPRESS_dexUrl=OSS CYPRESS_baseUrl=https://$INGRESS_HOST:$PORT_HTTPS cypress open --config testFiles='{oss,shared}/**/*.*'",
55-
"generate": "export SHA=c8f13fab276fa7af3dd925870e493e973e2df93f && export REMOTE=https://raw.githubusercontent.com/influxdata/openapi/${SHA}/ && yarn generate-meta",
55+
"generate": "export SHA=66183531c4681177eec11759a912c736af2d48e4 && export REMOTE=https://raw.githubusercontent.com/influxdata/openapi/${SHA}/ && yarn generate-meta",
5656
"generate-local": "export REMOTE=../openapi/ && yarn generate-meta",
5757
"generate-local-cloud": "export REMOTE=../openapi/ && yarn generate-meta-cloud",
5858
"generate-meta": "if [ -z \"${CLOUD_URL}\" ]; then yarn generate-meta-oss; else yarn generate-meta-cloud; fi",

src/operator/OrgOverlay.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,29 @@ import LimitsField from 'src/operator/LimitsField'
3434
// Constants
3535
import {TOOLS_URL} from 'src/shared/constants'
3636

37+
const viewUsageButtonStyles = {marginRight: '12px'}
38+
const reactivateOrgButtonStyles = {marginTop: '8px'}
39+
3740
const OrgOverlay: FC = () => {
3841
const {
3942
limits,
4043
limitsStatus,
4144
handleGetLimits,
4245
handleGetOrg,
46+
handleReactivateOrg,
4347
handleUpdateLimits,
4448
organization,
4549
orgStatus,
50+
reactivateOrgStatus,
4651
setLimits,
4752
updateLimitStatus,
4853
} = useContext(OverlayContext)
4954
const {hasWritePermissions} = useContext(OperatorContext)
5055

5156
const {orgID} = useParams<{orgID: string}>()
5257
const history = useHistory()
58+
const canReactivateOrg =
59+
hasWritePermissions && organization?.state === 'suspended'
5360

5461
useEffect(() => {
5562
handleGetLimits(orgID)
@@ -71,6 +78,11 @@ const OrgOverlay: FC = () => {
7178
}
7279
}
7380

81+
const reactivateOrg = async () => {
82+
await handleReactivateOrg(orgID)
83+
history.goBack()
84+
}
85+
7486
return (
7587
<Overlay
7688
visible={true}
@@ -111,8 +123,26 @@ const OrgOverlay: FC = () => {
111123
text="View Usage Dashboard"
112124
target={LinkTarget.Blank}
113125
className="overlay-button--link"
126+
style={viewUsageButtonStyles}
114127
href={`${TOOLS_URL}orgs/5d59ccc5163fc318/dashboards/0988da0fd78a7003?vars%5Borgid%5D=${orgID}`}
115128
/>
129+
{canReactivateOrg && (
130+
<ButtonBase
131+
color={ComponentColor.Primary}
132+
shape={ButtonShape.Default}
133+
size={ComponentSize.Medium}
134+
onClick={reactivateOrg}
135+
style={reactivateOrgButtonStyles}
136+
status={
137+
reactivateOrgStatus === RemoteDataState.Loading
138+
? ComponentStatus.Disabled
139+
: ComponentStatus.Default
140+
}
141+
testID="org-overlay-reactivate-organization--button"
142+
>
143+
Reactivate Organization
144+
</ButtonBase>
145+
)}
116146
</Grid.Column>
117147
</Grid.Row>
118148
<Grid.Row>

src/operator/context/overlay.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {useDispatch} from 'react-redux'
66
import {
77
getOperatorOrgsLimits,
88
getOperatorOrg,
9+
postOperatorOrgsReactivate,
910
putOperatorOrgsLimits,
1011
} from 'src/client/unityRoutes'
1112
import {notify} from 'src/shared/actions/notifications'
@@ -14,6 +15,8 @@ import {
1415
getLimitsError,
1516
updateLimitsError,
1617
updateLimitsSuccess,
18+
reactivateOrgError,
19+
reactivateOrgSuccess,
1720
} from 'src/shared/copy/notifications'
1821
import {toDisplayLimits} from 'src/operator/utils'
1922

@@ -30,21 +33,25 @@ export interface OverlayContextType {
3033
limitsStatus: RemoteDataState
3134
handleGetLimits: (id: string) => void
3235
handleGetOrg: (id: string) => void
36+
handleReactivateOrg: (id: string) => void
3337
handleUpdateLimits: (id: string, limits: OperatorOrgLimits) => void
3438
organization: OperatorOrg
3539
orgStatus: RemoteDataState
40+
reactivateOrgStatus: RemoteDataState
3641
setLimits: (_: OperatorOrgLimits) => void
3742
updateLimitStatus: RemoteDataState
3843
}
3944

4045
export const DEFAULT_CONTEXT: OverlayContextType = {
4146
handleGetLimits: (_: string) => {},
4247
handleGetOrg: (_: string) => {},
48+
handleReactivateOrg: (_id: string) => {},
4349
handleUpdateLimits: (_id: string, _limits: OperatorOrgLimits) => {},
4450
limits: null,
4551
limitsStatus: RemoteDataState.NotStarted,
4652
organization: null,
4753
orgStatus: RemoteDataState.NotStarted,
54+
reactivateOrgStatus: RemoteDataState.NotStarted,
4855
setLimits: (_: OperatorOrgLimits) => {},
4956
updateLimitStatus: RemoteDataState.NotStarted,
5057
}
@@ -55,6 +62,9 @@ export const OverlayContext =
5562
export const OverlayProvider: FC<Props> = React.memo(({children}) => {
5663
const [limits, setLimits] = useState(null)
5764
const [limitsStatus, setLimitsStatus] = useState(RemoteDataState.NotStarted)
65+
const [reactivateOrgStatus, setReactivateOrgStatus] = useState(
66+
RemoteDataState.NotStarted
67+
)
5868
const [updateLimitStatus, setUpdateLimitStatus] = useState(
5969
RemoteDataState.NotStarted
6070
)
@@ -109,6 +119,21 @@ export const OverlayProvider: FC<Props> = React.memo(({children}) => {
109119
[dispatch]
110120
)
111121

122+
const handleReactivateOrg = useCallback(
123+
async (id: string) => {
124+
try {
125+
setReactivateOrgStatus(RemoteDataState.Loading)
126+
await postOperatorOrgsReactivate({orgId: id})
127+
setReactivateOrgStatus(RemoteDataState.Done)
128+
dispatch(notify(reactivateOrgSuccess(id)))
129+
} catch (error) {
130+
console.error(error)
131+
dispatch(notify(reactivateOrgError(id)))
132+
}
133+
},
134+
[dispatch]
135+
)
136+
112137
const handleUpdateLimits = useCallback(
113138
async (id: string, updatedLimits: OperatorOrgLimits) => {
114139
try {
@@ -129,11 +154,13 @@ export const OverlayProvider: FC<Props> = React.memo(({children}) => {
129154
value={{
130155
handleGetLimits,
131156
handleGetOrg,
157+
handleReactivateOrg,
132158
handleUpdateLimits,
133159
limits,
134160
limitsStatus,
135161
organization,
136162
orgStatus,
163+
reactivateOrgStatus,
137164
setLimits,
138165
updateLimitStatus,
139166
}}

src/shared/copy/notifications/categories/operator.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ export const getOrgError = (id: string): Notification => ({
1919
message: `Could not find organization with ID ${id}`,
2020
})
2121

22+
export const reactivateOrgSuccess = (id: string): Notification => ({
23+
...defaultSuccessNotification,
24+
duration: FIVE_SECONDS,
25+
message: `Successfully reactivated organization with the ID ${id}`,
26+
})
27+
28+
export const reactivateOrgError = (id: string): Notification => ({
29+
...defaultErrorNotification,
30+
duration: FIVE_SECONDS,
31+
message: `Could not reactivate organization with ID ${id}`,
32+
})
33+
2234
export const getLimitsError = (id: string): Notification => ({
2335
...defaultErrorNotification,
2436
duration: FIVE_SECONDS,

0 commit comments

Comments
 (0)