Skip to content

Commit

Permalink
chore: pr fixes & amends
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaellis committed Jan 12, 2024
1 parent 250f5d2 commit d58a331
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 37 deletions.
10 changes: 7 additions & 3 deletions packages/core/admin/admin/src/StrapiApp.tsx
Expand Up @@ -16,7 +16,7 @@ import { Helmet } from 'react-helmet';
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import { DefaultTheme } from 'styled-components';

import { ROUTES_EE as BaseEERoutes } from '../../ee/admin/src/constants';
import { ROUTES_EE as BASE_ROUTES_EE } from '../../ee/admin/src/constants';
import { ROUTES_EE } from '../../ee/admin/src/pages/SettingsPage/constants';

import { App } from './App';
Expand Down Expand Up @@ -412,7 +412,11 @@ class StrapiApp {

createSettingSection = (
section: StrapiAppSetting,
links: Array<Parameters<typeof this.addSettingsLink>[1]>
links: Array<
Omit<StrapiAppSettingLink, 'Component'> & {
Component: () => Promise<{ default: React.ComponentType }>;
}
>
) => {
invariant(section.id, 'section.id should be defined');
invariant(
Expand Down Expand Up @@ -750,7 +754,7 @@ class StrapiApp {
</React.Suspense>
),
})),
...BaseEERoutes(),
...BASE_ROUTES_EE(),
...cmRoutes,
],
},
Expand Down
Expand Up @@ -100,9 +100,7 @@ const ContentTypeFormWrapper = ({
const { put, post, del } = fetchClient;

const isSingleType = collectionType === 'single-types';
const [isCreatingEntry, setIsCreatingEntry] = React.useState(
(!isSingleType && !id) || id === 'create'
);
const isCreatingEntry = (!isSingleType && !id) || id === 'create';

const requestURL =
isCreatingEntry && !origin
Expand Down Expand Up @@ -189,7 +187,6 @@ const ContentTypeFormWrapper = ({
return;
} else if (resStatus === 404 && isSingleType) {
// Creating a single type
setIsCreatingEntry(true);
dispatch(initForm(rawQuery, true));
}

Expand Down Expand Up @@ -260,7 +257,6 @@ const ContentTypeFormWrapper = ({
trackUsage('didDeleteEntry', trackerProperty);

if (isSingleType) {
setIsCreatingEntry(true);
dispatch(initForm(rawQuery, true));
} else {
navigate(redirectionLink, { replace: true });
Expand Down Expand Up @@ -329,7 +325,6 @@ const ContentTypeFormWrapper = ({

// TODO: need to find a better place, or a better abstraction
queryClient.invalidateQueries(['relation']);
setIsCreatingEntry(false);

dispatch(submitSucceeded(cleanReceivedData(data)));

Expand Down
Expand Up @@ -743,7 +743,8 @@ const EditViewDataManagerProvider = ({
publishConfirmation,
}}
>
{isLoadingForData || (!isCreatingEntry && !initialData.id) ? (
{/* with SingleTypes, we'll never be creating the entry and there won't ever be an id because thats not how single types work. */}
{isLoadingForData || (!isCreatingEntry && !initialData.id && !isSingleType) ? (
<Main aria-busy="true">
<LoadingIndicatorPage />
</Main>
Expand Down
Expand Up @@ -6,7 +6,7 @@ import { useQuery } from 'react-query';

import { useTypedSelector } from '../../core/store/hooks';
import { selectSchemas } from '../pages/App';
import { FormattedLayouts, formatLayouts } from '../utils/layouts';
import { type FormattedLayouts, formatLayouts } from '../utils/layouts';

const useContentTypeLayout = (contentTypeUID: string = '') => {
const schemas = useTypedSelector(selectSchemas);
Expand Down
Expand Up @@ -26,7 +26,7 @@ import type { Contracts } from '@strapi/plugin-content-manager/_internal/shared'
* -----------------------------------------------------------------------------------------------*/

const App = () => {
const contentTypeMatch = useMatch(`/content-manager/:kind/:uid/*`);
const contentTypeMatch = useMatch('/content-manager/:kind/:uid/*');
const { isLoading, collectionTypeLinks, models, singleTypeLinks } = useContentManagerInitData();
const { pathname } = useLocation();
const { formatMessage } = useIntl();
Expand Down
Expand Up @@ -8,10 +8,11 @@ import { HOOKS } from '../../constants';
import { useTypedDispatch, useTypedSelector } from '../../core/store/hooks';
import { useContentTypeLayout } from '../hooks/useLayouts';
import { useSyncRbac } from '../hooks/useSyncRbac';
import { FormattedLayouts } from '../utils/layouts';

import { ProtectedEditViewPage } from './EditView/EditViewPage';

import type { FormattedLayouts } from '../utils/layouts';

const { MUTATE_EDIT_VIEW_LAYOUT } = HOOKS;

/* -------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/admin/src/pages/Settings/constants.ts
@@ -1,4 +1,4 @@
import { RouteObject } from 'react-router-dom';
import type { RouteObject } from 'react-router-dom';

export const ROUTES_CE: RouteObject[] = [
{
Expand Down
Expand Up @@ -11,7 +11,7 @@ import {
import { TableRowProps, onRowClick, stopPropagation } from '@strapi/helper-plugin';
import { Pencil, Trash } from '@strapi/icons';
import { useIntl } from 'react-intl';
import { useNavigate } from 'react-router-dom';
import { NavLink, useNavigate } from 'react-router-dom';

import { SanitizedAdminUser } from '../../../../../../../shared/contracts/shared';
import { getFullName } from '../../../../../utils/getFullName';
Expand Down Expand Up @@ -84,7 +84,9 @@ const TableRows = ({
<Td>
<Flex justifyContent="end">
<IconButton
onClick={() => navigate(data.id.toString())}
forwardedAs={NavLink}
// @ts-expect-error – This is an issue in the DS with the as prop not adding the inferred props to the component.
to={data.id.toString()}
label={formatMessage(
{ id: 'app.component.table.edit', defaultMessage: 'Edit {target}' },
{ target: getFullName(data.firstname ?? '', data.lastname) }
Expand Down
Expand Up @@ -389,16 +389,18 @@ const ListPage = () => {
defaultMessage: 'No webhooks found',
})}
action={
<Button
variant="secondary"
startIcon={<Plus />}
onClick={() => (canCreate ? navigate('create') : {})}
>
{formatMessage({
id: 'Settings.webhooks.list.button.add',
defaultMessage: 'Create new webhook',
})}
</Button>
canCreate ? (
<Button
variant="secondary"
startIcon={<Plus />}
onClick={() => navigate('create')}
>
{formatMessage({
id: 'Settings.webhooks.list.button.add',
defaultMessage: 'Create new webhook',
})}
</Button>
) : null
}
/>
)}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/admin/ee/admin/src/constants.ts
@@ -1,7 +1,6 @@
import { RouteObject } from 'react-router-dom';

import type { SettingsMenu } from '../../../admin/src/constants';
import type { PermissionMap } from '../../../admin/src/types/permissions';
import type { RouteObject } from 'react-router-dom';

export const ADMIN_PERMISSIONS_EE = {
settings: {
Expand Down
Expand Up @@ -95,7 +95,7 @@ export const ReviewWorkflowsCreatePage = () => {
},
});

navigate(res.data.id.toString(), { replace: true });
navigate(res.data.id.toString());
} catch (error) {
toggleNotification({
type: 'warning',
Expand Down
Expand Up @@ -276,7 +276,6 @@ export const CMReleasesContainer = () => {

/**
* - Impossible to add entry to release before it exists
* - Content types without draft and publish cannot add entries to release
*/
if (isCreatingEntry) {
return null;
Expand Down
Expand Up @@ -7,7 +7,7 @@ import {
} from '@strapi/helper-plugin';
import { stringify } from 'qs';
import { useIntl } from 'react-intl';
import { useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import styled from 'styled-components';

import { I18nBaseQuery } from '../types';
Expand Down
Expand Up @@ -48,14 +48,10 @@ const TableBody = ({ sortedRoles, canDelete, permissions, setRoleToDelete, onDel
setShowConfirmDelete(!showConfirmDelete);
};

const handleClickEdit = (id) => {
navigate(`/settings/users-permissions/roles/${id}`);
};

return (
<Tbody>
{sortedRoles?.map((role) => (
<Tr key={role.name} {...onRowClick({ fn: () => handleClickEdit(role.id) })}>
<Tr key={role.name} {...onRowClick({ fn: () => navigate(role.id) })}>
<Td width="20%">
<Typography>{role.name}</Typography>
</Td>
Expand All @@ -77,7 +73,7 @@ const TableBody = ({ sortedRoles, canDelete, permissions, setRoleToDelete, onDel
<Flex justifyContent="end" {...stopPropagation}>
<CheckPermissions permissions={permissions.updateRole}>
<EditLink
to={`/settings/users-permissions/roles/${role.id}`}
to={role.id}
aria-label={formatMessage(
{ id: 'app.component.table.edit', defaultMessage: 'Edit {target}' },
{ target: `${role.name}` }
Expand Down

0 comments on commit d58a331

Please sign in to comment.