mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Fixed website refresh after save.
This commit is contained in:
parent
f01073c46a
commit
f50067e44f
@ -7,7 +7,6 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Toggle,
|
Toggle,
|
||||||
LoadingButton,
|
LoadingButton,
|
||||||
useToasts,
|
|
||||||
} from 'react-basics';
|
} from 'react-basics';
|
||||||
import { useContext, useState } from 'react';
|
import { useContext, useState } from 'react';
|
||||||
import { getRandomChars } from 'next-basics';
|
import { getRandomChars } from 'next-basics';
|
||||||
@ -18,6 +17,7 @@ const generateId = () => getRandomChars(16);
|
|||||||
|
|
||||||
export function ShareUrl({
|
export function ShareUrl({
|
||||||
hostUrl,
|
hostUrl,
|
||||||
|
onSave,
|
||||||
}: {
|
}: {
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
hostUrl?: string;
|
hostUrl?: string;
|
||||||
@ -27,7 +27,6 @@ export function ShareUrl({
|
|||||||
const { domain, shareId } = website;
|
const { domain, shareId } = website;
|
||||||
const { formatMessage, labels, messages } = useMessages();
|
const { formatMessage, labels, messages } = useMessages();
|
||||||
const [id, setId] = useState(shareId);
|
const [id, setId] = useState(shareId);
|
||||||
const { showToast } = useToasts();
|
|
||||||
const { post, useMutation } = useApi();
|
const { post, useMutation } = useApi();
|
||||||
const { mutate, error, isPending } = useMutation({
|
const { mutate, error, isPending } = useMutation({
|
||||||
mutationFn: (data: any) => post(`/websites/${website.id}`, data),
|
mutationFn: (data: any) => post(`/websites/${website.id}`, data),
|
||||||
@ -46,7 +45,8 @@ export function ShareUrl({
|
|||||||
const data = { shareId: checked ? generateId() : null };
|
const data = { shareId: checked ? generateId() : null };
|
||||||
mutate(data, {
|
mutate(data, {
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
touch(`website:${website.id}`);
|
||||||
|
onSave?.();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setId(data.shareId);
|
setId(data.shareId);
|
||||||
@ -57,8 +57,8 @@ export function ShareUrl({
|
|||||||
{ shareId: id },
|
{ shareId: id },
|
||||||
{
|
{
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
touch(`website:${website.id}`);
|
||||||
touch(`website:${website?.id}`);
|
onSave?.();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,18 +1,10 @@
|
|||||||
import { useContext, useRef } from 'react';
|
import { useContext, useRef } from 'react';
|
||||||
import {
|
import { SubmitButton, Form, FormInput, FormRow, FormButtons, TextField } from 'react-basics';
|
||||||
SubmitButton,
|
|
||||||
Form,
|
|
||||||
FormInput,
|
|
||||||
FormRow,
|
|
||||||
FormButtons,
|
|
||||||
TextField,
|
|
||||||
useToasts,
|
|
||||||
} from 'react-basics';
|
|
||||||
import { useApi, useMessages, useModified } from 'components/hooks';
|
import { useApi, useMessages, useModified } from 'components/hooks';
|
||||||
import { DOMAIN_REGEX } from 'lib/constants';
|
import { DOMAIN_REGEX } from 'lib/constants';
|
||||||
import { WebsiteContext } from 'app/(main)/websites/[websiteId]/WebsiteProvider';
|
import { WebsiteContext } from 'app/(main)/websites/[websiteId]/WebsiteProvider';
|
||||||
|
|
||||||
export function WebsiteEditForm({ websiteId }: { websiteId: string }) {
|
export function WebsiteEditForm({ websiteId, onSave }: { websiteId: string; onSave?: () => void }) {
|
||||||
const website = useContext(WebsiteContext);
|
const website = useContext(WebsiteContext);
|
||||||
const { formatMessage, labels, messages } = useMessages();
|
const { formatMessage, labels, messages } = useMessages();
|
||||||
const { post, useMutation } = useApi();
|
const { post, useMutation } = useApi();
|
||||||
@ -20,15 +12,14 @@ export function WebsiteEditForm({ websiteId }: { websiteId: string }) {
|
|||||||
mutationFn: (data: any) => post(`/websites/${websiteId}`, data),
|
mutationFn: (data: any) => post(`/websites/${websiteId}`, data),
|
||||||
});
|
});
|
||||||
const ref = useRef(null);
|
const ref = useRef(null);
|
||||||
const { showToast } = useToasts();
|
|
||||||
const { touch } = useModified();
|
const { touch } = useModified();
|
||||||
|
|
||||||
const handleSubmit = async (data: any) => {
|
const handleSubmit = async (data: any) => {
|
||||||
mutate(data, {
|
mutate(data, {
|
||||||
onSuccess: async () => {
|
onSuccess: async () => {
|
||||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
|
||||||
ref.current.reset(data);
|
ref.current.reset(data);
|
||||||
touch(`website:${website?.id}`);
|
touch(`website:${website.id}`);
|
||||||
|
onSave?.();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -38,9 +38,9 @@ export function WebsiteSettings({ websiteId, openExternal = false }) {
|
|||||||
<Item key="share">{formatMessage(labels.shareUrl)}</Item>
|
<Item key="share">{formatMessage(labels.shareUrl)}</Item>
|
||||||
<Item key="data">{formatMessage(labels.data)}</Item>
|
<Item key="data">{formatMessage(labels.data)}</Item>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
{tab === 'details' && <WebsiteEditForm websiteId={websiteId} />}
|
{tab === 'details' && <WebsiteEditForm websiteId={websiteId} onSave={handleSave} />}
|
||||||
{tab === 'tracking' && <TrackingCode websiteId={websiteId} />}
|
{tab === 'tracking' && <TrackingCode websiteId={websiteId} />}
|
||||||
{tab === 'share' && <ShareUrl websiteId={websiteId} />}
|
{tab === 'share' && <ShareUrl websiteId={websiteId} onSave={handleSave} />}
|
||||||
{tab === 'data' && <WebsiteData websiteId={websiteId} onSave={handleSave} />}
|
{tab === 'data' && <WebsiteData websiteId={websiteId} onSave={handleSave} />}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -89,3 +89,18 @@ main::-webkit-scrollbar-track {
|
|||||||
background-color: var(--base800);
|
background-color: var(--base800);
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--dark50: #111111;
|
||||||
|
--dark75: #191919;
|
||||||
|
--dark100: #222222;
|
||||||
|
--dark150: #2a2a2a;
|
||||||
|
--dark200: #313131;
|
||||||
|
--dark300: #3a3a3a;
|
||||||
|
--dark400: #484848;
|
||||||
|
--dark500: #606060;
|
||||||
|
--dark600: #6e6e6e;
|
||||||
|
--dark700: #7b7b7b;
|
||||||
|
--dark800: #b4b4b4;
|
||||||
|
--dark900: #eeeeee;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user