mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Fixed cancel of dashboard edit.
This commit is contained in:
parent
1d4aa7c535
commit
42e87a4691
@ -6,6 +6,7 @@ import Button from 'components/common/Button';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { orderByWebsiteMap } from 'lib/format';
|
import { orderByWebsiteMap } from 'lib/format';
|
||||||
import styles from './DashboardEdit.module.css';
|
import styles from './DashboardEdit.module.css';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
save: { id: 'label.save', defaultMessage: 'Save' },
|
save: { id: 'label.save', defaultMessage: 'Save' },
|
||||||
@ -45,18 +46,17 @@ export default function DashboardEdit({ data: websites }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleCancel() {
|
function handleCancel() {
|
||||||
saveDashboard({ editing: false });
|
saveDashboard({ editing: false, websiteOrder });
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleReset() {
|
function handleReset() {
|
||||||
setOrder({});
|
setOrder({});
|
||||||
saveDashboard({ websiteOrder: {} });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.buttons}>
|
<div className={styles.buttons}>
|
||||||
<Button onClick={handleSave} size="small">
|
<Button onClick={handleSave} variant="action" size="small">
|
||||||
{formatMessage(messages.save)}
|
{formatMessage(messages.save)}
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleCancel} size="small">
|
<Button onClick={handleCancel} size="small">
|
||||||
@ -77,15 +77,19 @@ export default function DashboardEdit({ data: websites }) {
|
|||||||
>
|
>
|
||||||
{ordered.map(({ website_id, name, domain }, index) => (
|
{ordered.map(({ website_id, name, domain }, index) => (
|
||||||
<Draggable key={website_id} draggableId={`${dragId}-${website_id}`} index={index}>
|
<Draggable key={website_id} draggableId={`${dragId}-${website_id}`} index={index}>
|
||||||
{provided => (
|
{(provided, snapshot) => (
|
||||||
<div
|
<div
|
||||||
ref={provided.innerRef}
|
ref={provided.innerRef}
|
||||||
|
className={classNames(styles.item, {
|
||||||
|
[styles.active]: snapshot.isDragging,
|
||||||
|
})}
|
||||||
{...provided.draggableProps}
|
{...provided.draggableProps}
|
||||||
{...provided.dragHandleProps}
|
{...provided.dragHandleProps}
|
||||||
className={styles.item}
|
|
||||||
>
|
>
|
||||||
<h1>{name}</h1>
|
<div className={styles.text}>
|
||||||
<h2>{domain}</h2>
|
<h1>{name}</h1>
|
||||||
|
<h2>{domain}</h2>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Draggable>
|
</Draggable>
|
||||||
|
@ -6,13 +6,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.item {
|
.item {
|
||||||
padding: 20px;
|
padding: 5px 0;
|
||||||
border-radius: 5px;
|
|
||||||
border: 1px solid var(--gray300);
|
|
||||||
}
|
|
||||||
|
|
||||||
.item + .item {
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.item h1 {
|
.item h1 {
|
||||||
@ -25,6 +19,18 @@
|
|||||||
color: var(--gray700);
|
color: var(--gray700);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid var(--gray400);
|
||||||
|
background: var(--gray50);
|
||||||
|
}
|
||||||
|
|
||||||
|
.active .text {
|
||||||
|
border-color: var(--gray600);
|
||||||
|
box-shadow: 4px 4px 4px var(--gray100);
|
||||||
|
}
|
||||||
|
|
||||||
.dragActive {
|
.dragActive {
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FormattedMessage } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import Link from 'components/common/Link';
|
import Link from 'components/common/Link';
|
||||||
import WebsiteChart from 'components/metrics/WebsiteChart';
|
import WebsiteChart from 'components/metrics/WebsiteChart';
|
||||||
import Page from 'components/layout/Page';
|
import Page from 'components/layout/Page';
|
||||||
@ -9,24 +9,29 @@ import useDashboard from 'store/dashboard';
|
|||||||
import { orderByWebsiteMap } from 'lib/format';
|
import { orderByWebsiteMap } from 'lib/format';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
|
const messages = defineMessages({
|
||||||
|
noWebsites: {
|
||||||
|
id: 'message.no-websites-configured',
|
||||||
|
defaultMessage: "You don't have any websites configured.",
|
||||||
|
},
|
||||||
|
goToSettngs: {
|
||||||
|
id: 'message.go-to-settings',
|
||||||
|
defaultMessage: 'Go to settings',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export default function WebsiteList({ data, showCharts, limit }) {
|
export default function WebsiteList({ data, showCharts, limit }) {
|
||||||
const { websiteOrder } = useDashboard();
|
const { websiteOrder } = useDashboard();
|
||||||
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
const websites = useMemo(() => orderByWebsiteMap(data, websiteOrder), [data, websiteOrder]);
|
const websites = useMemo(() => orderByWebsiteMap(data, websiteOrder), [data, websiteOrder]);
|
||||||
|
|
||||||
if (websites.length === 0) {
|
if (websites.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<EmptyPlaceholder
|
<EmptyPlaceholder msg={formatMessage(messages.noWebsites)}>
|
||||||
msg={
|
|
||||||
<FormattedMessage
|
|
||||||
id="message.no-websites-configured"
|
|
||||||
defaultMessage="You don't have any websites configured."
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Link href="/settings" icon={<Arrow />} iconRight>
|
<Link href="/settings" icon={<Arrow />} iconRight>
|
||||||
<FormattedMessage id="message.go-to-settings" defaultMessage="Go to settings" />
|
{formatMessage(messages.goToSettngs)}
|
||||||
</Link>
|
</Link>
|
||||||
</EmptyPlaceholder>
|
</EmptyPlaceholder>
|
||||||
</Page>
|
</Page>
|
||||||
|
Loading…
Reference in New Issue
Block a user