Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-zoos-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-plugin-webtools": patch
---

show spinner when bulk generating aliases
2 changes: 1 addition & 1 deletion packages/core/admin/containers/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const App = () => {
<Route path="/patterns/new" element={<PatternsCreatePage />} />
<Route path="/patterns/:id" element={<PatternsEditPage />} />
{routerComponents.map(({ path, Component }) => (
<Route path={path} element={<Component />} />
<Route key={path} path={path} element={<Component />} />
))}

<Route path="*" element={<PageNotFound />} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const GeneratePathsModal = ({
contentTypes,
children,
}: Props) => {
const [open, setOpen] = React.useState<boolean>();
const [open, setOpen] = React.useState<boolean>(false);
const [submitting, setSubmitting] = React.useState<boolean>(false);
const { formatMessage } = useIntl();
const [selectedContentTypes, setSelectedContentTypes] = React.useState<EnabledContentType['uid'][]>([]);
const [selectedGenerationType, setSelectedGenerationType] = React.useState<GenerationType>();
Expand Down Expand Up @@ -62,6 +63,7 @@ const GeneratePathsModal = ({
<Flex direction="column" alignItems="start" gap="1" marginTop="2">
{contentTypes.map((contentType) => (
<Checkbox
key={contentType.uid}
aria-label={`Select ${contentType.name}`}
checked={selectedContentTypes.includes(contentType.uid)}
onCheckedChange={() => {
Expand Down Expand Up @@ -134,13 +136,19 @@ const GeneratePathsModal = ({
<Button
// eslint-disable-next-line @typescript-eslint/no-misused-promises
onClick={async () => {
await onSubmit(selectedContentTypes, selectedGenerationType);
setOpen(false);
try {
setSubmitting(true);
await onSubmit(selectedContentTypes, selectedGenerationType);
setOpen(false);
} finally {
setSubmitting(false);
}
}}
loading={submitting}
>
{formatMessage({
id: 'webtools.settings.button.generate_paths',
defaultMessage: 'Generate paths',
defaultMessage: 'Bulk generate',
})}
</Button>
</Modal.Footer>
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/screens/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const List = () => {
<Button>
{formatMessage({
id: 'webtools.settings.button.generate_paths',
defaultMessage: 'Generate paths',
defaultMessage: 'Bulk generate',
})}
</Button>
</GeneratePathsModal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ContentTypesList = (props: Props) => {
</Thead>
<Tbody>
{contentTypes.map((contenttype) => (
<Tr>
<Tr key={contenttype.uid}>
<Td width="50%">
<Typography>{contenttype.name}</Typography>
</Td>
Expand Down
1 change: 1 addition & 0 deletions packages/core/admin/screens/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const List = () => {
width: '240px',
}}
id="fourth"
key={addon.info.name}
>
<CardBody>
<Box padding={2} background="primary100">
Expand Down
4 changes: 1 addition & 3 deletions packages/core/server/services/bulk-generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ const generateUrlAliases = async (params: GenerateParams): Promise<number> => {
}

let relations: string[] = [];
let languages: string[] = [undefined];

languages = [];
const locales = await strapi.documents('plugin::i18n.locale').findMany({});
languages = locales.map((locale) => locale.code);
const languages = locales.map((locale) => locale.code);

// Get all relations for the type
await Promise.all(languages.map(async (lang) => {
Expand Down
14 changes: 2 additions & 12 deletions packages/core/server/util/enabledContentTypes.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import get from 'lodash/get';
import { Schema } from '@strapi/strapi';

import { pluginId } from './pluginId';

export const isContentTypeEnabled = (ct: Schema.ContentType) => {
let contentType: Schema.ContentType;

if (typeof ct === 'string') {
contentType = strapi.contentTypes[ct];
} else {
contentType = ct;
}

export const isContentTypeEnabled = (contentType: Schema.ContentType) => {
const { pluginOptions } = contentType;

return get(pluginOptions, [pluginId, 'enabled'], false) as boolean;
return get(pluginOptions, ['webtools', 'enabled'], false) as boolean;
};