Skip to content

Commit 7a98d51

Browse files
fix(firstMile): create token once per session; allow feedback selection once (#4472)
1 parent dfbca61 commit 7a98d51

File tree

5 files changed

+65
-10
lines changed

5 files changed

+65
-10
lines changed

src/homepageExperience/components/FeedbackBar.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@ export default class FeedbackBar extends React.Component<OwnProps, State> {
3333
}
3434
}
3535

36+
// for now, we're only registering the first feedback user selects.
3637
private handleThumbsUpClick = () => {
37-
event(`firstMile.${this.props.wizardEventName}.thumbsUp.clicked`)
38-
this.setState({selectedFeedback: feedbackValue.THUMBS_UP})
38+
if (this.state.selectedFeedback === null) {
39+
event(`firstMile.${this.props.wizardEventName}.thumbsUp.clicked`)
40+
this.setState({selectedFeedback: feedbackValue.THUMBS_UP})
41+
}
3942
}
4043
private handleThumbsDownClick = () => {
41-
event(`firstMile.${this.props.wizardEventName}.thumbsDown.clicked`)
42-
this.setState({selectedFeedback: feedbackValue.THUMBS_DOWN})
44+
if (this.state.selectedFeedback === null) {
45+
event(`firstMile.${this.props.wizardEventName}.thumbsDown.clicked`)
46+
this.setState({selectedFeedback: feedbackValue.THUMBS_DOWN})
47+
}
4348
}
4449

4550
render() {

src/homepageExperience/components/steps/CreateToken.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ import {
3333

3434
type OwnProps = {
3535
wizardEventName: string
36+
setTokenValue: (tokenValue: string) => void
37+
tokenValue: string
3638
}
3739

3840
const collator = new Intl.Collator(navigator.language || 'en-US')
3941

40-
export const CreateToken: FC<OwnProps> = ({wizardEventName}) => {
42+
export const CreateToken: FC<OwnProps> = ({
43+
wizardEventName,
44+
setTokenValue,
45+
tokenValue,
46+
}) => {
4147
const org = useSelector(getOrg)
4248
const me = useSelector(getMe)
4349
const allPermissionTypes = useSelector(getAllTokensResources)
@@ -63,7 +69,7 @@ export const CreateToken: FC<OwnProps> = ({wizardEventName}) => {
6369
}, [])
6470

6571
useEffect(() => {
66-
if (sortedPermissionTypes.length) {
72+
if (sortedPermissionTypes.length && tokenValue === null) {
6773
const authorization: Authorization = {
6874
orgID: org.id,
6975
description: `onboarding-${wizardEventName}-token-${Date.now()}`,
@@ -75,12 +81,20 @@ export const CreateToken: FC<OwnProps> = ({wizardEventName}) => {
7581
}
7682
}, [sortedPermissionTypes.length])
7783

84+
// when token generated, save it to the parent component
7885
useEffect(() => {
7986
if (currentAuth.token) {
80-
setTokenTextboxText(`export INFLUXDB_TOKEN=${currentAuth.token}`)
87+
setTokenValue(currentAuth.token)
8188
}
8289
}, [currentAuth.token])
8390

91+
// when tokenValue in the parent component is not null, set text box value to tokenValue
92+
useEffect(() => {
93+
if (tokenValue !== null) {
94+
setTokenTextboxText(`export INFLUXDB_TOKEN=${tokenValue}`)
95+
}
96+
}, [tokenValue])
97+
8498
// Events log handling
8599
const logCopyCodeSnippet = () => {
86100
event(`firstMile.${wizardEventName}.createToken.code.copied`)

src/homepageExperience/containers/GoWizard.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ interface State {
3131
currentStep: number
3232
selectedBucket: string
3333
finishStepCompleted: boolean
34+
tokenValue: string
3435
}
3536

3637
export class GoWizard extends PureComponent<null, State> {
3738
state = {
3839
currentStep: 1,
3940
selectedBucket: 'my-bucket',
4041
finishStepCompleted: false,
42+
tokenValue: null,
4143
}
4244

4345
private handleSelectBucket = (bucketName: string) => {
@@ -48,6 +50,10 @@ export class GoWizard extends PureComponent<null, State> {
4850
this.setState({finishStepCompleted: true})
4951
}
5052

53+
private setTokenValue = (tokenValue: string) => {
54+
this.setState({tokenValue})
55+
}
56+
5157
handleNextClick = () => {
5258
this.setState(
5359
{
@@ -84,7 +90,13 @@ export class GoWizard extends PureComponent<null, State> {
8490
return <InstallDependencies />
8591
}
8692
case 3: {
87-
return <CreateToken wizardEventName="goWizard" />
93+
return (
94+
<CreateToken
95+
wizardEventName="goWizard"
96+
setTokenValue={this.setTokenValue}
97+
tokenValue={this.state.tokenValue}
98+
/>
99+
)
88100
}
89101
case 4: {
90102
return <InitalizeClient />

src/homepageExperience/containers/NodejsWizard.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ interface State {
3131
currentStep: number
3232
selectedBucket: string
3333
finishStepCompleted: boolean
34+
tokenValue: string
3435
}
3536

3637
export class NodejsWizard extends PureComponent<null, State> {
3738
state = {
3839
currentStep: 1,
3940
selectedBucket: 'my-bucket',
4041
finishStepCompleted: false,
42+
tokenValue: null,
4143
}
4244

4345
private handleSelectBucket = (bucketName: string) => {
@@ -48,6 +50,10 @@ export class NodejsWizard extends PureComponent<null, State> {
4850
this.setState({finishStepCompleted: true})
4951
}
5052

53+
private setTokenValue = (tokenValue: string) => {
54+
this.setState({tokenValue})
55+
}
56+
5157
handleNextClick = () => {
5258
this.setState(
5359
{
@@ -84,7 +90,13 @@ export class NodejsWizard extends PureComponent<null, State> {
8490
return <InstallDependencies />
8591
}
8692
case 3: {
87-
return <CreateToken wizardEventName="nodejsWizard" />
93+
return (
94+
<CreateToken
95+
wizardEventName="nodejsWizard"
96+
setTokenValue={this.setTokenValue}
97+
tokenValue={this.state.tokenValue}
98+
/>
99+
)
88100
}
89101
case 4: {
90102
return <InitalizeClient />

src/homepageExperience/containers/PythonWizard.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ interface State {
3131
currentStep: number
3232
selectedBucket: string
3333
finishStepCompleted: boolean
34+
tokenValue: string
3435
}
3536

3637
export class PythonWizard extends PureComponent<null, State> {
3738
state = {
3839
currentStep: 1,
3940
selectedBucket: 'my-bucket',
4041
finishStepCompleted: false,
42+
tokenValue: null,
4143
}
4244

4345
private handleSelectBucket = (bucketName: string) => {
@@ -48,6 +50,10 @@ export class PythonWizard extends PureComponent<null, State> {
4850
this.setState({finishStepCompleted: true})
4951
}
5052

53+
private setTokenValue = (tokenValue: string) => {
54+
this.setState({tokenValue})
55+
}
56+
5157
handleNextClick = () => {
5258
this.setState(
5359
{
@@ -84,7 +90,13 @@ export class PythonWizard extends PureComponent<null, State> {
8490
return <InstallDependencies />
8591
}
8692
case 3: {
87-
return <CreateToken wizardEventName="pythonWizard" />
93+
return (
94+
<CreateToken
95+
wizardEventName="pythonWizard"
96+
setTokenValue={this.setTokenValue}
97+
tokenValue={this.state.tokenValue}
98+
/>
99+
)
88100
}
89101
case 4: {
90102
return <InitalizeClient />

0 commit comments

Comments
 (0)