Skip to content

Commit b9198cb

Browse files
authored
Merge pull request #39 from johnmgrant/dev/strapi-v5-migration
chore(strapi): upgraded strapi support for v5
2 parents 9206a8b + 771b760 commit b9198cb

37 files changed

+4869
-6386
lines changed

.gitignore

Lines changed: 135 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,138 @@
1-
# Don't check auto-generated stuff into git
2-
coverage
3-
node_modules
4-
stats.json
5-
package-lock.json
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
############################
4+
# OS X
5+
############################
66

7-
# Cruft
87
.DS_Store
9-
npm-debug.log
8+
.AppleDouble
9+
.LSOverride
10+
Icon
11+
.Spotlight-V100
12+
.Trashes
13+
._*
14+
15+
16+
############################
17+
# Linux
18+
############################
19+
20+
*~
21+
22+
23+
############################
24+
# Windows
25+
############################
26+
27+
Thumbs.db
28+
ehthumbs.db
29+
Desktop.ini
30+
$RECYCLE.BIN/
31+
*.cab
32+
*.msi
33+
*.msm
34+
*.msp
35+
36+
37+
############################
38+
# Packages
39+
############################
40+
41+
*.7z
42+
*.csv
43+
*.dat
44+
*.dmg
45+
*.gz
46+
*.iso
47+
*.jar
48+
*.rar
49+
*.tar
50+
*.zip
51+
*.com
52+
*.class
53+
*.dll
54+
*.exe
55+
*.o
56+
*.seed
57+
*.so
58+
*.swo
59+
*.swp
60+
*.swn
61+
*.swm
62+
*.out
63+
*.pid
64+
65+
66+
############################
67+
# Logs and databases
68+
############################
69+
70+
.tmp
71+
*.log
72+
*.sql
73+
*.sqlite
74+
*.sqlite3
75+
76+
77+
############################
78+
# Misc.
79+
############################
80+
81+
*#
82+
ssl
1083
.idea
11-
dist/
84+
nbproject
85+
.tsbuildinfo
86+
.eslintcache
87+
.env
88+
89+
90+
############################
91+
# Strapi
92+
############################
93+
94+
public/uploads/*
95+
!public/uploads/.gitkeep
96+
97+
98+
############################
99+
# Build
100+
############################
101+
102+
dist
103+
build
104+
105+
106+
############################
107+
# Node.js
108+
############################
109+
110+
lib-cov
111+
lcov.info
112+
pids
113+
logs
114+
results
115+
node_modules
116+
.node_history
117+
118+
119+
############################
120+
# Package managers
121+
############################
122+
123+
.yarn/*
124+
!.yarn/cache
125+
!.yarn/unplugged
126+
!.yarn/patches
127+
!.yarn/releases
128+
!.yarn/sdks
129+
!.yarn/versions
130+
.pnp.*
131+
yarn-error.log
132+
133+
134+
############################
135+
# Tests
136+
############################
137+
138+
coverage

admin/custom.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module '@strapi/design-system/*';
2+
declare module '@strapi/design-system';

admin/src/components/Initializer/index.tsx renamed to admin/src/components/Initializer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { useEffect, useRef } from 'react';
8-
import pluginId from '../../pluginId';
8+
import pluginId from '../pluginId';
99

1010
type InitializerProps = {
1111
setPlugin: (id: string) => void;
@@ -21,4 +21,4 @@ const Initializer = ({ setPlugin }: InitializerProps) => {
2121
return null;
2222
};
2323

24-
export default Initializer;
24+
export {Initializer};

admin/src/components/MediaLib.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import {FC as FunctionComponent} from 'react';
2+
3+
import {useStrapiApp} from '@strapi/admin/strapi-admin';
4+
import type {Schema} from '@strapi/types';
5+
6+
7+
const prefixFileUrlWithBackendUrl = (fileURL: string) => {
8+
return !!fileURL &&
9+
fileURL.startsWith('/') &&
10+
'strapi' in window &&
11+
window.strapi instanceof Object &&
12+
'backendURL' in window.strapi &&
13+
window.strapi.backendURL ?
14+
`${window.strapi.backendURL}${fileURL}` :
15+
fileURL;
16+
};
17+
18+
interface MediaLibComponentProps {
19+
isOpen: boolean,
20+
onChange: (files: Schema.Attribute.MediaValue<true>) => void,
21+
onToggle: () => void,
22+
}
23+
24+
const MediaLib: FunctionComponent<MediaLibComponentProps> = ({
25+
isOpen,
26+
onChange,
27+
onToggle,
28+
}) => {
29+
const components = useStrapiApp('ImageDialog', (state) => state.components);
30+
if (!components || !isOpen) return null;
31+
32+
const MediaLibraryDialog = components['media-library'] as FunctionComponent<{
33+
onClose: () => void,
34+
onSelectAssets: (_images: Schema.Attribute.MediaValue<true>) => void,
35+
}>;
36+
37+
const handleSelectAssets = (files: Schema.Attribute.MediaValue<true>) => {
38+
const formattedFiles = files.map((f) => ({
39+
alt: f.alternativeText || f.name,
40+
url: prefixFileUrlWithBackendUrl(f.url),
41+
mime: f.mime,
42+
}));
43+
44+
onChange(formattedFiles);
45+
};
46+
47+
return (
48+
<MediaLibraryDialog
49+
onClose={onToggle}
50+
onSelectAssets={handleSelectAssets}
51+
/>
52+
);
53+
};
54+
55+
MediaLib.defaultProps = {
56+
isOpen: false,
57+
onChange: (_files: Schema.Attribute.MediaValue<true>) => {},
58+
onToggle: () => {},
59+
};
60+
61+
export {MediaLib};

admin/src/components/MediaLib/index.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)