Refactored teams components.

This commit is contained in:
Mike Cao 2023-10-07 22:42:49 -07:00
parent 6253d55790
commit 8b48130d5f
18 changed files with 75 additions and 44 deletions

View file

@ -1,4 +1,5 @@
'use client';
import { ReactNode } from 'react';
import WebsitesTable from 'app/(main)/settings/websites/WebsitesTable';
import useUser from 'components/hooks/useUser';
import useApi from 'components/hooks/useApi';
@ -6,10 +7,20 @@ import DataTable from 'components/common/DataTable';
import useFilterQuery from 'components/hooks/useFilterQuery';
import useCache from 'store/cache';
export interface WebsitesDataTableProps {
allowEdit?: boolean;
allowView?: boolean;
showActions?: boolean;
showTeam?: boolean;
includeTeams?: boolean;
onlyTeams?: boolean;
children?: ReactNode;
}
function useWebsites({ includeTeams, onlyTeams }) {
const { user } = useUser();
const { get } = useApi();
const modified = useCache(state => state?.websites);
const modified = useCache((state: any) => state?.websites);
return useFilterQuery(
['websites', { includeTeams, onlyTeams, modified }],
@ -32,7 +43,7 @@ export function WebsitesDataTable({
includeTeams,
onlyTeams,
children,
}) {
}: WebsitesDataTableProps) {
const queryResult = useWebsites({ includeTeams, onlyTeams });
return (

View file

@ -3,12 +3,12 @@ import useMessages from 'components/hooks/useMessages';
import PageHeader from 'components/layout/PageHeader';
import WebsiteAddButton from './WebsiteAddButton';
export function WebsitesHeader() {
export function WebsitesHeader({ showActions = true }) {
const { formatMessage, labels } = useMessages();
return (
<PageHeader title={formatMessage(labels.websites)}>
{!process.env.cloudMode && <WebsiteAddButton />}
{!process.env.cloudMode && showActions && <WebsiteAddButton />}
</PageHeader>
);
}

View file

@ -1,11 +1,8 @@
import WebsitesDataTable from './WebsitesDataTable';
import WebsitesHeader from './WebsitesHeader';
import { Metadata } from 'next';
export default function () {
if (process.env.cloudMode) {
return null;
}
return (
<>
<WebsitesHeader />
@ -13,3 +10,7 @@ export default function () {
</>
);
}
export const metadata: Metadata = {
title: 'Websites Settings | umami',
};