-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from mikecao/dev
v0.62.0 Prisma update and version check
- Loading branch information
Showing
46 changed files
with
402 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ | |
min-width: 160px; | ||
} | ||
|
||
.text { | ||
flex: 1; | ||
} | ||
|
||
.icon { | ||
padding-left: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import useVersion from 'hooks/useVersion'; | ||
import styles from './UpdateNotice.module.css'; | ||
import ButtonLayout from '../layout/ButtonLayout'; | ||
import Button from './Button'; | ||
import useForceUpdate from '../../hooks/useForceUpdate'; | ||
|
||
export default function UpdateNotice() { | ||
const forceUpdte = useForceUpdate(); | ||
const { hasUpdate, latest, updateCheck } = useVersion(); | ||
|
||
function handleViewClick() { | ||
location.href = 'https://github.com/mikecao/umami/releases'; | ||
updateCheck(); | ||
forceUpdte(); | ||
} | ||
|
||
function handleDismissClick() { | ||
updateCheck(); | ||
forceUpdte(); | ||
} | ||
|
||
if (!hasUpdate) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className={styles.notice}> | ||
<div className={styles.message}> | ||
<FormattedMessage | ||
id="message.new-version-available" | ||
defaultMessage="A new version of umami {version} is available!" | ||
values={{ version: `v${latest}` }} | ||
/> | ||
</div> | ||
<ButtonLayout> | ||
<Button size="xsmall" variant="action" onClick={handleViewClick}> | ||
<FormattedMessage id="button.view-details" defaultMessage="View details" /> | ||
</Button> | ||
<Button size="xsmall" onClick={handleDismissClick}> | ||
<FormattedMessage id="button.dismiss" defaultMessage="Dismiss" /> | ||
</Button> | ||
</ButtonLayout> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.notice { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding-top: 10px; | ||
font-size: var(--font-size-small); | ||
font-weight: 600; | ||
} | ||
|
||
.message { | ||
text-align: center; | ||
margin-right: 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import styles from './Page.module.css'; | ||
|
||
export default function Page({ children }) { | ||
return <div className={styles.page}>{children}</div>; | ||
export default function Page({ className, children }) { | ||
return <div className={classNames(styles.page, className)}>{children}</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
align-items: center; | ||
align-content: center; | ||
min-height: 80px; | ||
align-self: stretch; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
align-self: stretch; | ||
} | ||
|
||
.title { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.test { | ||
border: 1px solid var(--gray200); | ||
border-radius: 5px; | ||
padding: 0 20px 20px 20px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React, { useState } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import classNames from 'classnames'; | ||
import Head from 'next/head'; | ||
import Link from 'next/link'; | ||
import Page from '../layout/Page'; | ||
import PageHeader from '../layout/PageHeader'; | ||
import useFetch from '../../hooks/useFetch'; | ||
import DropDown from '../common/DropDown'; | ||
import styles from './Test.module.css'; | ||
import WebsiteChart from '../metrics/WebsiteChart'; | ||
import EventsChart from '../metrics/EventsChart'; | ||
import Button from '../common/Button'; | ||
import EmptyPlaceholder from '../common/EmptyPlaceholder'; | ||
|
||
export default function TestConsole() { | ||
const user = useSelector(state => state.user); | ||
const [website, setWebsite] = useState(); | ||
const { data } = useFetch('/api/websites'); | ||
|
||
if (!data || !user?.is_admin) { | ||
return null; | ||
} | ||
|
||
const options = data.map(({ name, website_id }) => ({ label: name, value: website_id })); | ||
const selectedValue = options.find(({ value }) => value === website?.website_id)?.value; | ||
|
||
function handleSelect(value) { | ||
setWebsite(data.find(({ website_id }) => website_id === value)); | ||
} | ||
|
||
function handleClick() { | ||
window.umami('event (default)'); | ||
window.umami.trackView('/page-view', 'https://www.google.com'); | ||
window.umami.trackEvent('event (custom)', 'custom-type'); | ||
} | ||
|
||
return ( | ||
<Page> | ||
<Head> | ||
{typeof window !== 'undefined' && website && ( | ||
<script async defer data-website-id={website.website_uuid} src="/umami.js" /> | ||
)} | ||
</Head> | ||
<PageHeader> | ||
<div>Test Console</div> | ||
<DropDown | ||
value={selectedValue || 'Select website'} | ||
options={options} | ||
onChange={handleSelect} | ||
/> | ||
</PageHeader> | ||
{!selectedValue && <EmptyPlaceholder msg="I hope you know what you're doing here" />} | ||
{selectedValue && ( | ||
<> | ||
<div className={classNames(styles.test, 'row')}> | ||
<div className="col-4"> | ||
<PageHeader>Page links</PageHeader> | ||
<div> | ||
<Link href={`?page=1`}> | ||
<a>page one</a> | ||
</Link> | ||
</div> | ||
<div> | ||
<Link href={`?page=2`}> | ||
<a>page two</a> | ||
</Link> | ||
</div> | ||
</div> | ||
<div className="col-4"> | ||
<PageHeader>CSS events</PageHeader> | ||
<Button id="primary-button" className="umami--click--primary-button" variant="action"> | ||
Send event | ||
</Button> | ||
</div> | ||
<div className="col-4"> | ||
<PageHeader>Javascript events</PageHeader> | ||
<Button id="manual-button" variant="action" onClick={handleClick}> | ||
Run script | ||
</Button> | ||
</div> | ||
</div> | ||
<div className="row"> | ||
<div className="col-12"> | ||
<WebsiteChart websiteId={website.website_id} title={website.name} showLink /> | ||
<PageHeader>Events</PageHeader> | ||
<EventsChart websiteId={website.website_id} /> | ||
</div> | ||
</div> | ||
</> | ||
)} | ||
</Page> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ | |
} | ||
|
||
.backButton { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
margin-bottom: 16px; | ||
} | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useEffect, useCallback } from 'react'; | ||
|
||
export default function useEscapeKey(handler) { | ||
const escFunction = useCallback(event => { | ||
if (event.keyCode === 27) { | ||
handler(event); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
document.addEventListener('keydown', escFunction, false); | ||
|
||
return () => { | ||
document.removeEventListener('keydown', escFunction, false); | ||
}; | ||
}, [escFunction]); | ||
|
||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useEffect, useCallback } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import semver from 'semver'; | ||
import { getItem, setItem } from 'lib/web'; | ||
import { checkVersion } from 'redux/actions/app'; | ||
import { VERSION_CHECK } from 'lib/constants'; | ||
|
||
export default function useVersion() { | ||
const dispatch = useDispatch(); | ||
const versions = useSelector(state => state.app.versions); | ||
const lastCheck = getItem(VERSION_CHECK); | ||
|
||
const { current, latest } = versions; | ||
const hasUpdate = latest && semver.gt(latest, current) && lastCheck?.version !== latest; | ||
|
||
const updateCheck = useCallback(() => { | ||
setItem(VERSION_CHECK, { version: latest, time: Date.now() }); | ||
}, [versions]); | ||
|
||
useEffect(() => { | ||
if (!versions.latest) { | ||
dispatch(checkVersion()); | ||
} | ||
}, [versions]); | ||
|
||
return { ...versions, hasUpdate, updateCheck }; | ||
} |
Oops, something went wrong.
241156d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: