Add plugin for testing custom fields

This commit is contained in:
Mark Kaylor 2022-07-05 17:40:40 +02:00
parent 5aad18547b
commit 1c556a0845
14 changed files with 130 additions and 0 deletions

View File

@ -28,4 +28,8 @@ module.exports = () => ({
testConf: 3,
},
},
mycustomfields: {
enabled: true,
resolve: `./src/plugins/mycustomfields`,
},
});

View File

@ -0,0 +1,3 @@
# Strapi plugin mycustomfield
A quick description of mycustomfield.

View File

@ -0,0 +1,6 @@
import React from 'react';
import Puzzle from '@strapi/icons/Puzzle';
const ColorPickerIcon = () => <Puzzle />;
export default ColorPickerIcon;

View File

@ -0,0 +1,7 @@
import React from 'react';
const ColorPickerInput = () => {
return <div>TODO: Color Picker Input Component</div>;
};
export default ColorPickerInput;

View File

@ -0,0 +1,49 @@
import { prefixPluginTranslations } from '@strapi/helper-plugin';
import pluginId from './pluginId';
// TODO: Uncomment for EXPANSION-235
//import ColorPickerIcon from './components/ColorPicker/ColorPickerIcon';
export default {
register(app) {
// TODO: Uncomment for EXPANSION-235
// app.customFields.register({
// name: 'color',
// pluginId: 'color-picker',
// type: 'text',
// icon: ColorPickerIcon,
// intlLabel: {
// id: 'color-picker.color.label',
// defaultMessage: 'Color',
// },
// intlDescription: {
// id: 'color-picker.color.description',
// defaultMessage: 'Select any color',
// },
// components: {
// Input: async () => import(/* webpackChunkName: "input-component" */ './components/ColorPicker/ColorPickerInput'),
// },
// });
},
bootstrap(app) {},
async registerTrads({ locales }) {
const importedTrads = await Promise.all(
locales.map(locale => {
return import(`./translations/${locale}.json`)
.then(({ default: data }) => {
return {
data: prefixPluginTranslations(data, pluginId),
locale,
};
})
.catch(() => {
return {
data: {},
locale,
};
});
})
);
return Promise.resolve(importedTrads);
},
};

View File

@ -0,0 +1,5 @@
const pluginPkg = require('../../package.json');
const pluginId = pluginPkg.name.replace(/^(@[^-,.][\w,-]+\/|strapi-)plugin-/i, '');
module.exports = pluginId;

View File

@ -0,0 +1,5 @@
import pluginId from '../pluginId';
const getTrad = id => `${pluginId}.${id}`;
export default getTrad;

View File

@ -0,0 +1,25 @@
{
"name": "mycustomfield",
"version": "0.0.0",
"description": "This is the description of the plugin.",
"strapi": {
"name": "mycustomfield",
"description": "Description of Mycustomfield plugin",
"kind": "plugin",
"displayName": "Mycustomfield"
},
"dependencies": {},
"author": {
"name": "A Strapi developer"
},
"maintainers": [
{
"name": "A Strapi developer"
}
],
"engines": {
"node": ">=14.19.1 <=16.x.x",
"npm": ">=6.0.0"
},
"license": "MIT"
}

View File

@ -0,0 +1,7 @@
'use strict';
const register = require('./register');
module.exports = {
register,
};

View File

@ -0,0 +1,11 @@
'use strict';
module.exports = ({ strapi }) => {
console.log('Running register in customfields plugin');
// TODO: Uncomment for EXPANSION-234
// strapi.customFields.register({
// name: 'color',
// plugin: 'color-picker',
// type: 'text',
// });
};

View File

@ -0,0 +1,3 @@
'use strict';
module.exports = require('./admin/src').default;

View File

@ -0,0 +1,3 @@
'use strict';
module.exports = require('./server');