Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Mike Cao 2024-02-08 11:47:55 -08:00
commit b4a9ffe89e
6 changed files with 31 additions and 22 deletions

View File

@ -3,7 +3,7 @@ import { FormRow } from 'react-basics';
import { parseDateRange } from 'lib/date';
import DateFilter from 'components/input/DateFilter';
import WebsiteSelect from 'components/input/WebsiteSelect';
import { useMessages, useTeamUrl } from 'components/hooks';
import { useMessages, useTeamUrl, useWebsite } from 'components/hooks';
import { ReportContext } from './Report';
export interface BaseParametersProps {
@ -22,10 +22,11 @@ export function BaseParameters({
const { report, updateReport } = useContext(ReportContext);
const { formatMessage, labels } = useMessages();
const { teamId } = useTeamUrl();
const { parameters } = report || {};
const { websiteId, dateRange } = parameters || {};
const { value, startDate, endDate } = dateRange || {};
const { data: website } = useWebsite(websiteId);
const { name } = website || {};
const handleWebsiteSelect = (websiteId: string) => {
updateReport({ websiteId, parameters: { websiteId } });
@ -39,8 +40,10 @@ export function BaseParameters({
<>
{showWebsiteSelect && (
<FormRow label={formatMessage(labels.website)}>
{allowWebsiteSelect && (
{allowWebsiteSelect ? (
<WebsiteSelect teamId={teamId} websiteId={websiteId} onSelect={handleWebsiteSelect} />
) : (
name
)}
</FormRow>
)}

View File

@ -29,7 +29,7 @@ function useFields(websiteId, startDate, endDate) {
export function EventDataParameters() {
const { report, runReport, updateReport, isRunning } = useContext(ReportContext);
const { formatMessage, labels, messages } = useMessages();
const { parameters } = report || {};
const { id, parameters } = report || {};
const { websiteId, dateRange, fields, filters, groups } = parameters || {};
const { startDate, endDate } = dateRange || {};
const queryEnabled = websiteId && dateRange && fields?.length;
@ -93,7 +93,7 @@ export function EventDataParameters() {
return (
<Form values={parameters} error={error} onSubmit={handleSubmit}>
<BaseParameters />
<BaseParameters allowWebsiteSelect={!id} />
{!hasData && <Empty message={formatMessage(messages.noEventData)} />}
{parametersSelected &&
hasData &&

View File

@ -22,7 +22,7 @@ export function FunnelParameters() {
const { report, runReport, updateReport, isRunning } = useContext(ReportContext);
const { formatMessage, labels } = useMessages();
const { parameters } = report || {};
const { id, parameters } = report || {};
const { websiteId, dateRange, urls } = parameters || {};
const queryDisabled = !websiteId || !dateRange || urls?.length < 2;
@ -62,7 +62,7 @@ export function FunnelParameters() {
return (
<Form values={parameters} onSubmit={handleSubmit} preventSubmit={true}>
<BaseParameters />
<BaseParameters allowWebsiteSelect={!id} />
<FormRow label={formatMessage(labels.window)}>
<FormInput
name="window"

View File

@ -1,22 +1,22 @@
import { useFilters, useFormat, useMessages } from 'components/hooks';
import Icons from 'components/icons';
import { useContext } from 'react';
import { useFormat, useMessages, useFilters } from 'components/hooks';
import {
Form,
FormRow,
FormButtons,
SubmitButton,
PopupTrigger,
FormRow,
Icon,
Popup,
PopupTrigger,
SubmitButton,
TooltipPopup,
} from 'react-basics';
import Icons from 'components/icons';
import BaseParameters from '../[reportId]/BaseParameters';
import { ReportContext } from '../[reportId]/Report';
import ParameterList from '../[reportId]/ParameterList';
import FilterSelectForm from '../[reportId]/FilterSelectForm';
import FieldSelectForm from '../[reportId]/FieldSelectForm';
import FilterSelectForm from '../[reportId]/FilterSelectForm';
import ParameterList from '../[reportId]/ParameterList';
import PopupForm from '../[reportId]/PopupForm';
import { ReportContext } from '../[reportId]/Report';
import styles from './InsightsParameters.module.css';
export function InsightsParameters() {
@ -24,7 +24,7 @@ export function InsightsParameters() {
const { formatMessage, labels } = useMessages();
const { formatValue } = useFormat();
const { filterLabels } = useFilters();
const { parameters } = report || {};
const { id, parameters } = report || {};
const { websiteId, dateRange, fields, filters } = parameters || {};
const { startDate, endDate } = dateRange || {};
const parametersSelected = websiteId && startDate && endDate;
@ -103,7 +103,7 @@ export function InsightsParameters() {
return (
<Form values={parameters} onSubmit={handleSubmit}>
<BaseParameters />
<BaseParameters allowWebsiteSelect={!id} />
{parametersSelected &&
parameterGroups.map(({ id, label }) => {
return (

View File

@ -10,7 +10,7 @@ export function RetentionParameters() {
const { report, runReport, isRunning, updateReport } = useContext(ReportContext);
const { formatMessage, labels } = useMessages();
const { parameters } = report || {};
const { id, parameters } = report || {};
const { websiteId, dateRange } = parameters || {};
const { startDate } = dateRange || {};
const queryDisabled = !websiteId || !dateRange;
@ -30,7 +30,7 @@ export function RetentionParameters() {
return (
<Form values={parameters} onSubmit={handleSubmit} preventSubmit={true}>
<BaseParameters showDateSelect={false} />
<BaseParameters showDateSelect={false} allowWebsiteSelect={!id} />
<FormRow label={formatMessage(labels.date)}>
<MonthSelect date={startDate} onChange={handleDateChange} />
</FormRow>

View File

@ -1,6 +1,6 @@
import { Button, Modal, ModalTrigger, ActionForm, useToasts } from 'react-basics';
import { useRouter } from 'next/navigation';
import { useMessages, useModified } from 'components/hooks';
import { useMessages, useModified, useTeamUrl } from 'components/hooks';
import WebsiteDeleteForm from './WebsiteDeleteForm';
import WebsiteResetForm from './WebsiteResetForm';
@ -9,6 +9,7 @@ export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?:
const router = useRouter();
const { showToast } = useToasts();
const { touch } = useModified();
const { teamId, renderTeamUrl } = useTeamUrl();
const handleReset = async () => {
showToast({ message: formatMessage(messages.saved), variant: 'success' });
@ -16,8 +17,13 @@ export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?:
};
const handleDelete = async () => {
if (teamId) {
touch('teams:websites');
router.push(renderTeamUrl('/settings/websites'));
} else {
touch('websites');
router.push('/settings/websites');
}
};
return (