Added settings redirect for cloud.

This commit is contained in:
Mike Cao 2023-08-27 14:15:02 -07:00
parent f2f5517051
commit cc574e6da4
6 changed files with 15 additions and 17 deletions

View File

@ -59,7 +59,9 @@ if (process.env.TRACKER_SCRIPT_NAME) {
const redirects = [
{
source: '/settings',
destination: process.env.CLOUD_MODE ? '/settings/profile' : '/settings/websites',
destination: process.env.CLOUD_MODE
? `${process.env.CLOUD_URL}/settings/websites`
: '/settings/websites',
permanent: true,
},
];

View File

@ -1,26 +1,24 @@
import { Icon, Text, Row, Column } from 'react-basics';
import Link from 'next/link';
import { useRouter } from 'next/router';
import classNames from 'classnames';
import Icons from 'components/icons';
import ThemeButton from 'components/input/ThemeButton';
import LanguageButton from 'components/input/LanguageButton';
import ProfileButton from 'components/input/ProfileButton';
import styles from './NavBar.module.css';
import useConfig from 'components/hooks/useConfig';
import useMessages from 'components/hooks/useMessages';
import { useRouter } from 'next/router';
import HamburgerButton from '../common/HamburgerButton';
import HamburgerButton from 'components/common/HamburgerButton';
import styles from './NavBar.module.css';
export function NavBar() {
const { pathname } = useRouter();
const { cloudMode } = useConfig();
const { formatMessage, labels } = useMessages();
const links = [
{ label: formatMessage(labels.dashboard), url: '/dashboard' },
{ label: formatMessage(labels.websites), url: '/websites' },
{ label: formatMessage(labels.reports), url: '/reports' },
!cloudMode && { label: formatMessage(labels.settings), url: '/settings' },
{ label: formatMessage(labels.settings), url: '/settings' },
].filter(n => n);
return (

View File

@ -9,7 +9,7 @@ export default function FieldFilterForm({
type,
values,
onSelect,
includeOnlyEquals,
allowFilterSelect = true,
}) {
const { formatMessage, labels } = useMessages();
const [filter, setFilter] = useState('eq');
@ -34,7 +34,7 @@ export default function FieldFilterForm({
<Form>
<FormRow label={label} className={styles.filter}>
<Flexbox gap={10}>
{!includeOnlyEquals && (
{allowFilterSelect && (
<Dropdown
className={styles.dropdown}
items={filters}

View File

@ -18,7 +18,7 @@ function useValues(websiteId, type) {
return { data, error, isLoading };
}
export default function FilterSelectForm({ websiteId, items, onSelect, includeOnlyEquals }) {
export default function FilterSelectForm({ websiteId, items, onSelect, allowFilterSelect }) {
const [field, setField] = useState();
const { data, isLoading } = useValues(websiteId, field?.name);
@ -37,7 +37,7 @@ export default function FilterSelectForm({ websiteId, items, onSelect, includeOn
type={field?.type}
values={data}
onSelect={onSelect}
includeOnlyEquals={includeOnlyEquals}
allowFilterSelect={allowFilterSelect}
/>
);
}

View File

@ -4,10 +4,10 @@ import useConfig from 'components/hooks/useConfig';
export function TrackingCode({ websiteId }) {
const { formatMessage, messages } = useMessages();
const { basePath, trackerScriptName } = useConfig();
const { basePath, trackerScriptName, trackerScriptOrigin } = useConfig();
const url = trackerScriptName?.startsWith('http')
? trackerScriptName
: `${location.origin}${basePath}/${
: `${trackerScriptOrigin || location.origin}${basePath}/${
trackerScriptName?.split(',')?.map(n => n.trim())?.[0] || 'script.js'
}`;

View File

@ -1,6 +1,5 @@
import classNames from 'classnames';
import { useApi, useDateRange, useMessages, usePageQuery, useSticky } from 'components/hooks';
import RefreshButton from 'components/input/RefreshButton';
import WebsiteDateFilter from 'components/input/WebsiteDateFilter';
import MetricCard from 'components/metrics/MetricCard';
import MetricsBar from 'components/metrics/MetricsBar';
@ -10,7 +9,7 @@ import { formatShortTime } from 'lib/format';
import { Button, Column, Icon, Icons, Popup, PopupTrigger, Row } from 'react-basics';
import styles from './WebsiteMetricsBar.module.css';
export function WebsiteMetricsBar({ websiteId, showFilter = true, showRefresh = true, sticky }) {
export function WebsiteMetricsBar({ websiteId, showFilter = true, sticky }) {
const { formatMessage, labels } = useMessages();
const { get, useQuery } = useApi();
@ -88,7 +87,7 @@ export function WebsiteMetricsBar({ websiteId, showFilter = true, showRefresh =
handleAddFilter(value);
close();
}}
includeOnlyEquals={true}
allowFilterSelect={false}
/>
</PopupForm>
);
@ -161,7 +160,6 @@ export function WebsiteMetricsBar({ websiteId, showFilter = true, showRefresh =
<Column defaultSize={12} xl={4}>
<div className={styles.actions}>
{showFilter && <WebsiteFilterButton />}
{showRefresh && <RefreshButton websiteId={websiteId} />}
<WebsiteDateFilter websiteId={websiteId} />
</div>
</Column>