{"id":13725306,"url":"https://github.com/surgeharb/strapi-plugins","last_synced_at":"2025-05-07T20:32:00.137Z","repository":{"id":39064250,"uuid":"278286134","full_name":"surgeharb/strapi-plugins","owner":"surgeharb","description":"🚀  Open source plugins for Strapi - Node.js Headless CMS","archived":false,"fork":false,"pushed_at":"2023-01-26T21:53:10.000Z","size":2079,"stargazers_count":26,"open_issues_count":29,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T01:27:30.908Z","etag":null,"topics":["admin-panel","cms","cms-plugin","customization","dashboard","headless-cms","nodejs","plugins","strapi"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/surgeharb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-09T06:49:56.000Z","updated_at":"2022-12-25T13:15:09.000Z","dependencies_parsed_at":"2023-02-15T01:17:16.480Z","dependency_job_id":null,"html_url":"https://github.com/surgeharb/strapi-plugins","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surgeharb%2Fstrapi-plugins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surgeharb%2Fstrapi-plugins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surgeharb%2Fstrapi-plugins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/surgeharb%2Fstrapi-plugins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/surgeharb","download_url":"https://codeload.github.com/surgeharb/strapi-plugins/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224645326,"owners_count":17346124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admin-panel","cms","cms-plugin","customization","dashboard","headless-cms","nodejs","plugins","strapi"],"created_at":"2024-08-03T01:02:18.866Z","updated_at":"2024-11-14T15:31:10.992Z","avatar_url":"https://github.com/surgeharb.png","language":"JavaScript","readme":"# 🚀 Cool Strapi Plugins\n\nAmazing Plugin [strapi-plugin-graphs-builder](https://github.com/surgeharb/strapi-plugin-graphs-builder) for Strapi v4, check it out now!\n\n## Getting Started\n\nFirst clone the project by running:\n\n```bash\ngit clone https://github.com/surgeharb/strapi-plugins.git\n```\n\n## Installation\n\nOnce the project is cloned locally, navigate to the main directory:\n\n```bash\ncd strapi-plugins\n```\n\nMake sure that yarn is installed on your machine and run:\n\n```bash\nyarn install\n```\n\nTo start the project in development mode:\n\n```bash\nyarn develop\n```\n\nIf you want to tinker with plugins and watch changes without rebuilding the project multiple times:\n\n```bash\nyarn develop --watch-admin\n```\n\nFinally, for production make sure to:\n\n```bash\n# build the project -- production\nNODE_ENV=production yarn build\n\n# start Strapi -- production\nNODE_ENV=production yarn start\n```\n\n## Plugin: Admin Access Rights\n*Keep in mind that this is a temporary solution as the core team of Strapi is in the latest stages of achieving this the good way in the system. \u003cbr\u003e\nI made use of the built in Strapi \"admin customization\" feature.*\n\nThis feature is available directly when you login as an admin user \u003e **Access Rights** under **Plugins** in the **Left Panel**.\n\n### Make it possible in your own Strapi Project!\n\nFirst, you will have 3 default roles **admin**, **author**, **editor** as a start.\n\n#### Step 1 - Modify admin database model\nAdd these roles to the `Administrator` database model.\n\nFrom this repo, copy the admin extension into your project's extensions:\n```bash\ncp -R ./extensions/admin ~/your-project/extensions\n```\n\nYou can notice a script to override `Administrator` model.\nTo apply it on every run, edit your package.json scripts as follow:\n\n```json\n{\n  \"scripts\": {\n    \"admin-override\": \"node ./extensions/admin/override-script.js\",\n    \"develop\": \"npm run admin-override \u0026\u0026 strapi develop\",\n    \"start\": \"npm run admin-override \u0026\u0026 strapi start\",\n    \"build\": \"npm run admin-override \u0026\u0026 strapi build\",\n    \"strapi\": \"strapi\"\n  },\n}\n```\n\nMake sure the default admin url is not `/admin` as it `admin` prefix causes issues in this modification. [Issue #1](https://github.com/surgeharb/strapi-plugins/issues/1).\nFor this project I changed the url to `/dashboard` as follows:\n\n```js\n// ./config/server.js\nmodule.exports = ({ env }) =\u003e ({\n  host: env('HOST', '0.0.0.0'),\n  port: env.int('PORT', 1337),\n  admin: {\n    url: '/dashboard'\n  }\n});\n```\n\n#### Step 2 - Override admin CRUD controllers\n\nStrapi administrator controllers restrict us from adding a new field while creating/updating admins.\n\nFor this I wrote a hook that overrides the controller behavior into letting us add new role on create/update admin.\n\n```bash\n# if you don't have hooks folder\nmkdir ~/your-project/hooks\n\n# copy admin-roles custom hook\ncp -R ./hooks/admin-roles ~/your-project/hooks\n\n# enable the hook on Strapi startup\ncp ./config/hook.js ~/your-project/config\n```\n\nKill the process, and restart Strapi instance, then navigate to `Manage administrators` in the top right menu, and create a new administrator.\n\nNow give new admin a role from the new dropdown that we injected in the model.\n\n***P.S. Make sure to keep at least 1 admin role on an administrator!!!***\n\n#### Step 3 - Create admin-access model and components\n\nTo manage roles access, create a database model linking **plugin uid** with the administrator role.\n\n```bash\n# copy new API models and controllers\ncp -R ./api/admin-access ~/your-project/api\n\n# prepare components general folder\nmkdir -p ~/your-project/components/general\n\n# copy custom plugin components used by the API\ncp ./components/general/plugin-access.json ~/your-project/components/general\n```\n\n#### Step 4 - Restrict access for roles\n\nRestrict plugin API fetching backend-side\n```bash\n# copy modified content-manager plugin controller\ncp -R ./extensions/content-manager ~/your-project/extensions\n```\n\nRemove frontend elements according to provided Roles `Manage administrators button` and `Left Panel Plugins`\n\n```bash\n# copy admin frontend modification in the root of your project\ncp -R ./admin ~/your-project\n```\n\n#### Step 5 - Add \"access rights\" plugin\n```bash\n# create plugins folder if not exists\nmkdir ~/your-project/plugins\n\n# add the newly crafter plugin for access rights\ncp -R ./plugins/access-rights ~/your-project/plugins\n```\n\n#### Optional Step - Add more roles\nAdd roles in enum array inside `extensions/admin/models/Administrator.settings.json` \u003cbr\u003e Don't remove first role - admin, it is necessary for the plugin to work properly!\n\nApply same additions also inside `plugins/access-rights/admin/src/containers/HomePage/index.js`\n```js\n// modify this array - do not include first role 'admin'\nconst [roles, setRoles] = useState(['author', 'editor']);\n```\n\nVoilà! Now kill the process, `yarn build` and restart Strapi.\nLogin using your main admin user and manage other administrators access.\n\n\u003cbr\u003e\n\n---\n\nDo not hesitate to open issues if you encounter any, submit a pull request to improve any bit of the code, or contact me [me@sergeharb.com](mailto:me@sergeharb.com)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurgeharb%2Fstrapi-plugins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsurgeharb%2Fstrapi-plugins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsurgeharb%2Fstrapi-plugins/lists"}