Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions src/browser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,7 @@ import ReactDOM from 'react-dom'

import AppInit, { setupSentry } from './AppInit'
import './init'
import { navigateToPreview } from './modules/Stream/StartPreviewFrame'
import { optedInByLocalhost } from 'browser-services/preview-optin-service'

setupSentry()

;(async () => {
const optedInToPreview = optedInByLocalhost()
try {
const response = await fetch('./preview/manifest.json')
if (response.status === 200) {
if (optedInToPreview) {
navigateToPreview()
} else {
localStorage.setItem('previewAvailable', 'true')
}
} else {
localStorage.setItem('previewAvailable', 'false')
}
} catch (e) {
localStorage.setItem('previewAvailable', 'false')
}

ReactDOM.render(<AppInit />, document.getElementById('mount'))
})()
ReactDOM.render(<AppInit />, document.getElementById('mount'))
7 changes: 2 additions & 5 deletions src/browser/modules/Stream/PlayFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,19 +292,16 @@ function generateContent(

// Check if content exists locally
if (isPlayChapter(guideName)) {
const isPreviewAvailable =
localStorage.getItem('previewAvailable') === 'true' && !inDesktop

const { content, title, subtitle, slides = null } = chapters[guideName]

const isPlayStart = stackFrame.cmd.trim() === ':play start'
const updatedContent =
isPlayStart && showPromotion ? (
<>
{isPreviewAvailable ? <PreviewFrame /> : content}
{!inDesktop ? <PreviewFrame /> : content}
<AuraPromotion />
</>
) : isPreviewAvailable ? (
) : !inDesktop ? (
<PreviewFrame />
) : (
content
Expand Down
31 changes: 9 additions & 22 deletions src/browser/modules/Stream/StartPreviewFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React, { Dispatch } from 'react'
import { Action } from 'redux'
import { trackNavigateToPreview } from 'shared/modules/preview/previewDuck'
import { connect } from 'react-redux'
import { withBus } from 'react-suber'
import { Action } from 'redux'
import { GlobalState } from 'shared/globalState'
import {
Connection,
getActiveConnectionData
} from 'shared/modules/connections/connectionsDuck'
import { trackNavigateToPreview } from 'shared/modules/preview/previewDuck'

export const navigateToPreview = (
db?: string | null,
dbms?: string | null
): void => {
const url = new URL(window.location.href)
const navigateToPreview = (db?: string | null, dbms?: string | null): void => {
const url = new URL('https://browser.neo4j.io/')

if (
dbms &&
!url.searchParams.has('dbms') &&
!url.searchParams.get('connectURL')
) {
if (dbms) {
url.searchParams.set('dbms', dbms)
}

if (db && !url.searchParams.has('db')) {
if (db) {
url.searchParams.set('db', db)
}

const previewPath = '/preview/'
if (!url.pathname.endsWith(previewPath)) {
url.pathname = url.pathname.replace(/\/?$/, previewPath)
window.location.href = decodeURIComponent(url.toString())
}
window.open(url.toString(), '_blank')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps not completely necessary since we define url ourselves - but we could add noreferrer to here to the options parameter as a general sanitary measure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's good practice so might as well

}

type PreviewFrameProps = {
Expand All @@ -71,10 +60,8 @@ const PreviewFrame = ({
<div className="teasers">
<div className="teaser teaser-advertise teaser-3">
<img src="./assets/images/clusters.svg" className="img-advertise" />
<h3>🚀 Try the new Browser preview!</h3>
<p>
Switch to the preview experience to access all the latest features.
</p>
<h3>🚀 Try the new hosted Browser!</h3>
<p>Switch to the hosted Browser to access all the latest features.</p>
<button
onClick={trackAndNavigateToPreview}
className="btn btn-advertise"
Expand Down
10 changes: 0 additions & 10 deletions src/browser/services/preview-optin-service.ts

This file was deleted.