Skip to content

Commit 82da33d

Browse files
authored
feat: arduino firstMile scaffolding (#5273)
* feat: add arduino wizard outline
1 parent 1bf1f11 commit 82da33d

File tree

13 files changed

+725
-24
lines changed

13 files changed

+725
-24
lines changed

src/homepageExperience/components/HomepageIcons.tsx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,76 @@
11
import React from 'react'
22

33
// Language icons
4+
export const ArduinoIcon = (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
xmlnsXlink="http://www.w3.org/1999/xlink"
8+
version="1.1"
9+
id="Layer_1"
10+
x="0px"
11+
y="0px"
12+
width="108"
13+
height="66"
14+
enableBackground="new 0 0 342.394 261.395"
15+
xmlSpace="preserve"
16+
viewBox="25.84 27.72 288.36 197.67"
17+
>
18+
<g>
19+
<g>
20+
<path
21+
fill="#00878F"
22+
d="M314.2,96.221c0-37.77-31.866-68.504-71.038-68.504c-3.61,0-7.279,0.244-10.928,0.772 c-30.429,4.34-50.798,26.238-62.203,43.026c-11.432-16.788-31.797-38.686-62.23-43.026c-3.634-0.528-7.31-0.772-10.92-0.772 c-39.183,0-71.041,30.734-71.041,68.504c0,37.784,31.858,68.504,71.01,68.504c3.634,0,7.317-0.24,10.951-0.753 c30.433-4.367,50.798-26.268,62.23-43.076c11.405,16.808,31.774,38.709,62.203,43.076c3.649,0.513,7.318,0.753,10.959,0.753 C282.342,164.725,314.2,134.005,314.2,96.221 M104.363,139.916c-2.496,0.356-5.025,0.542-7.513,0.542 c-25.76,0-46.721-19.856-46.721-44.237c0-24.38,20.961-44.25,46.752-44.25c2.464,0,4.986,0.207,7.489,0.547 c28.667,4.092,46.224,32.374,52.174,43.692C150.591,107.554,133.037,135.825,104.363,139.916 M183.511,96.221 c5.95-11.329,23.487-39.611,52.162-43.703c2.487-0.34,5.029-0.547,7.489-0.547c25.776,0,46.745,19.87,46.745,44.25 c0,24.381-20.961,44.237-46.714,44.237c-2.473,0-5.009-0.186-7.52-0.542C206.998,135.825,189.445,107.538,183.511,96.221"
23+
/>
24+
<rect
25+
x="77.303"
26+
y="89.53"
27+
fill="#00878F"
28+
width="42.652"
29+
height="13.748"
30+
/>
31+
<polygon
32+
fill="#00878F"
33+
points="247.897,103.278 262.316,103.278 262.316,89.53 247.897,89.53 247.897,75.064 234.115,75.064 234.115,89.53 219.672,89.53 219.672,103.278 234.115,103.278 234.115,117.743 247.897,117.743 "
34+
/>
35+
<path
36+
fill="#00878F"
37+
d="M46.014,185.097l-12.448,39.679h10.049l2.025-8.129h11.413l2.2,8.129h10.431l-12.631-39.679H46.014z M47.531,209.031l3.599-14.53l3.917,14.53H47.531z"
38+
/>
39+
<path
40+
fill="#00878F"
41+
d="M107.086,198.348c0-7.627-4.145-13.251-15.123-13.251H75.977v39.679h9.819v-12.577h4.952l5.957,12.577 h11.6l-7.745-14.526C104.889,207.928,107.086,203.79,107.086,198.348 M90.989,204.324h-5.193v-11.203h5.002 c4.578,0,5.838,1.762,5.838,5.28C96.636,202.811,94.393,204.324,90.989,204.324"
42+
/>
43+
<path
44+
fill="#00878F"
45+
d="M128.025,185.098h-12.988v39.678h13.049c16.835,0,19.697-10.815,19.697-20.203 C147.783,192.112,142.85,185.098,128.025,185.098 M128.575,216.647h-3.722v-23.526h2.866c8.781,0,9.575,4.131,9.575,11.887 C137.294,211.71,136.69,216.647,128.575,216.647"
46+
/>
47+
<path
48+
fill="#00878F"
49+
d="M176.855,209.326c0,6.049-1.654,8.049-6.117,8.049c-3.714,0-6.045-1.52-6.045-8.103v-24.175h-9.815v26.013 c0,12.011,8.669,14.275,15.444,14.275c7.022,0,15.978-2.502,15.978-14.225v-26.063h-9.445L176.855,209.326L176.855,209.326z"
50+
/>
51+
<polygon
52+
fill="#00878F"
53+
points="195.081,193.214 205.34,193.214 205.34,216.647 195.081,216.647 195.081,224.776 225.487,224.776 225.487,216.647 215.164,216.647 215.164,193.214 225.487,193.214 225.487,185.098 195.081,185.098 "
54+
/>
55+
<polygon
56+
fill="#00878F"
57+
points="257.155,208.913 244.294,185.098 233.595,185.098 233.595,224.776 242.884,224.776 242.819,199.38 256.372,224.776 266.31,224.776 266.31,185.098 257.155,185.098 "
58+
/>
59+
<path
60+
fill="#00878F"
61+
d="M289.46,184.579c-12.032,0-16.609,8.83-16.609,20.789c0,13.129,5.25,20.018,16.655,20.018 c12.762,0,16.96-8.965,16.96-20.446C306.466,189.798,300.747,184.579,289.46,184.579 M289.506,217.376 c-5.67,0-6.228-4.011-6.228-12.008c0-9.687,0.928-12.815,6.182-12.815c5.781,0,6.58,2.698,6.58,12.387 C296.04,214.094,295.241,217.376,289.506,217.376"
62+
/>
63+
<g>
64+
<path
65+
fill="#00878F"
66+
d="M300.654,39.428c0-3.536,2.808-6.396,6.214-6.396c3.484,0,6.292,2.86,6.292,6.396 c0,3.666-2.808,6.37-6.292,6.37C303.462,45.798,300.654,42.938,300.654,39.428z M312.068,39.428c0-2.86-2.158-5.408-5.2-5.408 c-2.964,0-5.122,2.21-5.122,5.408c0,3.302,2.418,5.408,5.122,5.408C309.91,44.836,312.068,42.678,312.068,39.428z M303.904,35.372h3.094c2.418,0,3.276,1.04,3.276,2.652c0,1.092-0.52,1.924-1.508,2.34l1.508,3.043h-2.158l-1.118-2.679h-1.144 v2.679h-1.95L303.904,35.372L303.904,35.372z M306.843,39.35c0.857,0,1.403-0.312,1.403-1.326c0-0.884-0.338-1.248-1.43-1.248 h-0.962v2.574H306.843z"
67+
/>
68+
</g>
69+
</g>
70+
</g>
71+
</svg>
72+
)
73+
474
export const PythonIcon = (
575
<svg
676
width="65"
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Libraries
2+
import React, {useEffect} from 'react'
3+
4+
// Utils
5+
import {event} from 'src/cloud/utils/reporting'
6+
import {keyboardCopyTriggered, userSelection} from 'src/utils/crossPlatform'
7+
8+
const logCopyCodeSnippet = () => {
9+
event('firstMile.arduinoWizard.executeAggregateQuery.code.copied')
10+
}
11+
12+
type OwnProps = {
13+
bucket: string
14+
}
15+
16+
export const ExecuteAggregateQuery = (props: OwnProps) => {
17+
const {bucket} = props
18+
19+
useEffect(() => {
20+
const fireKeyboardCopyEvent = event => {
21+
if (
22+
keyboardCopyTriggered(event) &&
23+
userSelection().includes('influx query')
24+
) {
25+
logCopyCodeSnippet()
26+
}
27+
}
28+
document.addEventListener('keydown', fireKeyboardCopyEvent)
29+
return () => document.removeEventListener('keydown', fireKeyboardCopyEvent)
30+
}, [])
31+
32+
return <h1>Execute a Flux Aggregate Query on {bucket}</h1>
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Libraries
2+
import React, {useEffect} from 'react'
3+
4+
// Utils
5+
import {event} from 'src/cloud/utils/reporting'
6+
7+
import {keyboardCopyTriggered, userSelection} from 'src/utils/crossPlatform'
8+
9+
const logCopyCodeSnippet = () => {
10+
event('firstMile.arduinoWizard.executeQuery.code.copied')
11+
}
12+
13+
type OwnProps = {
14+
bucket: string
15+
}
16+
17+
export const ExecuteQuery = (props: OwnProps) => {
18+
const {bucket} = props
19+
20+
useEffect(() => {
21+
const fireKeyboardCopyEvent = event => {
22+
if (
23+
keyboardCopyTriggered(event) &&
24+
userSelection().includes('influx query')
25+
) {
26+
logCopyCodeSnippet()
27+
}
28+
}
29+
document.addEventListener('keydown', fireKeyboardCopyEvent)
30+
return () => document.removeEventListener('keydown', fireKeyboardCopyEvent)
31+
}, [])
32+
33+
return <h1>Execute a Flux Query on {bucket}</h1>
34+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Libraries
2+
import React, {FC, useContext, useEffect, useMemo} from 'react'
3+
import {useDispatch, useSelector} from 'react-redux'
4+
5+
// Actions
6+
import {
7+
createAuthorization,
8+
getAllResources,
9+
} from 'src/authorizations/actions/thunks'
10+
11+
// Selectors
12+
import {getOrg} from 'src/organizations/selectors'
13+
import {getMe} from 'src/me/selectors'
14+
import {getAllTokensResources} from 'src/resources/selectors'
15+
16+
// Thunks
17+
import {getBuckets} from 'src/buckets/actions/thunks'
18+
19+
// Helper Components
20+
import {WriteDataDetailsContext} from 'src/writeData/components/WriteDataDetailsContext'
21+
22+
// Utils
23+
import {allAccessPermissions} from 'src/authorizations/utils/permissions'
24+
import {event} from 'src/cloud/utils/reporting'
25+
import {keyboardCopyTriggered, userSelection} from 'src/utils/crossPlatform'
26+
27+
// Types
28+
import {AppState, Authorization} from 'src/types'
29+
30+
// Styles
31+
import './ArduinoSteps.scss'
32+
33+
type OwnProps = {
34+
setTokenValue: (tokenValue: string) => void
35+
tokenValue: string
36+
onSelectBucket: (bucketName: string) => void
37+
}
38+
39+
const collator = new Intl.Collator(navigator.language || 'en-US')
40+
41+
export const InitializeClient: FC<OwnProps> = ({
42+
setTokenValue,
43+
tokenValue,
44+
onSelectBucket,
45+
}) => {
46+
const org = useSelector(getOrg)
47+
const me = useSelector(getMe)
48+
const allPermissionTypes = useSelector(getAllTokensResources)
49+
const dispatch = useDispatch()
50+
51+
const currentAuth = useSelector((state: AppState) => {
52+
return state.resources.tokens.currentAuth.item
53+
})
54+
55+
const sortedPermissionTypes = useMemo(
56+
() => allPermissionTypes.sort((a, b) => collator.compare(a, b)),
57+
[allPermissionTypes]
58+
)
59+
const {bucket} = useContext(WriteDataDetailsContext)
60+
61+
useEffect(() => {
62+
dispatch(getBuckets())
63+
}, []) // eslint-disable-line react-hooks/exhaustive-deps
64+
65+
useEffect(() => {
66+
onSelectBucket(bucket.name)
67+
}, [bucket.name, onSelectBucket])
68+
69+
useEffect(() => {
70+
const fetchResources = async () => {
71+
await dispatch(getAllResources())
72+
}
73+
fetchResources()
74+
}, [])
75+
76+
useEffect(() => {
77+
if (sortedPermissionTypes.length && tokenValue === null) {
78+
const authorization: Authorization = {
79+
orgID: org.id,
80+
description: `onboarding-arduinoWizard-token-${Date.now()}`,
81+
permissions: allAccessPermissions(sortedPermissionTypes, org.id, me.id),
82+
}
83+
84+
dispatch(createAuthorization(authorization))
85+
event(`firstMile.arduinoWizard.tokens.tokenCreated`)
86+
}
87+
}, [sortedPermissionTypes.length])
88+
89+
// when token generated, save it to the parent component
90+
useEffect(() => {
91+
if (currentAuth.token) {
92+
setTokenValue(currentAuth.token)
93+
}
94+
}, [currentAuth.token])
95+
96+
useEffect(() => {
97+
const fireKeyboardCopyEvent = event => {
98+
if (
99+
keyboardCopyTriggered(event) &&
100+
(userSelection().includes('influx config create') ||
101+
userSelection().includes('influx bucket create'))
102+
) {
103+
logCopyCodeSnippet()
104+
}
105+
}
106+
document.addEventListener('keydown', fireKeyboardCopyEvent)
107+
return () => document.removeEventListener('keydown', fireKeyboardCopyEvent)
108+
}, [])
109+
110+
// Events log handling
111+
const logCopyCodeSnippet = () => {
112+
event(`firstMile.arduinoWizard.buckets.code.copied`)
113+
}
114+
115+
return <h1>Initialize Client</h1>
116+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import {
2+
ComponentColor,
3+
Button,
4+
ButtonGroup,
5+
Orientation,
6+
} from '@influxdata/clockface'
7+
8+
import React, {FC, useEffect, useState} from 'react'
9+
import {useDispatch} from 'react-redux'
10+
import {getBuckets} from 'src/buckets/actions/thunks'
11+
import {event} from 'src/cloud/utils/reporting'
12+
import {keyboardCopyTriggered, userSelection} from 'src/utils/crossPlatform'
13+
14+
export const InstallDependencies: FC = () => {
15+
const dispatch = useDispatch()
16+
17+
useEffect(() => {
18+
dispatch(getBuckets())
19+
}, [])
20+
21+
const headingWithMargin = {marginTop: '48px', marginBottom: '0px'}
22+
23+
const logCopyCodeSnippet = OS => {
24+
event(`firstMile.cliWizard.installDependencies${OS}.code.copied`)
25+
}
26+
27+
type CurrentOSSelection = 'Linux' | 'Mac' | 'Windows'
28+
const [currentSelection, setCurrentSelection] = useState<CurrentOSSelection>(
29+
'Mac'
30+
)
31+
32+
useEffect(() => {
33+
const fireKeyboardCopyEvent = event => {
34+
if (
35+
keyboardCopyTriggered(event) &&
36+
userSelection().includes('brew install')
37+
) {
38+
logCopyCodeSnippet('Mac')
39+
}
40+
if (
41+
keyboardCopyTriggered(event) &&
42+
(userSelection().includes('Expand-Archive') ||
43+
userSelection().includes('mv'))
44+
) {
45+
logCopyCodeSnippet('Windows')
46+
}
47+
if (
48+
keyboardCopyTriggered(event) &&
49+
(userSelection().includes('wget') ||
50+
userSelection().includes('tar') ||
51+
userSelection().includes('sudo'))
52+
) {
53+
logCopyCodeSnippet('Linux')
54+
}
55+
}
56+
document.addEventListener('keydown', fireKeyboardCopyEvent)
57+
return () => document.removeEventListener('keydown', fireKeyboardCopyEvent)
58+
}, [])
59+
60+
return (
61+
<>
62+
<h1>Install Dependencies</h1>
63+
<ButtonGroup orientation={Orientation.Horizontal}>
64+
<Button
65+
text="mac OS"
66+
color={
67+
currentSelection === 'Mac'
68+
? ComponentColor.Primary
69+
: ComponentColor.Default
70+
}
71+
onClick={() => {
72+
setCurrentSelection('Mac')
73+
}}
74+
/>
75+
<Button
76+
text="windows"
77+
color={
78+
currentSelection === 'Windows'
79+
? ComponentColor.Primary
80+
: ComponentColor.Default
81+
}
82+
onClick={() => {
83+
setCurrentSelection('Windows')
84+
}}
85+
/>
86+
<Button
87+
text="linux"
88+
color={
89+
currentSelection === 'Linux'
90+
? ComponentColor.Primary
91+
: ComponentColor.Default
92+
}
93+
onClick={() => {
94+
setCurrentSelection('Linux')
95+
}}
96+
/>
97+
</ButtonGroup>
98+
{currentSelection === 'Mac' && (
99+
<>
100+
<h2 style={headingWithMargin}>Use Homebrew</h2>
101+
</>
102+
)}
103+
{currentSelection === 'Windows' && (
104+
<>
105+
<h2 style={headingWithMargin}>Download the CLI package</h2>
106+
</>
107+
)}
108+
{currentSelection === 'Linux' && (
109+
<>
110+
<h2 style={headingWithMargin}>Download from the command line</h2>
111+
</>
112+
)}
113+
</>
114+
)
115+
}

0 commit comments

Comments
 (0)