mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-22 18:00:17 +01:00
Disable website select for saved report. Fix delete website routing
This commit is contained in:
parent
91e3dff7f5
commit
5ae04291af
@ -3,7 +3,7 @@ import { FormRow } from 'react-basics';
|
|||||||
import { parseDateRange } from 'lib/date';
|
import { parseDateRange } from 'lib/date';
|
||||||
import DateFilter from 'components/input/DateFilter';
|
import DateFilter from 'components/input/DateFilter';
|
||||||
import WebsiteSelect from 'components/input/WebsiteSelect';
|
import WebsiteSelect from 'components/input/WebsiteSelect';
|
||||||
import { useMessages, useTeamUrl } from 'components/hooks';
|
import { useMessages, useTeamUrl, useWebsite } from 'components/hooks';
|
||||||
import { ReportContext } from './Report';
|
import { ReportContext } from './Report';
|
||||||
|
|
||||||
export interface BaseParametersProps {
|
export interface BaseParametersProps {
|
||||||
@ -22,10 +22,11 @@ export function BaseParameters({
|
|||||||
const { report, updateReport } = useContext(ReportContext);
|
const { report, updateReport } = useContext(ReportContext);
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { teamId } = useTeamUrl();
|
const { teamId } = useTeamUrl();
|
||||||
|
|
||||||
const { parameters } = report || {};
|
const { parameters } = report || {};
|
||||||
const { websiteId, dateRange } = parameters || {};
|
const { websiteId, dateRange } = parameters || {};
|
||||||
const { value, startDate, endDate } = dateRange || {};
|
const { value, startDate, endDate } = dateRange || {};
|
||||||
|
const { data: website } = useWebsite(websiteId);
|
||||||
|
const { name } = website || {};
|
||||||
|
|
||||||
const handleWebsiteSelect = (websiteId: string) => {
|
const handleWebsiteSelect = (websiteId: string) => {
|
||||||
updateReport({ websiteId, parameters: { websiteId } });
|
updateReport({ websiteId, parameters: { websiteId } });
|
||||||
@ -39,8 +40,10 @@ export function BaseParameters({
|
|||||||
<>
|
<>
|
||||||
{showWebsiteSelect && (
|
{showWebsiteSelect && (
|
||||||
<FormRow label={formatMessage(labels.website)}>
|
<FormRow label={formatMessage(labels.website)}>
|
||||||
{allowWebsiteSelect && (
|
{allowWebsiteSelect ? (
|
||||||
<WebsiteSelect teamId={teamId} websiteId={websiteId} onSelect={handleWebsiteSelect} />
|
<WebsiteSelect teamId={teamId} websiteId={websiteId} onSelect={handleWebsiteSelect} />
|
||||||
|
) : (
|
||||||
|
name
|
||||||
)}
|
)}
|
||||||
</FormRow>
|
</FormRow>
|
||||||
)}
|
)}
|
||||||
|
@ -29,7 +29,7 @@ function useFields(websiteId, startDate, endDate) {
|
|||||||
export function EventDataParameters() {
|
export function EventDataParameters() {
|
||||||
const { report, runReport, updateReport, isRunning } = useContext(ReportContext);
|
const { report, runReport, updateReport, isRunning } = useContext(ReportContext);
|
||||||
const { formatMessage, labels, messages } = useMessages();
|
const { formatMessage, labels, messages } = useMessages();
|
||||||
const { parameters } = report || {};
|
const { id, parameters } = report || {};
|
||||||
const { websiteId, dateRange, fields, filters, groups } = parameters || {};
|
const { websiteId, dateRange, fields, filters, groups } = parameters || {};
|
||||||
const { startDate, endDate } = dateRange || {};
|
const { startDate, endDate } = dateRange || {};
|
||||||
const queryEnabled = websiteId && dateRange && fields?.length;
|
const queryEnabled = websiteId && dateRange && fields?.length;
|
||||||
@ -93,7 +93,7 @@ export function EventDataParameters() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Form values={parameters} error={error} onSubmit={handleSubmit}>
|
<Form values={parameters} error={error} onSubmit={handleSubmit}>
|
||||||
<BaseParameters />
|
<BaseParameters allowWebsiteSelect={!id} />
|
||||||
{!hasData && <Empty message={formatMessage(messages.noEventData)} />}
|
{!hasData && <Empty message={formatMessage(messages.noEventData)} />}
|
||||||
{parametersSelected &&
|
{parametersSelected &&
|
||||||
hasData &&
|
hasData &&
|
||||||
|
@ -22,7 +22,7 @@ export function FunnelParameters() {
|
|||||||
const { report, runReport, updateReport, isRunning } = useContext(ReportContext);
|
const { report, runReport, updateReport, isRunning } = useContext(ReportContext);
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
const { parameters } = report || {};
|
const { id, parameters } = report || {};
|
||||||
const { websiteId, dateRange, urls } = parameters || {};
|
const { websiteId, dateRange, urls } = parameters || {};
|
||||||
const queryDisabled = !websiteId || !dateRange || urls?.length < 2;
|
const queryDisabled = !websiteId || !dateRange || urls?.length < 2;
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ export function FunnelParameters() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Form values={parameters} onSubmit={handleSubmit} preventSubmit={true}>
|
<Form values={parameters} onSubmit={handleSubmit} preventSubmit={true}>
|
||||||
<BaseParameters />
|
<BaseParameters allowWebsiteSelect={!id} />
|
||||||
<FormRow label={formatMessage(labels.window)}>
|
<FormRow label={formatMessage(labels.window)}>
|
||||||
<FormInput
|
<FormInput
|
||||||
name="window"
|
name="window"
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
|
import { useFilters, useFormat, useMessages } from 'components/hooks';
|
||||||
|
import Icons from 'components/icons';
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { useFormat, useMessages, useFilters } from 'components/hooks';
|
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormRow,
|
|
||||||
FormButtons,
|
FormButtons,
|
||||||
SubmitButton,
|
FormRow,
|
||||||
PopupTrigger,
|
|
||||||
Icon,
|
Icon,
|
||||||
Popup,
|
Popup,
|
||||||
|
PopupTrigger,
|
||||||
|
SubmitButton,
|
||||||
TooltipPopup,
|
TooltipPopup,
|
||||||
} from 'react-basics';
|
} from 'react-basics';
|
||||||
import Icons from 'components/icons';
|
|
||||||
import BaseParameters from '../[reportId]/BaseParameters';
|
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 FieldSelectForm from '../[reportId]/FieldSelectForm';
|
||||||
|
import FilterSelectForm from '../[reportId]/FilterSelectForm';
|
||||||
|
import ParameterList from '../[reportId]/ParameterList';
|
||||||
import PopupForm from '../[reportId]/PopupForm';
|
import PopupForm from '../[reportId]/PopupForm';
|
||||||
|
import { ReportContext } from '../[reportId]/Report';
|
||||||
import styles from './InsightsParameters.module.css';
|
import styles from './InsightsParameters.module.css';
|
||||||
|
|
||||||
export function InsightsParameters() {
|
export function InsightsParameters() {
|
||||||
@ -24,7 +24,7 @@ export function InsightsParameters() {
|
|||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
const { formatValue } = useFormat();
|
const { formatValue } = useFormat();
|
||||||
const { filterLabels } = useFilters();
|
const { filterLabels } = useFilters();
|
||||||
const { parameters } = report || {};
|
const { id, parameters } = report || {};
|
||||||
const { websiteId, dateRange, fields, filters } = parameters || {};
|
const { websiteId, dateRange, fields, filters } = parameters || {};
|
||||||
const { startDate, endDate } = dateRange || {};
|
const { startDate, endDate } = dateRange || {};
|
||||||
const parametersSelected = websiteId && startDate && endDate;
|
const parametersSelected = websiteId && startDate && endDate;
|
||||||
@ -103,7 +103,7 @@ export function InsightsParameters() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Form values={parameters} onSubmit={handleSubmit}>
|
<Form values={parameters} onSubmit={handleSubmit}>
|
||||||
<BaseParameters />
|
<BaseParameters allowWebsiteSelect={!id} />
|
||||||
{parametersSelected &&
|
{parametersSelected &&
|
||||||
parameterGroups.map(({ id, label }) => {
|
parameterGroups.map(({ id, label }) => {
|
||||||
return (
|
return (
|
||||||
|
@ -10,7 +10,7 @@ export function RetentionParameters() {
|
|||||||
const { report, runReport, isRunning, updateReport } = useContext(ReportContext);
|
const { report, runReport, isRunning, updateReport } = useContext(ReportContext);
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
const { parameters } = report || {};
|
const { id, parameters } = report || {};
|
||||||
const { websiteId, dateRange } = parameters || {};
|
const { websiteId, dateRange } = parameters || {};
|
||||||
const { startDate } = dateRange || {};
|
const { startDate } = dateRange || {};
|
||||||
const queryDisabled = !websiteId || !dateRange;
|
const queryDisabled = !websiteId || !dateRange;
|
||||||
@ -30,7 +30,7 @@ export function RetentionParameters() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Form values={parameters} onSubmit={handleSubmit} preventSubmit={true}>
|
<Form values={parameters} onSubmit={handleSubmit} preventSubmit={true}>
|
||||||
<BaseParameters showDateSelect={false} />
|
<BaseParameters showDateSelect={false} allowWebsiteSelect={!id} />
|
||||||
<FormRow label={formatMessage(labels.date)}>
|
<FormRow label={formatMessage(labels.date)}>
|
||||||
<MonthSelect date={startDate} onChange={handleDateChange} />
|
<MonthSelect date={startDate} onChange={handleDateChange} />
|
||||||
</FormRow>
|
</FormRow>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Button, Modal, ModalTrigger, ActionForm, useToasts } from 'react-basics';
|
import { Button, Modal, ModalTrigger, ActionForm, useToasts } from 'react-basics';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import { useMessages, useModified } from 'components/hooks';
|
import { useMessages, useModified, useTeamUrl } from 'components/hooks';
|
||||||
import WebsiteDeleteForm from './WebsiteDeleteForm';
|
import WebsiteDeleteForm from './WebsiteDeleteForm';
|
||||||
import WebsiteResetForm from './WebsiteResetForm';
|
import WebsiteResetForm from './WebsiteResetForm';
|
||||||
|
|
||||||
@ -9,6 +9,7 @@ export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?:
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { showToast } = useToasts();
|
const { showToast } = useToasts();
|
||||||
const { touch } = useModified();
|
const { touch } = useModified();
|
||||||
|
const { teamId, renderTeamUrl } = useTeamUrl();
|
||||||
|
|
||||||
const handleReset = async () => {
|
const handleReset = async () => {
|
||||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||||
@ -16,8 +17,13 @@ export function WebsiteData({ websiteId, onSave }: { websiteId: string; onSave?:
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
|
if (teamId) {
|
||||||
|
touch('teams:websites');
|
||||||
|
router.push(renderTeamUrl('/settings/websites'));
|
||||||
|
} else {
|
||||||
touch('websites');
|
touch('websites');
|
||||||
router.push('/settings/websites');
|
router.push('/settings/websites');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user