Skip to content

Commit cd434a1

Browse files
committed
Merge branch 'next' into offline-support-reference-input
2 parents d26a330 + c9bd470 commit cd434a1

29 files changed

+14391
-8256
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: 📕 Deploy headless docs
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- next # TODO remove
7+
pull_request: # TODO remove
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
pages: write
15+
contents: write
16+
17+
jobs:
18+
deploy:
19+
name: 📕 Deploy headless docs
20+
runs-on: ubuntu-latest
21+
22+
env:
23+
PRODUCTION_REMOTE: https://git:${{ secrets.DEPLOY_TOKEN }}@github.com/${{ vars.DEPLOY_REPOSITORY }}
24+
25+
steps:
26+
- name: 📥 Checkout repo
27+
uses: actions/checkout@v4
28+
29+
- name: ⚙️ Setup node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
cache: yarn
34+
35+
- name: ⚙️ Setup git
36+
run: |
37+
echo Deploying to pages to $PRODUCTION_REMOTE
38+
git remote set-url origin https://git:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}
39+
git remote add production $PRODUCTION_REMOTE
40+
git config --global user.email [email protected]
41+
git config --global user.name github-actions-bot
42+
43+
- name: 📥 Download deps
44+
run: yarn install --frozen-lockfile
45+
46+
- name: 🔨 Build
47+
run: |
48+
cd docs_headless
49+
yarn build
50+
cd ..
51+
52+
- name: 📡 Deploy GitHub pages
53+
run: yarn gh-pages --remote production -d docs_headless/dist -b ${{ vars.DEPLOY_BRANCH || 'gh-pages' }}
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }}

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ cypress/screenshots
2323
!.yarn/plugins
2424
!.yarn/releases
2525
!.yarn/sdks
26-
!.yarn/versions
26+
!.yarn/versions
27+
.astro

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ build: build-ra-core build-ra-data-fakerest build-ra-ui-materialui build-ra-data
117117
doc: ## compile doc as html and launch doc web server
118118
@yarn doc
119119

120+
doc-headless: ## launch headless doc web server
121+
@cd docs_headless && yarn dev
122+
120123
docker-doc: ## run the doc website in a docker container
121124
@docker run -it --rm \
122125
-p 4000:4000 \

docs/ReferenceField.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,9 @@ You can also use a custom `link` function to get a custom path for the children.
176176

177177
## `offline`
178178

179-
`<ReferenceField>` can display a custom message when the referenced record is missing because there is no network connectivity, thanks to the `offline` prop.
179+
When the user is offline, `<ReferenceField>` is smart enough to display the referenced record if it was previously fetched. However, if the referenced record has never been fetched before, `<ReferenceField>` displays an error message explaining that the app has lost network connectivity.
180180

181-
```jsx
182-
<ReferenceField source="user_id" reference="users" offline="No network, could not fetch data" >
183-
...
184-
</ReferenceField>
185-
```
186-
187-
`<ReferenceField>` renders the `offline` element when:
188-
189-
- the referenced record is missing (no record in the `users` table with the right `user_id`), and
190-
- there is no network connectivity
191-
192-
You can pass either a React element or a string to the `offline` prop:
181+
You can customize this error message by passing a React element or a string to the `offline` prop:
193182

194183
```jsx
195184
<ReferenceField source="user_id" reference="users" offline={<span>No network, could not fetch data</span>} >

docs/ReferenceFieldBase.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,15 @@ You can pass either a React element or a string to the `empty` prop:
129129

130130
## `offline`
131131

132-
`<ReferenceFieldBase>` can display a custom message when the referenced record is missing because there is no network connectivity, thanks to the `offline` prop.
132+
When the user is offline, `<ReferenceFieldBase>` is smart enough to display the referenced record if it was previously fetched. However, if the referenced record has never been fetched before, `<ReferenceFieldBase>` displays an error message explaining that the app has lost network connectivity.
133133

134-
```jsx
135-
<ReferenceFieldBase source="user_id" reference="users" offline="No network, could not fetch data" >
136-
...
137-
</ReferenceFieldBase>
138-
```
139-
140-
`<ReferenceFieldBase>` renders the `empty` element when:
141-
142-
- the referenced record is missing (no record in the `users` table with the right `user_id`), and
143-
- there is no network connectivity
144-
145-
You can pass either a React element or a string to the `offline` prop:
134+
You can customize this error message by passing a React element or a string to the `offline` prop:
146135

147136
```jsx
148-
<ReferenceFieldBase source="user_id" reference="users" empty={<span>No network, could not fetch data</span>} >
137+
<ReferenceFieldBase source="user_id" reference="users" offline={<span>No network, could not fetch data</span>} >
149138
...
150139
</ReferenceFieldBase>
151-
<ReferenceFieldBase source="user_id" reference="users" empty="No network, could not fetch data" >
140+
<ReferenceFieldBase source="user_id" reference="users" offline="No network, could not fetch data" >
152141
...
153142
</ReferenceFieldBase>
154143
```

docs/ReferenceOneField.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,24 @@ You can also set the `link` prop to a string, which will be used as the link typ
160160

161161
## `offline`
162162

163-
Use `offline` to customize the text displayed when the related record is empty because there is no network connectivity.
163+
When the user is offline, `<ReferenceOneField>` is smart enough to display the referenced record if it was previously fetched. However, if the referenced record has never been fetched before, `<ReferenceOneField>` displays an error message explaining that the app has lost network connectivity.
164164

165-
```jsx
166-
<ReferenceOneField label="Details" reference="book_details" target="book_id" offline="No network, could not fetch data">
167-
...
168-
</ReferenceOneField>
169-
```
170-
171-
`offline` also accepts a `ReactNode`.
165+
You can customize this error message by passing a React element or a string to the `offline` prop:
172166

173167
```jsx
174168
<ReferenceOneField
175-
label="Details"
176169
reference="book_details"
177170
target="book_id"
178171
offline={<p>No network, could not fetch data</p>}
179172
>
180173
...
181174
</ReferenceOneField>
175+
<ReferenceOneField
176+
reference="book_details"
177+
target="book_id"
178+
offline="No network, could not fetch data">
179+
...
180+
</ReferenceOneField>
182181
```
183182

184183
## `queryOptions`

docs/ReferenceOneFieldBase.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,25 +198,24 @@ You can also set the `link` prop to a string, which will be used as the link typ
198198

199199
## `offline`
200200

201-
Use `offline` to customize the text displayed when the related record is empty because there is no network connectivity.
201+
When the user is offline, `<ReferenceOneFieldBase>` is smart enough to display the referenced record if it was previously fetched. However, if the referenced record has never been fetched before, `<ReferenceOneFieldBase>` displays an error message explaining that the app has lost network connectivity.
202202

203-
```jsx
204-
<ReferenceOneFieldBase label="Details" reference="book_details" target="book_id" offline="No network, could not fetch data">
205-
...
206-
</ReferenceOneFieldBase>
207-
```
208-
209-
`offline` also accepts a `ReactNode`.
203+
You can customize this error message by passing a React element or a string to the `offline` prop:
210204

211205
```jsx
212206
<ReferenceOneFieldBase
213-
label="Details"
214207
reference="book_details"
215208
target="book_id"
216209
offline={<p>No network, could not fetch data</p>}
217210
>
218211
...
219212
</ReferenceOneFieldBase>
213+
<ReferenceOneFieldBase
214+
reference="book_details"
215+
target="book_id"
216+
offline="No network, could not fetch data">
217+
...
218+
</ReferenceOneFieldBase>
220219
```
221220

222221
## `queryOptions`

docs_headless/.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# build output
2+
dist/
3+
# generated types
4+
.astro/
5+
6+
# dependencies
7+
node_modules/
8+
9+
# logs
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
pnpm-debug.log*
14+
15+
16+
# environment variables
17+
.env
18+
.env.production
19+
20+
# macOS-specific files
21+
.DS_Store

docs_headless/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Starlight Starter Kit: Basics
2+
3+
[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)
4+
5+
```
6+
npm create astro@latest -- --template starlight
7+
```
8+
9+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
10+
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
11+
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/withastro/starlight&create_from_path=examples/basics)
12+
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)
13+
14+
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
15+
16+
## 🚀 Project Structure
17+
18+
Inside of your Astro + Starlight project, you'll see the following folders and files:
19+
20+
```
21+
.
22+
├── public/
23+
├── src/
24+
│ ├── assets/
25+
│ ├── content/
26+
│ │ └── docs/
27+
│ └── content.config.ts
28+
├── astro.config.mjs
29+
├── package.json
30+
└── tsconfig.json
31+
```
32+
33+
Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.
34+
35+
Images can be added to `src/assets/` and embedded in Markdown with a relative link.
36+
37+
Static assets, like favicons, can be placed in the `public/` directory.
38+
39+
## 🧞 Commands
40+
41+
All commands are run from the root of the project, from a terminal:
42+
43+
| Command | Action |
44+
| :------------------------ | :----------------------------------------------- |
45+
| `npm install` | Installs dependencies |
46+
| `npm run dev` | Starts local dev server at `localhost:4321` |
47+
| `npm run build` | Build your production site to `./dist/` |
48+
| `npm run preview` | Preview your build locally, before deploying |
49+
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
50+
| `npm run astro -- --help` | Get help using the Astro CLI |
51+
52+
## 👀 Want to learn more?
53+
54+
Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).

docs_headless/astro.config.mjs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// @ts-check
2+
import { defineConfig } from 'astro/config';
3+
import starlight from '@astrojs/starlight';
4+
import react from '@astrojs/react';
5+
import mdx from '@astrojs/mdx';
6+
import tailwindcss from '@tailwindcss/vite';
7+
import rehypeCodeGroup from 'rehype-code-group';
8+
import expressiveCode from 'astro-expressive-code';
9+
import { pluginFullscreen } from 'expressive-code-fullscreen';
10+
import { pluginCollapsibleSections } from '@expressive-code/plugin-collapsible-sections';
11+
import rehypeAstroRelativeMarkdownLinks from 'astro-rehype-relative-markdown-links';
12+
13+
// https://astro.build/config
14+
export default defineConfig({
15+
integrations: [
16+
starlight({
17+
title: 'React Admin Headless',
18+
customCss: ['./src/styles/global.css'],
19+
favicon: '/favicon.ico',
20+
social: [
21+
{
22+
icon: 'github',
23+
label: 'GitHub',
24+
href: 'https://github.com/marmelab/react-admin',
25+
},
26+
],
27+
sidebar: [
28+
{
29+
label: 'Guides & Concepts',
30+
items: [
31+
// Each item here is one entry in the navigation menu.
32+
{
33+
label: 'General Concepts',
34+
slug: 'guides/architecture',
35+
},
36+
{
37+
label: 'Data Fetching',
38+
slug: 'guides/datafetchingguide',
39+
},
40+
{
41+
label: 'CRUD pages',
42+
slug: 'guides/crud',
43+
attrs: {
44+
class: 'flex items-center',
45+
},
46+
badge: {
47+
text: '',
48+
variant: 'default',
49+
class: 'ee-badge',
50+
},
51+
},
52+
],
53+
},
54+
{
55+
label: 'Reference',
56+
autogenerate: {
57+
directory: 'reference',
58+
},
59+
},
60+
],
61+
components: {
62+
Sidebar: './src/components/CustomSidebar.astro',
63+
},
64+
}),
65+
expressiveCode({
66+
plugins: [pluginFullscreen(), pluginCollapsibleSections()],
67+
}),
68+
react(),
69+
mdx(),
70+
],
71+
markdown: {
72+
rehypePlugins: [
73+
rehypeCodeGroup,
74+
[
75+
rehypeAstroRelativeMarkdownLinks,
76+
{
77+
base: '/ra-core/',
78+
collectionBase: false,
79+
},
80+
],
81+
],
82+
},
83+
vite: {
84+
plugins: [tailwindcss()],
85+
},
86+
base: '/ra-core/',
87+
site: 'https://marmelab.com',
88+
build: {
89+
assets: 'assets',
90+
},
91+
});

0 commit comments

Comments
 (0)