Skip to content

Commit 196ad05

Browse files
committed
feat: enhance the URL alias overview (locale filters & locale and contenttype in the table)
1 parent 73128f9 commit 196ad05

File tree

6 files changed

+51
-9
lines changed

6 files changed

+51
-9
lines changed

.changeset/lazy-sides-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"strapi-plugin-webtools": minor
3+
---
4+
5+
feat: enhance the URL alias overview (locale filters & locale and contenttype in the table)

packages/core/admin/screens/List/components/Filters/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import {
1010
import { Filters as StrapiFilters, SearchInput } from '@strapi/strapi/admin';
1111
import FilterInput from './FilterInput';
1212
import { EnabledContentType, EnabledContentTypes } from '../../../../types/enabled-contenttypes';
13+
import { Locales } from '../../../../types/languages';
1314

1415
type Props = {
1516
contentTypes: EnabledContentTypes,
17+
locales: Locales,
1618
};
1719

18-
const Filters = ({ contentTypes }: Props) => {
20+
const Filters = ({ contentTypes, locales }: Props) => {
1921
const { formatMessage } = useIntl();
2022

2123
const filters = useMemo(() => {
@@ -27,12 +29,22 @@ const Filters = ({ contentTypes }: Props) => {
2729
input: FilterInput,
2830
label: 'Content-Type',
2931
name: 'contenttype',
30-
options: contentTypes.map((contenttype: EnabledContentType) => ({
32+
options: contentTypes.map((contenttype) => ({
3133
label: contenttype.name,
3234
value: contenttype.uid,
3335
})),
3436
type: 'string',
3537
},
38+
{
39+
input: FilterInput,
40+
label: 'Locale',
41+
name: 'locale',
42+
options: locales.map((locale) => ({
43+
label: locale.name,
44+
value: locale.uid,
45+
})),
46+
type: 'string',
47+
},
3648
);
3749
}
3850

packages/core/admin/screens/List/components/Table/index.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import type { Pagination } from '../..';
2323
import Filters from '../Filters';
2424
import { Config } from '../../../../../server/config';
2525
import { UrlAliasEntity } from '../../../../types/url-aliases';
26+
import { Locales } from '../../../../types/languages';
2627

2728
type Props = {
2829
paths: UrlAliasEntity[],
2930
onDelete: () => any,
3031
pagination: Pagination,
3132
contentTypes: any[],
33+
locales: Locales,
3234
config: Config,
3335
};
3436

@@ -39,6 +41,7 @@ const TableComponent: FC<Props> = (props) => {
3941
onDelete,
4042
config,
4143
contentTypes,
44+
locales,
4245
} = props;
4346

4447
const { formatMessage } = useIntl();
@@ -60,7 +63,7 @@ const TableComponent: FC<Props> = (props) => {
6063

6164
return (
6265
<div>
63-
<Filters contentTypes={contentTypes} />
66+
<Filters contentTypes={contentTypes} locales={locales} />
6467
{amountChecked > 0 && (
6568
<Flex marginBottom="6" gap="3">
6669
<Typography variant="omega" textColor="neutral600">
@@ -93,7 +96,17 @@ const TableComponent: FC<Props> = (props) => {
9396
</Th> */}
9497
<Th>
9598
<Typography variant="sigma" textColor="neutral600">
96-
{formatMessage({ id: 'webtools.settings.page.patterns.table.head.label', defaultMessage: 'Path' })}
99+
{formatMessage({ id: 'webtools.settings.page.path.table.head.path', defaultMessage: 'Path' })}
100+
</Typography>
101+
</Th>
102+
<Th>
103+
<Typography variant="sigma" textColor="neutral600">
104+
{formatMessage({ id: 'webtools.settings.page.path.table.head.content-type', defaultMessage: 'Content-Type' })}
105+
</Typography>
106+
</Th>
107+
<Th>
108+
<Typography variant="sigma" textColor="neutral600">
109+
{formatMessage({ id: 'webtools.settings.page.path.table.head.locale', defaultMessage: 'Locale' })}
97110
</Typography>
98111
</Th>
99112
</Tr>

packages/core/admin/screens/List/components/TableRow/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ const TableRow: FC<Props> = ({
7171
<Typography>{row.url_path}</Typography>
7272
</Box>
7373
</Td>
74+
<Td>
75+
<Box style={{ marginTop: 5, marginBottom: 5 }}>
76+
<Typography>{row.contenttype}</Typography>
77+
</Box>
78+
</Td>
79+
<Td>
80+
<Box style={{ marginTop: 5, marginBottom: 5 }}>
81+
<Typography>{row.locale}</Typography>
82+
</Box>
83+
</Td>
7484
<Td>
7585
<Flex justifyContent="end">
7686
{config.website_url && (

packages/core/admin/screens/List/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { GenericResponse } from '../../types/content-api';
2424
import { Config } from '../../../server/config';
2525
import { UrlAliasEntity } from '../../types/url-aliases';
2626
import useQueryParams from '../../hooks/useQueryParams';
27+
import { Locales } from '../../types/languages';
2728

2829
export type Pagination = {
2930
page: number;
@@ -38,6 +39,7 @@ const List = () => {
3839

3940
const items = useQuery(['url-alias', params], async () => get<GenericResponse<UrlAliasEntity[]>>(`/webtools/url-alias/findMany?${params}`));
4041
const contentTypes = useQuery('content-types', async () => get<EnabledContentTypes>('/webtools/info/getContentTypes'));
42+
const locales = useQuery('languages', async () => get<Locales>('/webtools/info/getLanguages'));
4143
const config = useQuery('config', async () => get<Config>('/webtools/info/config'));
4244
const queryClient = useQueryClient();
4345

@@ -58,21 +60,20 @@ const List = () => {
5860
await queryClient.invalidateQueries('url-alias');
5961
};
6062

61-
if (items.isLoading || config.isLoading || contentTypes.isLoading) {
63+
if (items.isLoading || config.isLoading || contentTypes.isLoading || locales.isLoading) {
6264
return (
6365
<Loader />
6466
);
6567
}
6668

67-
if (items.isError || config.isError || contentTypes.isError) {
69+
if (items.isError || config.isError || contentTypes.isError || locales.isError) {
6870
return (
6971
<div>error</div>
7072
);
7173
}
7274

7375
return (
7476
<Page.Protect permissions={pluginPermissions['settings.patterns']}>
75-
{false && <Loader />}
7677
<Layouts.Header
7778
title={formatMessage({ id: 'webtools.settings.page.list.title', defaultMessage: 'URLs' })}
7879
subtitle={formatMessage({ id: 'webtools.settings.page.list.description', defaultMessage: 'A list of all the known URL aliases.' })}
@@ -97,6 +98,7 @@ const List = () => {
9798
pagination={items.data.data.meta.pagination}
9899
onDelete={() => queryClient.invalidateQueries('url-alias')}
99100
config={config.data.data}
101+
locales={locales.data.data}
100102
contentTypes={contentTypes.data.data}
101103
/>
102104
</Layouts.Content>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export interface EnabledContentType {
1+
export interface Locale {
22
name: string,
33
uid: string,
44
}
55

6-
export type EnabledContentTypes = EnabledContentType[];
6+
export type Locales = Locale[];

0 commit comments

Comments
 (0)