Skip to content

Commit 52380bc

Browse files
Merge pull request #1378 from OskarDamkjaer/aura-promotion
Add aura promotion in community
2 parents 97ef571 + 9001751 commit 52380bc

File tree

10 files changed

+190
-57
lines changed

10 files changed

+190
-57
lines changed
Lines changed: 35 additions & 0 deletions
Loading

src/browser/images/aura-logo.svg

Lines changed: 35 additions & 0 deletions
Loading

src/browser/modules/ClickToCode/__snapshots__/index.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`ClickToCode does not render if no children 1`] = `<div />`;
55
exports[`ClickToCode renders all children 1`] = `
66
<div>
77
<code
8-
class="sc-fzsDOv gpNFQu"
8+
class="sc-jVODtj jXQeRt"
99
>
1010
<div>
1111
<span>
@@ -20,7 +20,7 @@ exports[`ClickToCode renders all children 1`] = `
2020
exports[`ClickToCode renders children as code if no code is provided 1`] = `
2121
<div>
2222
<code
23-
class="sc-fzsDOv gpNFQu"
23+
class="sc-jVODtj jXQeRt"
2424
>
2525
hellohi!
2626
</code>
@@ -30,7 +30,7 @@ exports[`ClickToCode renders children as code if no code is provided 1`] = `
3030
exports[`ClickToCode renders code as the code when code is available 1`] = `
3131
<div>
3232
<code
33-
class="sc-fzsDOv gpNFQu"
33+
class="sc-jVODtj jXQeRt"
3434
>
3535
hello
3636
</code>

src/browser/modules/Stream/CypherFrame/__snapshots__/CodeView.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports[`CodeViews CodeStatusbar displays no statusBarMessage 1`] = `
66
class="sc-ckVGcZ fsAzIa"
77
>
88
<div
9-
class="sc-fMiknA kzCZTC"
9+
class="sc-eqIVtm dNNpFH"
1010
/>
1111
</div>
1212
</div>
@@ -18,7 +18,7 @@ exports[`CodeViews CodeStatusbar displays statusBarMessage 1`] = `
1818
class="sc-ckVGcZ fsAzIa"
1919
>
2020
<div
21-
class="sc-fMiknA kzCZTC"
21+
class="sc-eqIVtm dNNpFH"
2222
>
2323
Started streaming 1 records after 5 ms and completed after 10 ms.
2424
</div>

src/browser/modules/Stream/CypherFrame/__snapshots__/ErrorsView.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports[`ErrorsViews ErrorsStatusbar displays error 1`] = `
1010
title="Test.Error: Test error description"
1111
>
1212
<i
13-
class="sc-kUaPvJ duoQTJ fa fa-exclamation-triangle"
13+
class="sc-fONwsr efNtcV fa fa-exclamation-triangle"
1414
/>
1515
1616
Test.Error: Test error description
@@ -61,7 +61,7 @@ exports[`ErrorsViews ErrorsView displays procedure link if unknown procedure 1`]
6161
class="sc-bMVAic kWTfCD"
6262
>
6363
<i
64-
class="sc-gPWkxV hffcmY fa fa-play-circle-o"
64+
class="sc-kUaPvJ dnTzuZ fa fa-play-circle-o"
6565
/>
6666
 List available procedures
6767
</a>

src/browser/modules/Stream/CypherFrame/__snapshots__/VisualizationView.test.tsx.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`Visualization renders 1`] = `<div />`;
55
exports[`Visualization renders with result and escapes any HTML 1`] = `
66
<div>
77
<div
8-
class="sc-bYSBpT fHjFHH"
8+
class="sc-jtRfpW iZdwsA"
99
>
1010
<div
1111
class="sc-iAyFgw ikvPvE one-legend-row"
@@ -137,15 +137,15 @@ exports[`Visualization renders with result and escapes any HTML 1`] = `
137137
class="sc-cvbbAY ZoyPP faded zoom-in"
138138
>
139139
<i
140-
class="sc-jXQZqI bMRwes sl-zoom-in"
140+
class="sc-kasBVs dwyrqg sl-zoom-in"
141141
style="font-size: 1em;"
142142
/>
143143
</button>
144144
<button
145145
class="sc-cvbbAY ZoyPP zoom-out"
146146
>
147147
<i
148-
class="sc-iGPElx czYOXU sl-zoom-out"
148+
class="sc-hgHYgh cHEuJX sl-zoom-out"
149149
style="font-size: 1em;"
150150
/>
151151
</button>

src/browser/modules/Stream/CypherFrame/__snapshots__/relatable-view.test.tsx.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exports[`RelatableViews RelatableView displays bodyMessage if no rows 1`] = `
66
class="sc-ckVGcZ fsAzIa"
77
>
88
<div
9-
class="sc-fMiknA kzCZTC"
9+
class="sc-eqIVtm dNNpFH"
1010
>
1111
(no changes, no records)
1212
</div>
@@ -17,7 +17,7 @@ exports[`RelatableViews RelatableView displays bodyMessage if no rows 1`] = `
1717
exports[`RelatableViews RelatableView does not display bodyMessage if rows, and escapes HTML 1`] = `
1818
<div>
1919
<div
20-
class="sc-dVhcbM bPSoTK"
20+
class="sc-fAjcbJ Ooyas"
2121
>
2222
<div
2323
class="relatable css-1dne9dv"
@@ -90,7 +90,7 @@ exports[`RelatableViews TableStatusbar displays no statusBarMessage 1`] = `
9090
class="sc-ckVGcZ fsAzIa"
9191
>
9292
<div
93-
class="sc-fMiknA kzCZTC"
93+
class="sc-eqIVtm dNNpFH"
9494
/>
9595
</div>
9696
</div>
@@ -102,7 +102,7 @@ exports[`RelatableViews TableStatusbar displays statusBarMessage 1`] = `
102102
class="sc-ckVGcZ fsAzIa"
103103
>
104104
<div
105-
class="sc-fMiknA kzCZTC"
105+
class="sc-eqIVtm dNNpFH"
106106
>
107107
Started streaming 1 records after 5 ms and completed after 10 ms.
108108
</div>

src/browser/modules/Stream/PlayFrame.tsx

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
import React, { useEffect, useState } from 'react'
21+
import React, { useContext, useEffect, useState } from 'react'
2222
import { withBus } from 'react-suber'
2323
import { fetchGuideFromAllowlistAction } from 'shared/modules/commands/commandsDuck'
2424

@@ -38,6 +38,36 @@ import {
3838
} from 'browser-components/icons/Icons'
3939
import { splitMdxSlides } from '../Docs/MDX/splitMdx'
4040
import { LAST_GUIDE_SLIDE } from 'shared/modules/udc/udcDuck'
41+
import { connect } from 'react-redux'
42+
import { GlobalState } from 'shared/globalState'
43+
import { inCloudEnv } from 'shared/modules/app/appDuck'
44+
import { getEdition, isEnterprise } from 'shared/modules/dbMeta/dbMetaDuck'
45+
import { PromotionContainer, AuraPromoLink } from './styled'
46+
import { ThemeContext } from 'styled-components'
47+
import { DARK_THEME } from 'shared/modules/settings/settingsDuck'
48+
49+
const AuraPromotion = () => {
50+
const theme = useContext(ThemeContext)
51+
const isDarkTheme = theme.name === DARK_THEME
52+
53+
return (
54+
<PromotionContainer>
55+
<AuraPromoLink
56+
href="https://neo4j.com/cloud/aura/pricing/?utm_medium=browser&utm_source=ce&utm_campaign=wl_v1"
57+
rel="noreferrer"
58+
target="_blank"
59+
>
60+
Sign up
61+
</AuraPromoLink>
62+
for a free Neo4j cloud instance with
63+
<img
64+
src={`./assets/images/aura-logo${isDarkTheme ? '-inverted' : ''}.svg`}
65+
alt="Neo4j"
66+
style={{ marginLeft: '5px', width: '100%', maxWidth: '140px' }}
67+
/>
68+
</PromotionContainer>
69+
)
70+
}
4171

4272
const {
4373
play: { chapters }
@@ -50,7 +80,7 @@ const checkHtmlForSlides = (html: any) => {
5080
return !!slides.length
5181
}
5282

53-
export function PlayFrame({ stack, bus }: any): JSX.Element {
83+
export function PlayFrame({ stack, bus, showPromotion }: any): JSX.Element {
5484
const [stackIndex, setStackIndex] = useState(0)
5585
const [atSlideStart, setAtSlideStart] = useState<boolean | null>(null)
5686
const [atSlideEnd, setAtSlideEnd] = useState<boolean | null>(null)
@@ -75,7 +105,8 @@ export function PlayFrame({ stack, bus }: any): JSX.Element {
75105
currentFrame,
76106
bus,
77107
onSlide,
78-
shouldUseSlidePointer
108+
shouldUseSlidePointer,
109+
showPromotion
79110
)
80111
if (stillMounted) {
81112
setInitialPlay(false)
@@ -88,7 +119,7 @@ export function PlayFrame({ stack, bus }: any): JSX.Element {
88119
stillMounted = false
89120
}
90121
// The full dependency array causes a re-run which switches to slide 1
91-
}, [bus, currentFrame])
122+
}, [bus, currentFrame, showPromotion])
92123

93124
const { guide, aside, hasCarousel, isRemote } = guideObj
94125

@@ -158,7 +189,8 @@ function generateContent(
158189
stackFrame: any,
159190
bus: any,
160191
onSlide: any,
161-
shouldUseSlidePointer: any
192+
shouldUseSlidePointer: any,
193+
showPromotion = false
162194
): any {
163195
// Not found
164196
if (stackFrame.response && stackFrame.response.status === 404) {
@@ -242,13 +274,25 @@ function generateContent(
242274
// Check if content exists locally
243275
if (isPlayChapter(guideName)) {
244276
const { content, title, subtitle, slides = null } = chapters[guideName]
277+
278+
const isPlayStart = stackFrame.cmd.trim() === ':play start'
279+
const updatedContent =
280+
isPlayStart && showPromotion ? (
281+
<>
282+
{content}
283+
<AuraPromotion />
284+
</>
285+
) : (
286+
content
287+
)
288+
245289
return {
246290
guide: (
247291
<Docs
248292
lastUpdate={stackFrame.ts}
249293
originFrameId={stackFrame.id}
250294
withDirectives
251-
content={slides ? null : content}
295+
content={slides ? null : updatedContent}
252296
slides={slides ? slides : null}
253297
initialSlide={initialSlide}
254298
onSlide={onSlide}
@@ -315,4 +359,9 @@ const unfound = (
315359
}
316360
}
317361

318-
export default withBus(PlayFrame)
362+
const mapStateToProps = (state: GlobalState) => ({
363+
showPromotion:
364+
getEdition(state) !== null && !isEnterprise(state) && !inCloudEnv(state)
365+
})
366+
367+
export default connect(mapStateToProps)(withBus(PlayFrame))

0 commit comments

Comments
 (0)