fix sharetable UI/CSS issues
This commit is contained in:
1 parent
2fe062c49e
commit
41e9ad38f1
5 files changed
+313
-142
No files matched your search
@@ -1,59 +1,18 @@
|
||||
import { DataColumn, DataTable, Icon, type DataTableProps, Row, Text } from '@umami/react-zen';
|
||||
import { ShareDeleteButton } from '@/app/(main)/websites/[websiteId]/settings/ShareDeleteButton';
|
||||
import { CopyButton } from '@/components/common/CopyButton';
|
||||
import Link from '@/components/common/Link';
|
||||
import { useConfig, useMessages, useMobile } from '@/components/hooks';
|
||||
import { ExternalLink } from '@/components/icons';
|
||||
import { Row, type DataTableProps } from '@umami/react-zen';
|
||||
import { SimpleShareEditButton } from './SimpleShareEditButton';
|
||||
import { SharedSharesTable } from './SharedSharesTable';
|
||||
|
||||
export function SimpleSharesTable(props: DataTableProps) {
|
||||
const { t, labels } = useMessages();
|
||||
const config = useConfig();
|
||||
const cloudMode = config?.cloudMode;
|
||||
const { isMobile } = useMobile();
|
||||
|
||||
const getUrl = (slug: string) => {
|
||||
if (cloudMode) {
|
||||
return `${process.env.cloudUrl}/share/${slug}`;
|
||||
}
|
||||
|
||||
return `${window?.location.origin}${process.env.basePath || ''}/share/${slug}`;
|
||||
};
|
||||
|
||||
return (
|
||||
<DataTable {...props} displayMode={isMobile ? 'cards' : 'table'}>
|
||||
<DataColumn id="name" label={t(labels.name)}>
|
||||
{({ name }: any) => name}
|
||||
</DataColumn>
|
||||
<DataColumn id="slug" label={t(labels.shareUrl)} width="2fr" style={{ minWidth: 0 }}>
|
||||
{({ slug }: any) => {
|
||||
const url = getUrl(slug);
|
||||
|
||||
return (
|
||||
<Row alignItems="center" gap="1" minWidth="0" width="100%" overflow="hidden">
|
||||
<Row alignItems="center" gap minWidth="0" style={{ flex: 1 }}>
|
||||
<Text title={url} style={{ minWidth: 0, flex: 1, overflowWrap: 'anywhere' }}>
|
||||
<Link href={url} target="_blank" prefetch={false}>
|
||||
{isMobile ? slug : url}
|
||||
</Link>
|
||||
</Text>
|
||||
<Icon size="sm" strokeColor="muted" style={{ flexShrink: 0 }}>
|
||||
<ExternalLink />
|
||||
</Icon>
|
||||
</Row>
|
||||
<CopyButton value={url} label="Copy URL" />
|
||||
</Row>
|
||||
);
|
||||
}}
|
||||
</DataColumn>
|
||||
<DataColumn id="action" align="end" width="100px">
|
||||
{({ id, slug }: any) => (
|
||||
<SharedSharesTable
|
||||
data={props.data as any[]}
|
||||
renderActions={({ id, slug }) => (
|
||||
<Row>
|
||||
<SimpleShareEditButton shareId={id} />
|
||||
<ShareDeleteButton shareId={id} slug={slug} />
|
||||
</Row>
|
||||
)}
|
||||
</DataColumn>
|
||||
</DataTable>
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user