Skip to content

Commit

Permalink
Merge branch 'main' of github.com:strapi/documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pwizla committed Sep 23, 2024
2 parents 47ed0fa + 7107def commit a2ec741
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ This component has been removed and not replaced. If you feel like you need this

We recommend using the `Page.Protect` component from `@strapi/strapi/admin` instead (see [`CheckPagePermissions`](#checkpagepermissions) for an example). If you need to check permissions for a lower level component you can use [the `useRBAC` hook](#userbac).


### CheckPagePermissions

This component has been removed and refactored to be part of the `Page` component exported from `@strapi/strapi/admin`. You should use the `Page` component from there:
Expand Down Expand Up @@ -153,11 +152,18 @@ import { FilterListURLQuery } from '@strapi/helper-plugin';

const MyComponent = () => {
return (
<FilterListURLQuery filtersSchema={[{name: 'name', metadatas: {label: 'Name'}, fieldSchema: {type: 'string'}}]} />
<FilterListURLQuery
filtersSchema={[
{
name: 'name',
metadatas: { label: 'Name' },
fieldSchema: { type: 'string' },
},
]}
/>
);
};


// After
import { Filters } from '@strapi/strapi/admin';

Expand Down Expand Up @@ -237,6 +243,13 @@ Note, that the `InputRenderer` component has a different API, and you should ref
This component has been removed and not replaced. However, you can easily replicate this in your own project by using the `useStrapiApp` hook:

```tsx
// Before

import { InjectionZone } from '@strapi/helper-plugin';
<InjectionZone area={`injection.zone.area`} />;

// After

const MyComponent = ({ area, ...compProps }) => {
const getPlugin = useStrapiApp('MyComponent', (state) => state.getPlugin);

Expand Down Expand Up @@ -536,14 +549,16 @@ const MyComponent = () => {
return (
<Tr key={name}>
<Td>
<Typography textColor="neutral800" variant="omega" fontWeight="bold">
<Typography
textColor="neutral800"
variant="omega"
fontWeight="bold"
>
{name}
</Typography>
</Td>
<Td>
<Typography textColor="neutral800">
{description}
</Typography>
<Typography textColor="neutral800">{description}</Typography>
</Td>
</Tr>
);
Expand All @@ -553,7 +568,6 @@ const MyComponent = () => {
);
};


// After
import { Table } from '@strapi/strapi/admin';
```
Expand Down Expand Up @@ -603,11 +617,19 @@ const {
} = useContentManagerContext();
```

- `allLayoutData` has been removed.
```tsx
// Before

// 'allLayoutData' has been removed. It contained 'components' and 'contentType' which can be extracted from the 'useContentManagerContext' hook as seen below.
const { allLayoutData } = useCMEditViewDataManager();

// After
const { components, contentType } = useContentManagerContext();
```

```tsx
// Before
const { layout, allLayoutData } = useCMEditViewDataManager();
const { layout } = useCMEditViewDataManager();

// After
const { layout } = useContentManagerContext();
Expand All @@ -625,6 +647,7 @@ const { initialData, modifiedData, onChange } = useCMEditViewDataManager();
// After
const { form } = useContentManagerContext();

// Here 'initialData' and 'modifiedData' correspond to 'initialValues' and 'values'.
const { initialValues, values, onChange } = form;
```

Expand Down Expand Up @@ -907,9 +930,10 @@ This util has been removed. If you need to use it, you should use the `checkUser
// Before
import { hasPermissions } from '@strapi/helper-plugin';


const permissions = await Promise.all(
generalSectionRawLinks.map(({ permissions }) => hasPermissions(userPermissions, permissions))
generalSectionRawLinks.map(({ permissions }) =>
hasPermissions(userPermissions, permissions)
)
);

// After
Expand Down
2 changes: 1 addition & 1 deletion docusaurus/docs/dev-docs/typescript/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ To do that, edit the `tsconfig.json` of the Strapi project and add `types/genera
However, if you still want to use the generated types on your project, but don't want Strapi to use them, a workaround could be to copy those generated types and paste them outside of the `generated` directory (so that they aren't overwritten when the types are regenerated) and remove the `declare module '@strapi/types'` from the bottom of the file.

:::warning
Types should only be imported from `@strapi/strapi` to avoid breaking changes. The types in `@strapi/types` is for internal use only and is subject to change without notice.
Types should only be imported from `@strapi/strapi` to avoid breaking changes. The types in `@strapi/types` are for internal use only and may change without notice.
:::

## Start Strapi programmatically
Expand Down

0 comments on commit a2ec741

Please sign in to comment.