-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5c527df
Showing
26 changed files
with
305 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Strapi plugin exchange | ||
|
||
A quick description of exchange. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* | ||
* Initializer | ||
* | ||
*/ | ||
|
||
import { useEffect, useRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import pluginId from '../../pluginId'; | ||
|
||
const Initializer = ({ setPlugin }) => { | ||
const ref = useRef(); | ||
ref.current = setPlugin; | ||
|
||
useEffect(() => { | ||
ref.current(pluginId); | ||
}, []); | ||
|
||
return null; | ||
}; | ||
|
||
Initializer.propTypes = { | ||
setPlugin: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default Initializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* | ||
* PluginIcon | ||
* | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Puzzle } from '@strapi/icons'; | ||
|
||
const PluginIcon = () => <Puzzle />; | ||
|
||
export default PluginIcon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { prefixPluginTranslations } from '@strapi/helper-plugin'; | ||
import pluginPkg from '../../package.json'; | ||
import pluginId from './pluginId'; | ||
import Initializer from './components/Initializer'; | ||
import PluginIcon from './components/PluginIcon'; | ||
|
||
const name = pluginPkg.strapi.name; | ||
|
||
export default { | ||
register(app) { | ||
app.addMenuLink({ | ||
to: `/plugins/${pluginId}`, | ||
icon: PluginIcon, | ||
intlLabel: { | ||
id: `${pluginId}.plugin.name`, | ||
defaultMessage: name, | ||
}, | ||
Component: async () => { | ||
const component = await import(/* webpackChunkName: "[request]" */ './pages/App'); | ||
|
||
return component; | ||
}, | ||
permissions: [ | ||
// Uncomment to set the permissions of the plugin here | ||
// { | ||
// action: '', // the action name should be plugin::plugin-name.actionType | ||
// subject: null, | ||
// }, | ||
], | ||
}); | ||
app.registerPlugin({ | ||
id: pluginId, | ||
initializer: Initializer, | ||
isReady: false, | ||
name, | ||
}); | ||
}, | ||
|
||
bootstrap(app) {}, | ||
async registerTrads({ locales }) { | ||
const importedTrads = await Promise.all( | ||
locales.map((locale) => { | ||
return import( | ||
/* webpackChunkName: "translation-[request]" */ `./translations/${locale}.json` | ||
) | ||
.then(({ default: data }) => { | ||
return { | ||
data: prefixPluginTranslations(data, pluginId), | ||
locale, | ||
}; | ||
}) | ||
.catch(() => { | ||
return { | ||
data: {}, | ||
locale, | ||
}; | ||
}); | ||
}) | ||
); | ||
|
||
return Promise.resolve(importedTrads); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* | ||
* This component is the skeleton around the actual pages, and should only | ||
* contain code that should be seen on all pages. (e.g. navigation bar) | ||
* | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Switch, Route } from 'react-router-dom'; | ||
import { AnErrorOccurred } from '@strapi/helper-plugin'; | ||
import pluginId from '../../pluginId'; | ||
import HomePage from '../HomePage'; | ||
|
||
const App = () => { | ||
return ( | ||
<div> | ||
<Switch> | ||
<Route path={`/plugins/${pluginId}`} component={HomePage} exact /> | ||
<Route component={AnErrorOccurred} /> | ||
</Switch> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* | ||
* HomePage | ||
* | ||
*/ | ||
|
||
import React from 'react'; | ||
// import PropTypes from 'prop-types'; | ||
import pluginId from '../../pluginId'; | ||
|
||
const HomePage = () => { | ||
return ( | ||
<div> | ||
<h1>{pluginId}'s HomePage</h1> | ||
<p>Happy coding</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default HomePage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pluginPkg from '../../package.json'; | ||
|
||
const pluginId = pluginPkg.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, ''); | ||
|
||
export default pluginId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pluginId from '../pluginId'; | ||
|
||
const getTrad = (id) => `${pluginId}.${id}`; | ||
|
||
export default getTrad; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "exchange", | ||
"version": "0.0.0", | ||
"description": "This is the description of the plugin.", | ||
"strapi": { | ||
"name": "exchange", | ||
"description": "Description of Exchange plugin", | ||
"kind": "plugin", | ||
"displayName": "Exchange" | ||
}, | ||
"dependencies": { | ||
"@strapi/design-system": "^1.6.3", | ||
"@strapi/helper-plugin": "^4.6.0", | ||
"@strapi/icons": "^1.6.3", | ||
"prop-types": "^15.7.2" | ||
}, | ||
"devDependencies": { | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router-dom": "^5.3.4", | ||
"styled-components": "^5.3.6" | ||
}, | ||
"peerDependencies": { | ||
"react": "^17.0.0 || ^18.0.0", | ||
"react-dom": "^17.0.0 || ^18.0.0", | ||
"react-router-dom": "^5.3.4", | ||
"styled-components": "^5.3.6" | ||
}, | ||
"author": { | ||
"name": "A Strapi developer" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "A Strapi developer" | ||
} | ||
], | ||
"engines": { | ||
"node": ">=16.0.0 <=20.x.x", | ||
"npm": ">=6.0.0" | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = ({ strapi }) => { | ||
// bootstrap phase | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
default: {}, | ||
validator() {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const myController = require('./my-controller'); | ||
|
||
module.exports = { | ||
myController, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports = ({ strapi }) => ({ | ||
index(ctx) { | ||
ctx.body = strapi | ||
.plugin('exchange') | ||
.service('myService') | ||
.getWelcomeMessage(); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = ({ strapi }) => { | ||
// destroy phase | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
const register = require('./register'); | ||
const bootstrap = require('./bootstrap'); | ||
const destroy = require('./destroy'); | ||
const config = require('./config'); | ||
const contentTypes = require('./content-types'); | ||
const controllers = require('./controllers'); | ||
const routes = require('./routes'); | ||
const middlewares = require('./middlewares'); | ||
const policies = require('./policies'); | ||
const services = require('./services'); | ||
|
||
module.exports = { | ||
register, | ||
bootstrap, | ||
destroy, | ||
config, | ||
controllers, | ||
routes, | ||
services, | ||
contentTypes, | ||
policies, | ||
middlewares, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = ({ strapi }) => { | ||
// registeration phase | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = [ | ||
{ | ||
method: 'GET', | ||
path: '/', | ||
handler: 'myController.index', | ||
config: { | ||
policies: [], | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
const myService = require('./my-service'); | ||
|
||
module.exports = { | ||
myService, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
module.exports = ({ strapi }) => ({ | ||
getWelcomeMessage() { | ||
return 'Welcome to Strapi 🚀'; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./admin/src').default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./server'); |