Skip to content

Commit 60a91b5

Browse files
authored
feat: allow users to select bucket in cli wizard (#5126)
* feat: allow users to select bucket in cli wizard
1 parent 89d9ac6 commit 60a91b5

File tree

2 files changed

+59
-16
lines changed

2 files changed

+59
-16
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.small-margins {
2+
margin-top: 0px;
3+
margin-bottom: 8px;
4+
}
5+
6+
.large-margins {
7+
margin-top: 48px;
8+
margin-bottom: 8px;
9+
}

src/homepageExperience/components/steps/cli/InitializeClient.tsx

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Libraries
2-
import React, {FC, useEffect, useMemo} from 'react'
2+
import React, {FC, useContext, useEffect, useMemo} from 'react'
33
import {useDispatch, useSelector} from 'react-redux'
44

55
// Actions
@@ -13,8 +13,20 @@ import {getOrg} from 'src/organizations/selectors'
1313
import {getMe} from 'src/me/selectors'
1414
import {getAllTokensResources} from 'src/resources/selectors'
1515

16+
// Thunks
17+
import {getBuckets} from 'src/buckets/actions/thunks'
18+
1619
// Helper Components
1720
import CodeSnippet from 'src/shared/components/CodeSnippet'
21+
import {
22+
Columns,
23+
ComponentSize,
24+
Grid,
25+
InfluxColors,
26+
Panel,
27+
} from '@influxdata/clockface'
28+
import WriteDataHelperBuckets from 'src/writeData/components/WriteDataHelperBuckets'
29+
import {WriteDataDetailsContext} from 'src/writeData/components/WriteDataDetailsContext'
1830

1931
// Utils
2032
import {allAccessPermissions} from 'src/authorizations/utils/permissions'
@@ -23,17 +35,14 @@ import {event} from 'src/cloud/utils/reporting'
2335
// Types
2436
import {AppState, Authorization} from 'src/types'
2537

38+
// Styles
39+
import './CliSteps.scss'
40+
2641
type OwnProps = {
2742
wizardEventName: string
2843
setTokenValue: (tokenValue: string) => void
2944
tokenValue: string
30-
}
31-
32-
// Style
33-
34-
const inlineStyle = {
35-
marginTop: '0px',
36-
marginBottom: '8px',
45+
onSelectBucket: (bucketName: string) => void
3746
}
3847

3948
const collator = new Intl.Collator(navigator.language || 'en-US')
@@ -42,22 +51,22 @@ export const InitializeClient: FC<OwnProps> = ({
4251
wizardEventName,
4352
setTokenValue,
4453
tokenValue,
54+
onSelectBucket,
4555
}) => {
4656
const org = useSelector(getOrg)
4757
const me = useSelector(getMe)
4858
const allPermissionTypes = useSelector(getAllTokensResources)
4959
const dispatch = useDispatch()
5060
const url =
5161
me.quartzMe?.clusterHost || 'https://us-west-2-1.aws.cloud2.influxdata.com/'
52-
const orgID = org.id
5362
const currentAuth = useSelector((state: AppState) => {
5463
return state.resources.tokens.currentAuth.item
5564
})
5665
const token = currentAuth.token
5766

5867
const codeSnippet = `influx config create --config-name onboarding
5968
--host-url "${url}"
60-
--org "${orgID}"
69+
--org "${org.id}"
6170
--token "${token}"
6271
--active`
6372

@@ -67,6 +76,15 @@ export const InitializeClient: FC<OwnProps> = ({
6776
() => allPermissionTypes.sort((a, b) => collator.compare(a, b)),
6877
[allPermissionTypes]
6978
)
79+
const {bucket} = useContext(WriteDataDetailsContext)
80+
81+
useEffect(() => {
82+
dispatch(getBuckets())
83+
}, []) // eslint-disable-line react-hooks/exhaustive-deps
84+
85+
useEffect(() => {
86+
onSelectBucket(bucket.name)
87+
}, [bucket, onSelectBucket])
7088

7189
useEffect(() => {
7290
const fetchResources = async () => {
@@ -103,8 +121,8 @@ export const InitializeClient: FC<OwnProps> = ({
103121
return (
104122
<>
105123
<h1>Initialize Client</h1>
106-
<h2 style={inlineStyle}>Configure an InfluxDB profile</h2>
107-
<p style={inlineStyle}>
124+
<h2 className="small-margins">Configure an InfluxDB profile</h2>
125+
<p className="small-margins">
108126
Next we'll need to configure the client and its initial connection to
109127
InfluxDB.
110128
</p>
@@ -123,10 +141,26 @@ export const InitializeClient: FC<OwnProps> = ({
123141
recommend using a token with more specific permissions in the long-term.
124142
You can edit your tokens anytime from the app.
125143
</p>
126-
<h2 style={{marginTop: '48px', marginBottom: '8px'}}>Create a bucket</h2>
127-
<p style={inlineStyle}>
128-
Now we'll create a bucket. A <b>bucket</b> is used to store time-series
129-
data. We'll link the bucket to the profile you created.
144+
<h2 className="large-margins">Select or Create a bucket</h2>
145+
<p className="small-margins">
146+
A <b>bucket</b> is used to store time-series data. Here is a list of
147+
your existing buckets. You can select one to use for the rest of the
148+
tutorial, or create one below.
149+
</p>
150+
<Panel backgroundColor={InfluxColors.Grey15}>
151+
<Panel.Body size={ComponentSize.ExtraSmall}>
152+
<Grid>
153+
<Grid.Row>
154+
<Grid.Column widthSM={Columns.Twelve}>
155+
<WriteDataHelperBuckets useSimplifiedBucketForm={true} />
156+
</Grid.Column>
157+
</Grid.Row>
158+
</Grid>
159+
</Panel.Body>
160+
</Panel>
161+
<p className="large-margins">
162+
We can also create a bucket using the InfluxCLI. We'll link the bucket
163+
to the profile you created.
130164
</p>
131165
<CodeSnippet
132166
text={bucketSnippet}

0 commit comments

Comments
 (0)