Skip to content

Commit d03544e

Browse files
authored
Merge pull request #10815 from marmelab/chore/update-tips
[chore] Sync tips from tips repository
2 parents da9499b + f705bfa commit d03544e

File tree

2 files changed

+66
-9
lines changed

2 files changed

+66
-9
lines changed

docs/assets/features.md_ignore

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ With your admin getting bigger, or if you have to manage many resources and/or s
118118

119119
<video controls autoplay playsinline muted loop width="100%">
120120
<source
121-
src="https://react-admin-ee.marmelab.com/assets/breadcumb-nested-resource.mp4"
121+
src="https://react-admin-ee.marmelab.com/assets/ra-navigation/latest/breadcumb-nested-resource.webm"
122122
type="video/webm"
123123
/>
124124
Your browser does not support the video tag.
@@ -177,6 +177,7 @@ Edition forms in react-admin have a built-in "Undo" feature, letting end users c
177177
`<Edit>` is designed to be a page component, passed to the edit prop of the `<Resource>` component. But you may want to let users edit a record in a dialiog without leaving the context of the list page. If so, you can use the `<EditDialog>` component. #form https://marmelab.com/react-admin/EditDialog.html
178178

179179
<video controls autoplay playsinline muted loop>
180+
<source src="https://react-admin-ee.marmelab.com/assets/edit-dialog.webm" type="video/webm">
180181
<source src="https://react-admin-ee.marmelab.com/assets/edit-dialog.mp4" type="video/mp4">
181182
Your browser does not support the video tag.
182183
</video>
@@ -186,6 +187,7 @@ Edition forms in react-admin have a built-in "Undo" feature, letting end users c
186187
If you want to let users edit a record from another page, use the `<EditInDialogButton>` component. #form https://marmelab.com/react-admin/EditInDialogButton.html
187188

188189
<video controls autoplay playsinline muted loop>
190+
<source src="https://react-admin-ee.marmelab.com/assets/ra-form-layout/latest/InDialogButtons.webm" type="video/webm">
189191
<source src="https://react-admin-ee.marmelab.com/assets/ra-form-layout/latest/InDialogButtons.mp4" type="video/mp4">
190192
Your browser does not support the video tag.
191193
</video>
@@ -215,6 +217,7 @@ Use `<ReferenceOneInput>` in an `<Edit>` or `<Create>` view to edit a record lin
215217
The `<Search>` component renders a global search input. It’s designed to be always accessible in the top `<AppBar>`. #ui https://marmelab.com/react-admin/Search.html
216218

217219
<video controls autoplay playsinline muted loop>
220+
<source src="https://react-admin-ee.marmelab.com/assets/ra-search-demo.webm" type="video/webm">
218221
<source src="https://react-admin-ee.marmelab.com/assets/ra-search-demo.mp4" type="video/mp4">
219222
Your browser does not support the video tag.
220223
</video>
@@ -231,9 +234,10 @@ The `<Configurable>` component makes another component configurable by the end u
231234

232235
---
233236

234-
In the case you want keep track of user actions, and get an overview of the activity of your admin, you can display event lists and audit logs with `<TimeLine>`, `<RecordTimeline>` and with `<EventList>` components. #activitylog #timeline #eventlog https://marmelab.com/ra-enterprise/modules/ra-audit-log
237+
In the case you want keep track of user actions, and get an overview of the activity of your admin, you can display event lists and audit logs with `<TimeLine>`, `<RecordTimeline>` and with `<EventList>` components. #activitylog #timeline #eventlog https://react-admin-ee.marmelab.com/ra-audit-log
235238

236239
<video controls autoplay playsinline muted loop>
240+
<source src="https://react-admin-ee.marmelab.com/assets/ra-audit-log/latest/ra-audit-log-event-list.webm" type="video/webm">
237241
<source src="https://react-admin-ee.marmelab.com/assets/ra-audit-log/latest/ra-audit-log-event-list.mp4" type="video/mp4">
238242
Your browser does not support the video tag.
239243
</video>
@@ -261,6 +265,7 @@ With your admin getting bigger, the default sidebar menu might become too crowde
261265
If your app needs to display **events**, **appointments**, **time intervals**, or any other kind of time-based data, you can use the `<Calendar>` component. #ui https://marmelab.com/react-admin/Calendar.html
262266

263267
<video controls autoplay playsinline muted loop>
268+
<source src="https://react-admin-ee.marmelab.com/assets/ra-calendar.webm" type="video/webm">
264269
<source src="https://react-admin-ee.marmelab.com/assets/ra-calendar.mp4" type="video/mp4">
265270
Your browser does not support the video tag.
266271
</video>
@@ -276,9 +281,10 @@ If your app needs to display **events**, **appointments**, **time intervals**, o
276281

277282
---
278283

279-
The `<SearchWithResult>` component renders a search input and the search results directly below the input. It's ideal for dashboards or menu panels. #ui #search https://marmelab.com/ra-enterprise/modules/ra-search#searchwithresult
284+
The `<SearchWithResult>` component renders a search input and the search results directly below the input. It's ideal for dashboards or menu panels. #ui #search https://react-admin-ee.marmelab.com/ra-search#searchwithresult
280285

281286
<video controls autoplay playsinline muted loop>
287+
<source src="https://react-admin-ee.marmelab.com/assets/ra-search-with-result-overview.webm" type="video/webm">
282288
<source src="https://react-admin-ee.marmelab.com/assets/ra-search-with-result-overview.mp4" type="video/mp4">
283289
Your browser does not support the video tag.
284290
</video>

docs/assets/tips.md_ignore

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,34 @@ export const PostList = () => (
12261226

12271227
---
12281228

1229+
The `canAccess` helper function allows you to check if the current user has the permissions to execute an action. You can use it to disable desired links on a menu for instance. #Role-Based-Access-Control #RBAC https://react-admin-ee.marmelab.com/ra-rbac#canaccess
1230+
1231+
```tsx
1232+
import { usePermissions, Menu } from "react-admin";
1233+
import { canAccess } from "@react-admin/ra-rbac";
1234+
1235+
const MyMenu = () => {
1236+
const { permissions } = usePermissions();
1237+
return (
1238+
<Menu>
1239+
<Menu.DashboardItem />
1240+
<Menu.Item
1241+
to="/categories"
1242+
primaryText="Categories"
1243+
disabled={
1244+
!canAccess({
1245+
permissions,
1246+
resource: "categories",
1247+
})
1248+
}
1249+
/>
1250+
</Menu>
1251+
);
1252+
};
1253+
```
1254+
1255+
---
1256+
12291257
If you render more than one `<DatagridConfigurable>` on the same page, you must pass a unique preferenceKey prop to each one. Do not forget to link their `<SelectColumnsButton>` components by giving them the same preferenceKey. #datagrid https://marmelab.com/react-admin/Datagrid.html#configurable
12301258

12311259
{% raw %}
@@ -2000,18 +2028,41 @@ You can add custom CSS classes to any column or cell in `DatagridAG` or `Datagri
20002028
{% raw %}
20012029
```tsx
20022030
const columnDefs = [
2003-
{ field: 'static', cellClass: 'my-class' },
2004-
{ field: 'staticArray', cellClass: ['my-class1','my-class2'] },
2005-
{ field: 'function', cellClass: params => params.value === 'something' ? 'my-class-1' : 'my-class-2' },
2006-
{ field: 'functionArray', cellClass: params => ['my-class-1','my-class-2'] },
2031+
// return same class for each row
2032+
{
2033+
field: 'static',
2034+
cellClass: 'my-class'
2035+
},
2036+
// return same array of classes for each row
2037+
{
2038+
field: 'staticArray',
2039+
cellClass: ['my-class1','my-class2'],
2040+
},
2041+
// return class based on function
2042+
{
2043+
field: 'function',
2044+
cellClass: params => {
2045+
return params.value === 'something' ? 'my-class-1' : 'my-class-2';
2046+
},
2047+
},
2048+
// return array of classes based on function
2049+
{
2050+
field: 'functionArray',
2051+
cellClass: params => ['my-class-1','my-class-2'],
2052+
},
2053+
// return array of classes based on many functions with `cellClassRules`
20072054
{
20082055
field: 'functionRules',
20092056
cellClassRules: {
2057+
// apply green to 2008
20102058
'rag-green-outer': params => params.value === 2008,
2059+
// apply blue to 2004
20112060
'rag-blue-outer': params => params.value === 2004,
2061+
// apply red to 2000
20122062
'rag-red-outer': params => params.value === 2000,
20132063
}
2014-
},
2064+
}
2065+
// return array of classes based on many functions with `cellClassRules`
20152066
{
20162067
field: 'simplifiedFunctionRules',
20172068
cellClassRules: {
@@ -2024,4 +2075,4 @@ const columnDefs = [
20242075
```
20252076
{% endraw %}
20262077

2027-
https://www.ag-grid.com/react-data-grid/cell-styles
2078+
https://www.ag-grid.com/react-data-grid/cell-styles

0 commit comments

Comments
 (0)