mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Allow custom release URL.
This commit is contained in:
parent
64f1841ae4
commit
e4c4019e25
@ -16,7 +16,8 @@
|
|||||||
"react/display-name": "off",
|
"react/display-name": "off",
|
||||||
"react/react-in-jsx-scope": "off",
|
"react/react-in-jsx-scope": "off",
|
||||||
"react/prop-types": "off",
|
"react/prop-types": "off",
|
||||||
"import/no-anonymous-default-export": "off"
|
"import/no-anonymous-default-export": "off",
|
||||||
|
"@next/next/no-img-element": "off"
|
||||||
},
|
},
|
||||||
"globals": {
|
"globals": {
|
||||||
"React": "writable"
|
"React": "writable"
|
||||||
|
@ -3,12 +3,12 @@ import { FormattedMessage } from 'react-intl';
|
|||||||
import ButtonLayout from 'components/layout/ButtonLayout';
|
import ButtonLayout from 'components/layout/ButtonLayout';
|
||||||
import useStore, { checkVersion } from 'store/version';
|
import useStore, { checkVersion } from 'store/version';
|
||||||
import { setItem } from 'lib/web';
|
import { setItem } from 'lib/web';
|
||||||
import { VERSION_CHECK, VERSION_URL } from 'lib/constants';
|
import { REPO_URL, VERSION_CHECK } from 'lib/constants';
|
||||||
import Button from './Button';
|
import Button from './Button';
|
||||||
import styles from './UpdateNotice.module.css';
|
import styles from './UpdateNotice.module.css';
|
||||||
|
|
||||||
export default function UpdateNotice() {
|
export default function UpdateNotice() {
|
||||||
const { latest, checked, hasUpdate } = useStore();
|
const { latest, checked, hasUpdate, releaseUrl } = useStore();
|
||||||
const [dismissed, setDismissed] = useState(false);
|
const [dismissed, setDismissed] = useState(false);
|
||||||
|
|
||||||
const updateCheck = useCallback(() => {
|
const updateCheck = useCallback(() => {
|
||||||
@ -18,7 +18,7 @@ export default function UpdateNotice() {
|
|||||||
function handleViewClick() {
|
function handleViewClick() {
|
||||||
updateCheck();
|
updateCheck();
|
||||||
setDismissed(true);
|
setDismissed(true);
|
||||||
location.href = VERSION_URL;
|
location.href = releaseUrl || REPO_URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDismissClick() {
|
function handleDismissClick() {
|
||||||
|
@ -4,7 +4,7 @@ import { FormattedMessage } from 'react-intl';
|
|||||||
import Link from 'components/common/Link';
|
import Link from 'components/common/Link';
|
||||||
import styles from './Footer.module.css';
|
import styles from './Footer.module.css';
|
||||||
import useStore from 'store/version';
|
import useStore from 'store/version';
|
||||||
import { HOMEPAGE_URL, VERSION_URL } from 'lib/constants';
|
import { HOMEPAGE_URL, REPO_URL } from 'lib/constants';
|
||||||
|
|
||||||
export default function Footer() {
|
export default function Footer() {
|
||||||
const { current } = useStore();
|
const { current } = useStore();
|
||||||
@ -26,8 +26,11 @@ export default function Footer() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={classNames(styles.version, 'col-12 col-md-4')}>
|
<div className={classNames(styles.version, 'col-12 col-md-4')}>
|
||||||
<Link href={VERSION_URL}>{`v${current}`}</Link>
|
<Link href={REPO_URL}>{`v${current}`}</Link>
|
||||||
</div>
|
</div>
|
||||||
|
{!process.env.telemetryDisabled && (
|
||||||
|
<img src={`https://i.umami.is/a.png?v=${current}`} alt="" />
|
||||||
|
)}
|
||||||
</footer>
|
</footer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ export const DASHBOARD_CONFIG = 'umami.dashboard';
|
|||||||
export const VERSION_CHECK = 'umami.version-check';
|
export const VERSION_CHECK = 'umami.version-check';
|
||||||
export const SHARE_TOKEN_HEADER = 'x-umami-share-token';
|
export const SHARE_TOKEN_HEADER = 'x-umami-share-token';
|
||||||
export const HOMEPAGE_URL = 'https://umami.is';
|
export const HOMEPAGE_URL = 'https://umami.is';
|
||||||
export const VERSION_URL = 'https://github.com/mikecao/umami/releases';
|
export const REPO_URL = 'https://github.com/umami-software/umami';
|
||||||
|
export const UPDATES_URL = 'https://api.umami.is/v1/updates';
|
||||||
|
|
||||||
export const DEFAULT_LOCALE = 'en-US';
|
export const DEFAULT_LOCALE = 'en-US';
|
||||||
export const DEFAULT_THEME = 'light';
|
export const DEFAULT_THEME = 'light';
|
||||||
|
20
lib/db.js
20
lib/db.js
@ -2,7 +2,7 @@ import { PrismaClient } from '@prisma/client';
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
BigInt.prototype.toJSON = function () {
|
BigInt.prototype.toJSON = function () {
|
||||||
return this.toString();
|
return Number(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
@ -18,20 +18,20 @@ function logQuery(e) {
|
|||||||
console.log(chalk.yellow(e.params), '->', e.query, chalk.greenBright(`${e.duration}ms`));
|
console.log(chalk.yellow(e.params), '->', e.query, chalk.greenBright(`${e.duration}ms`));
|
||||||
}
|
}
|
||||||
|
|
||||||
let prisma;
|
function getClient(options) {
|
||||||
|
const prisma = new PrismaClient(options);
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.LOG_QUERY) {
|
||||||
prisma = new PrismaClient(options);
|
prisma.$on('query', logQuery);
|
||||||
} else {
|
|
||||||
if (!global.prisma) {
|
|
||||||
global.prisma = new PrismaClient(options);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
prisma = global.prisma;
|
return prisma;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.LOG_QUERY) {
|
const prisma = global.prisma || getClient(options);
|
||||||
prisma.$on('query', logQuery);
|
|
||||||
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
global.prisma = prisma;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default prisma;
|
export default prisma;
|
||||||
|
@ -6,6 +6,7 @@ module.exports = {
|
|||||||
currentVersion: pkg.version,
|
currentVersion: pkg.version,
|
||||||
loginDisabled: process.env.DISABLE_LOGIN,
|
loginDisabled: process.env.DISABLE_LOGIN,
|
||||||
updatesDisabled: process.env.DISABLE_UPDATES,
|
updatesDisabled: process.env.DISABLE_UPDATES,
|
||||||
|
telemetryDisabled: process.env.DISABLE_TELEMETRY,
|
||||||
},
|
},
|
||||||
basePath: process.env.BASE_PATH,
|
basePath: process.env.BASE_PATH,
|
||||||
output: 'standalone',
|
output: 'standalone',
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
import create from 'zustand';
|
import create from 'zustand';
|
||||||
import produce from 'immer';
|
import produce from 'immer';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import { VERSION_CHECK } from 'lib/constants';
|
import { VERSION_CHECK, UPDATES_URL } from 'lib/constants';
|
||||||
import { getItem } from 'lib/web';
|
import { getItem } from 'lib/web';
|
||||||
|
|
||||||
const UPDATES_URL = 'https://api.umami.is/v1/updates';
|
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
current: process.env.currentVersion,
|
current: process.env.currentVersion,
|
||||||
latest: null,
|
latest: null,
|
||||||
hasUpdate: false,
|
hasUpdate: false,
|
||||||
checked: false,
|
checked: false,
|
||||||
|
releaseUrl: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const store = create(() => ({ ...initialState }));
|
const store = create(() => ({ ...initialState }));
|
||||||
@ -37,7 +36,7 @@ export async function checkVersion() {
|
|||||||
|
|
||||||
store.setState(
|
store.setState(
|
||||||
produce(state => {
|
produce(state => {
|
||||||
const { latest } = data;
|
const { latest, url } = data;
|
||||||
const lastCheck = getItem(VERSION_CHECK);
|
const lastCheck = getItem(VERSION_CHECK);
|
||||||
|
|
||||||
const hasUpdate = !!(latest && lastCheck?.version !== latest && semver.gt(latest, current));
|
const hasUpdate = !!(latest && lastCheck?.version !== latest && semver.gt(latest, current));
|
||||||
@ -46,6 +45,7 @@ export async function checkVersion() {
|
|||||||
state.latest = latest;
|
state.latest = latest;
|
||||||
state.hasUpdate = hasUpdate;
|
state.hasUpdate = hasUpdate;
|
||||||
state.checked = true;
|
state.checked = true;
|
||||||
|
state.releaseUrl = url;
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}),
|
}),
|
||||||
|
Loading…
Reference in New Issue
Block a user