mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 14:17:13 +01:00
Updated cloud mode checks.
This commit is contained in:
parent
d8075764e2
commit
9897c725de
16 changed files with 23 additions and 81 deletions
|
|
@ -18,7 +18,7 @@ export function UpdateNotice({ user, config }) {
|
|||
!config?.updatesDisabled &&
|
||||
!config?.privateMode &&
|
||||
!pathname.includes('/share/') &&
|
||||
!process.env.cloudUrl &&
|
||||
!process.env.cloudMode &&
|
||||
!dismissed;
|
||||
|
||||
const updateCheck = useCallback(() => {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export function AdminLayout({ children }: { children: ReactNode }) {
|
|||
const { formatMessage, labels } = useMessages();
|
||||
const { pathname } = useNavigation();
|
||||
|
||||
if (!user.isAdmin || process.env.cloudUrl) {
|
||||
if (!user.isAdmin || process.env.cloudMode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
|||
import { AdminLayout } from './AdminLayout';
|
||||
|
||||
export default function ({ children }) {
|
||||
if (process.env.cloudUrl) {
|
||||
if (process.env.cloudMode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,9 @@ export function LinkEditForm({
|
|||
{formatMessage(labels.cancel)}
|
||||
</Button>
|
||||
)}
|
||||
<FormSubmitButton isDisabled={false}>{formatMessage(labels.save)}</FormSubmitButton>
|
||||
<FormSubmitButton isDisabled={false} isLoading={isPending}>
|
||||
{formatMessage(labels.save)}
|
||||
</FormSubmitButton>
|
||||
</Row>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
|||
import { SettingsLayout } from './SettingsLayout';
|
||||
|
||||
export default function ({ children }) {
|
||||
if (process.env.cloudUrl) {
|
||||
if (process.env.cloudMode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,10 +114,7 @@ export function CohortEditForm({
|
|||
|
||||
<Column>
|
||||
<Label>{formatMessage(labels.filters)}</Label>
|
||||
<FormField
|
||||
name="parameters.filters"
|
||||
rules={{ required: formatMessage(labels.required) }}
|
||||
>
|
||||
<FormField name="parameters.filters">
|
||||
<FieldFilters websiteId={websiteId} exclude={['path', 'event']} />
|
||||
</FormField>
|
||||
</Column>
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ export async function GET(request: Request) {
|
|||
}
|
||||
|
||||
return json({
|
||||
cloudMode: !!process.env.CLOUD_URL,
|
||||
cloudUrl: process.env.CLOUD_URL,
|
||||
cloudMode: !!process.env.CLOUD_MODE,
|
||||
faviconUrl: process.env.FAVICON_URL,
|
||||
linksUrl: process.env.LINKS_URL,
|
||||
pixelsUrl: process.env.PIXELS_URL,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Metadata } from 'next';
|
|||
import { LoginPage } from './LoginPage';
|
||||
|
||||
export default async function () {
|
||||
if (process.env.DISABLE_LOGIN) {
|
||||
if (process.env.DISABLE_LOGIN || process.env.CLOUD_MODE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { LogoutPage } from './LogoutPage';
|
||||
import { Metadata } from 'next';
|
||||
import { LogoutPage } from './LogoutPage';
|
||||
|
||||
export default function () {
|
||||
if (process.env.DISABLE_LOGIN) {
|
||||
if (process.env.DISABLE_LOGIN || process.env.CLOUD_MODE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import { useApi } from '@/components/hooks/useApi';
|
|||
|
||||
export type Config = {
|
||||
cloudMode: boolean;
|
||||
cloudUrl?: string;
|
||||
faviconUrl?: string;
|
||||
linksUrl?: string;
|
||||
pixelsUrl?: string;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,13 @@ import {
|
|||
Text,
|
||||
Row,
|
||||
} from '@umami/react-zen';
|
||||
import { useMessages, useLoginQuery, useNavigation, useConfig } from '@/components/hooks';
|
||||
import { useMessages, useLoginQuery, useNavigation } from '@/components/hooks';
|
||||
import { LogOut, UserCircle, LockKeyhole } from '@/components/icons';
|
||||
|
||||
export function ProfileButton() {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { user } = useLoginQuery();
|
||||
const { renderUrl } = useNavigation();
|
||||
const { cloudUrl } = useConfig();
|
||||
|
||||
const items = [
|
||||
{
|
||||
|
|
@ -28,7 +27,7 @@ export function ProfileButton() {
|
|||
icon: <UserCircle />,
|
||||
},
|
||||
user.isAdmin &&
|
||||
!cloudUrl && {
|
||||
!process.env.cloudMode && {
|
||||
id: 'admin',
|
||||
label: formatMessage(labels.admin),
|
||||
path: '/admin',
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ export function SettingsButton() {
|
|||
const { formatMessage, labels } = useMessages();
|
||||
const { user } = useLoginQuery();
|
||||
const { router, renderUrl } = useNavigation();
|
||||
const { cloudMode, cloudUrl } = useConfig();
|
||||
const { cloudMode } = useConfig();
|
||||
|
||||
const handleAction = (id: Key) => {
|
||||
if (id === 'settings') {
|
||||
if (cloudMode) {
|
||||
window.location.href = `${cloudUrl}/settings`;
|
||||
window.location.href = `/settings`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ export const labels = defineMessages({
|
|||
invalidUrl: { id: 'label.invalid-url', defaultMessage: 'Invalid URL' },
|
||||
environment: { id: 'label.environment', defaultMessage: 'Environment' },
|
||||
criteria: { id: 'label.criteria', defaultMessage: 'Criteria' },
|
||||
share: { defaultMessage: 'label.share', id: 'Share' },
|
||||
share: { id: 'label.share', defaultMessage: 'Share' },
|
||||
});
|
||||
|
||||
export const messages = defineMessages({
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export function getBearerToken(request: Request) {
|
|||
export async function checkAuth(request: Request) {
|
||||
const token = getBearerToken(request);
|
||||
const payload = parseSecureToken(token, secret());
|
||||
const shareToken = await parseShareToken(request.headers);
|
||||
const shareToken = await parseShareToken(request);
|
||||
|
||||
let user = null;
|
||||
const { userId, authKey, grant } = payload || {};
|
||||
|
|
@ -71,9 +71,9 @@ export async function hasPermission(role: string, permission: string | string[])
|
|||
return ensureArray(permission).some(e => ROLE_PERMISSIONS[role]?.includes(e));
|
||||
}
|
||||
|
||||
export function parseShareToken(headers: Headers) {
|
||||
export function parseShareToken(request: Request) {
|
||||
try {
|
||||
return parseToken(headers.get(SHARE_TOKEN_HEADER), secret());
|
||||
return parseToken(request.headers.get(SHARE_TOKEN_HEADER), secret());
|
||||
} catch (e) {
|
||||
log(e);
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue