Skip to content

Commit f65dce7

Browse files
authored
feat: version viewing is now a thing (#3901)
1 parent 0bf6a5d commit f65dce7

File tree

22 files changed

+434
-34
lines changed

22 files changed

+434
-34
lines changed

src/alerting/components/AlertingIndex.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {event} from 'src/cloud/utils/reporting'
3737

3838
const alertsPath = '/orgs/:orgID/alerting'
3939
import {AppSettingContext} from 'src/shared/contexts/app'
40+
import {PROJECT_NAME} from 'src/flows'
4041

4142
type ActiveColumn = 'checks' | 'endpoints' | 'rules'
4243

@@ -78,7 +79,10 @@ const AlertingIndex: FunctionComponent = () => {
7879
<Icon glyph={IconFont.BookPencil} />
7980
Now you can use Notebooks to explore your data while building an
8081
alert
81-
<Link to="/notebook/from/notification" onClick={recordClick}>
82+
<Link
83+
to={`/${PROJECT_NAME.toLowerCase()}/from/notification`}
84+
onClick={recordClick}
85+
>
8286
Create an Alert
8387
</Link>
8488
<span className="header-cta--close-icon" onClick={hideFlowsCTA}>

src/buckets/components/BucketCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import BucketCardActions from 'src/buckets/components/BucketCardActions'
1010

1111
// Constants
1212
import {isSystemBucket} from 'src/buckets/constants/index'
13+
import {PROJECT_NAME} from 'src/flows'
1314

1415
// Utils
1516
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
@@ -37,7 +38,7 @@ const BucketCard: FC<Props & RouteComponentProps<{orgID: string}>> = ({
3738
}) => {
3839
const handleNameClick = () => {
3940
if (isFlagEnabled('exploreWithFlows')) {
40-
history.push(`/notebook/from/bucket/${bucket.name}`)
41+
history.push(`/${PROJECT_NAME.toLowerCase()}/from/bucket/${bucket.name}`)
4142
} else {
4243
history.push(`/orgs/${orgID}/data-explorer?bucket=${bucket.name}`)
4344
}

src/dashboards/components/dashboard_index/DashboardCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {getMe} from 'src/me/selectors'
5757
import {getOrg} from 'src/organizations/selectors'
5858
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
5959
import {CLOUD} from 'src/shared/constants'
60+
import {PROJECT_NAME} from 'src/flows'
6061

6162
interface OwnProps {
6263
id: string
@@ -237,7 +238,7 @@ class DashboardCard extends PureComponent<Props> {
237238
},
238239
} = this.props
239240

240-
let dest = `/notebook/from/dashboard/${id}`
241+
let dest = `/${PROJECT_NAME.toLowerCase()}/from/dashboard/${id}`
241242

242243
if (!isFlagEnabled('boardWithFlows')) {
243244
dest = `/orgs/${orgID}/dashboards/${id}`

src/dataExplorer/components/DataExplorerPage.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {ResourceType} from 'src/types'
2525

2626
import 'src/shared/components/cta.scss'
2727
import {AppSettingContext} from 'src/shared/contexts/app'
28+
import {PROJECT_NAME} from 'src/flows'
2829

2930
const DataExplorerPage: FC = () => {
3031
const {flowsCTA, setFlowsCTA} = useContext(AppSettingContext)
@@ -66,7 +67,10 @@ const DataExplorerPage: FC = () => {
6667
<Icon glyph={IconFont.BookPencil} />
6768
Now you can use Notebooks to explore and take action on your
6869
data
69-
<Link to="/notebook/from/default" onClick={recordClick}>
70+
<Link
71+
to={`/${PROJECT_NAME.toLowerCase()}/from/default`}
72+
onClick={recordClick}
73+
>
7074
Create a Notebook
7175
</Link>
7276
<span className="header-cta--close-icon" onClick={hideFlowsCTA}>

src/flows/components/FromTemplatePage.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
OverlayController,
3030
} from 'src/overlays/components/OverlayController'
3131
import EngagementLink from 'src/cloud/components/onboarding/EngagementLink'
32+
import {PROJECT_NAME, PROJECT_NAME_PLURAL} from '..'
3233

3334
const Template: FC = () => {
3435
const {add} = useContext(FlowListContext)
@@ -62,7 +63,9 @@ const Template: FC = () => {
6263
populate(data)
6364
} else {
6465
add(data).then(id => {
65-
history.replace(`/orgs/${org.id}/notebooks/${id}`)
66+
history.replace(
67+
`/orgs/${org.id}/${PROJECT_NAME_PLURAL.toLowerCase()}/${id}`
68+
)
6669
})
6770
}
6871
})
@@ -99,7 +102,10 @@ const FromTemplatePage: FC = () => {
99102
<FlowListProvider>
100103
<FlowProvider>
101104
<Switch>
102-
<Route path="/notebook/from/*" component={Template} />
105+
<Route
106+
path={`/${PROJECT_NAME.toLowerCase()}/from/*`}
107+
component={Template}
108+
/>
103109
<Route component={NotFound} />
104110
</Switch>
105111
</FlowProvider>
@@ -113,7 +119,10 @@ const FromTemplatePage: FC = () => {
113119
return (
114120
<FlowListProvider>
115121
<Switch>
116-
<Route path="/notebook/from/*" component={Template} />
122+
<Route
123+
path={`/${PROJECT_NAME.toLowerCase()}/from/*`}
124+
component={Template}
125+
/>
117126
<Route component={NotFound} />
118127
</Switch>
119128
</FlowListProvider>

src/flows/components/PresetFlows.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,28 @@ import {
99
} from '@influxdata/clockface'
1010
import {useHistory} from 'react-router-dom'
1111
import FlowsExplainer from 'src/flows/components/FlowsExplainer'
12+
import {PROJECT_NAME} from 'src/flows'
1213
export const PRESET_MAP = [
13-
{title: 'New Notebook', href: '/notebook/from/default', testID: 'new'},
14-
{title: 'Set an Alert', href: '/notebook/from/notification', testID: 'alert'},
15-
{title: 'Schedule a Task', href: '/notebook/from/task', testID: 'task'},
16-
{title: 'Write a Flux Script', href: '/notebook/from/flux', testID: 'script'},
14+
{
15+
title: 'New Notebook',
16+
href: `/${PROJECT_NAME.toLowerCase()}/from/default`,
17+
testID: 'new',
18+
},
19+
{
20+
title: 'Set an Alert',
21+
href: `/${PROJECT_NAME.toLowerCase()}/from/notification`,
22+
testID: 'alert',
23+
},
24+
{
25+
title: 'Schedule a Task',
26+
href: `/${PROJECT_NAME.toLowerCase()}/from/task`,
27+
testID: 'task',
28+
},
29+
{
30+
title: 'Write a Flux Script',
31+
href: `/${PROJECT_NAME.toLowerCase()}/from/flux`,
32+
testID: 'script',
33+
},
1734
]
1835

1936
const PresetFlows: FC = () => {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Libraries
2+
import React, {FC, useContext} from 'react'
3+
import {DapperScrollbars, Page} from '@influxdata/clockface'
4+
import {useParams} from 'react-router'
5+
6+
// Contexts
7+
import {VersionFlowProvider} from 'src/flows/context/version.read'
8+
import {FlowQueryProvider} from 'src/flows/context/flow.query'
9+
import QueryProvider from 'src/shared/contexts/query'
10+
import {PopupDrawer, PopupProvider} from 'src/flows/context/popup'
11+
import {ResultsProvider} from 'src/flows/context/results'
12+
import {SidebarProvider} from 'src/flows/context/sidebar'
13+
import {FlowContext} from 'src/flows/context/flow.current'
14+
15+
// Components
16+
import ReadOnlyPipeList from 'src/flows/components/ReadOnlyPipeList'
17+
import {SubSideBar} from 'src/flows/components/Sidebar'
18+
import VersionHeader from 'src/flows/components/header/VersionHeader'
19+
import NotFound from 'src/shared/components/NotFound'
20+
21+
import 'src/flows/style.scss'
22+
import 'src/flows/shared/Resizer.scss'
23+
import '@influxdata/clockface/dist/index.css'
24+
25+
const ReadOnly: FC = ({children}) => {
26+
const {flow} = useContext(FlowContext)
27+
const {id} = useParams<{id: string}>()
28+
if (!id || !flow) {
29+
return (
30+
<div style={{width: '100%'}}>
31+
<NotFound />
32+
</div>
33+
)
34+
}
35+
return <>{children}</>
36+
}
37+
38+
const ReadOnlyFlowPage: FC = () => {
39+
const {flow} = useContext(FlowContext)
40+
41+
return (
42+
<Page titleTag={flow.name + ' (Shared) | InfluxDB Cloud'}>
43+
<VersionHeader />
44+
<Page.Contents fullWidth={true} scrollable={false} className="flow-page">
45+
<PopupProvider>
46+
<DapperScrollbars
47+
noScrollX
48+
thumbStartColor="gray"
49+
thumbStopColor="gray"
50+
>
51+
<ReadOnlyPipeList />
52+
</DapperScrollbars>
53+
<SubSideBar />
54+
<PopupDrawer />
55+
</PopupProvider>
56+
</Page.Contents>
57+
</Page>
58+
)
59+
}
60+
61+
const FlowContainer: FC = () => (
62+
<VersionFlowProvider>
63+
<ReadOnly>
64+
<QueryProvider>
65+
<ResultsProvider>
66+
<FlowQueryProvider>
67+
<SidebarProvider>
68+
<ReadOnlyFlowPage />
69+
</SidebarProvider>
70+
</FlowQueryProvider>
71+
</ResultsProvider>
72+
</QueryProvider>
73+
</ReadOnly>
74+
</VersionFlowProvider>
75+
)
76+
77+
export default FlowContainer

src/flows/components/header/PublishedVersions.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const PublishedVersions: FC = () => {
1111

1212
return (
1313
<>
14+
<VersionBullet draftVersion />
1415
{versions.map(version => (
1516
<VersionBullet key={version.id} version={version} />
1617
))}

src/flows/components/header/SaveState.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {FlowContext} from 'src/flows/context/flow.current'
1313
import {FlowListContext} from 'src/flows/context/flow.list'
1414
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
1515
import {event} from 'src/cloud/utils/reporting'
16+
import {PROJECT_NAME_PLURAL} from 'src/flows'
1617

1718
const SaveState: FC = () => {
1819
const {flow} = useContext(FlowContext)
@@ -22,7 +23,9 @@ const SaveState: FC = () => {
2223
const addFlow = () => {
2324
event('Notebook save button clicked')
2425
add(flow).then(id => {
25-
history.replace(`/orgs/${org.id}/notebooks/${id}`)
26+
history.replace(
27+
`/orgs/${org.id}/${PROJECT_NAME_PLURAL.toLowerCase()}/${id}`
28+
)
2629
})
2730
}
2831

src/flows/components/header/VersionBullet.scss

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
.publish-version-bullet--button {
2-
margin-right: 40px;
2+
margin-right: 30px;
3+
4+
@media screen and (max-width: $cf-grid--breakpoint-md) {
5+
margin-right: 23px;
6+
}
37

48
&:hover {
59
cursor: pointer;
@@ -10,10 +14,11 @@
1014
content: '';
1115
height: 25px;
1216
width: 4px;
13-
transform: translate(-480%, 0%) rotate(-90deg);
17+
transform: translate(-380%, 0%) rotate(-90deg);
1418

1519
@media screen and (max-width: $cf-grid--breakpoint-md) {
16-
transform: translate(-380%, 0%) rotate(-90deg);
20+
height: 18px;
21+
transform: translate(-280%, 0%) rotate(-90deg);
1722
}
1823
background: #333346;
1924
background: -moz-linear-gradient(top, #333346 0%, #8e1fc3 100%);
@@ -29,13 +34,54 @@
2934
content: '';
3035
height: 25px;
3136
width: 4px;
32-
transform: translate(480%, 0) rotate(90deg);
37+
transform: translate(380%, 0) rotate(90deg);
3338

3439
@media screen and (max-width: $cf-grid--breakpoint-md) {
35-
transform: translate(380%, 0%) rotate(90deg);
40+
height: 18px;
41+
transform: translate(280%, 0%) rotate(90deg);
3642
}
3743
background: #333346;
3844
background: -moz-linear-gradient(top, #333346 0%, #8e1fc3 100%);
3945
background: -webkit-linear-gradient(top, #333346 0%, #8e1fc3 100%);
4046
background: linear-gradient(to bottom, #333346 0%, #8e1fc3 100%);
4147
}
48+
49+
.publish-version--bullet:last-of-type {
50+
.publish-version-bullet--button::after {
51+
display: none;
52+
}
53+
}
54+
55+
.active-version--button {
56+
box-shadow: 0 0 25px $cf-white;
57+
}
58+
59+
.publish-version-draft {
60+
background: $cf-grey-45;
61+
margin-right: 30px;
62+
63+
@media screen and (max-width: $cf-grid--breakpoint-md) {
64+
margin-right: 23px;
65+
margin-bottom: 1px;
66+
}
67+
68+
&:hover {
69+
cursor: pointer;
70+
}
71+
}
72+
73+
.publish-version-draft::after {
74+
content: '';
75+
height: 25px;
76+
width: 4px;
77+
transform: translate(380%, 0) rotate(90deg);
78+
79+
@media screen and (max-width: $cf-grid--breakpoint-md) {
80+
height: 18px;
81+
transform: translate(280%, 0%) rotate(90deg);
82+
}
83+
background: #333346;
84+
background: -moz-linear-gradient(top, #333346 0%, #78727a 100%);
85+
background: -webkit-linear-gradient(top, #333346 0%, #78727a 100%);
86+
background: linear-gradient(to bottom, #333346 0%, #78727a 100%);
87+
}

0 commit comments

Comments
 (0)