diff --git a/package-lock.json b/package-lock.json index a739453..64375c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "react": "^18.0.0", "react-dom": "^18.0.0", "react-router-dom": "^6.0.0", + "strapi-v5-plugin-populate-deep": "^4.0.5", "styled-components": "^6.0.0" }, "devDependencies": { @@ -20598,6 +20599,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/strapi-v5-plugin-populate-deep": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/strapi-v5-plugin-populate-deep/-/strapi-v5-plugin-populate-deep-4.0.5.tgz", + "integrity": "sha512-se5WE8rWxVx+BX904tESoZsRJYJg7VtGWZNeNGhirJGhuUJV5UgAP38Jiq5kPdyT3rASiwfCJxvXgMAfTh3Y5A==", + "license": "MIT", + "engines": { + "node": ">=18.0.0 <=22.x.x", + "npm": ">=6.0.0" + } + }, "node_modules/stream-browserify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", diff --git a/package.json b/package.json index 6c7aefd..69a9ca7 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "react": "^18.0.0", "react-dom": "^18.0.0", "react-router-dom": "^6.0.0", + "strapi-v5-plugin-populate-deep": "^4.0.5", "styled-components": "^6.0.0" }, "devDependencies": { diff --git a/src/api/choral/content-types/choral/schema.json b/src/api/choral/content-types/choral/schema.json index a93166a..0418876 100644 --- a/src/api/choral/content-types/choral/schema.json +++ b/src/api/choral/content-types/choral/schema.json @@ -67,6 +67,11 @@ "relation": "oneToMany", "target": "api::event.event", "mappedBy": "choral" + }, + "permissions_templates": { + "type": "relation", + "relation": "oneToMany", + "target": "api::permissions-template.permissions-template" } } } diff --git a/src/api/permissions-template/content-types/permissions-template/schema.json b/src/api/permissions-template/content-types/permissions-template/schema.json new file mode 100644 index 0000000..4587928 --- /dev/null +++ b/src/api/permissions-template/content-types/permissions-template/schema.json @@ -0,0 +1,29 @@ +{ + "kind": "collectionType", + "collectionName": "permissions_templates", + "info": { + "singularName": "permissions-template", + "pluralName": "permissions-templates", + "displayName": "PermissionsTemplate" + }, + "options": { + "draftAndPublish": false + }, + "pluginOptions": {}, + "attributes": { + "key": { + "type": "uid" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "permissions": { + "type": "component", + "repeatable": true, + "component": "user.permissions" + } + } +} diff --git a/src/api/permissions-template/controllers/permissions-template.ts b/src/api/permissions-template/controllers/permissions-template.ts new file mode 100644 index 0000000..8ada77c --- /dev/null +++ b/src/api/permissions-template/controllers/permissions-template.ts @@ -0,0 +1,7 @@ +/** + * permissions-template controller + */ + +import { factories } from '@strapi/strapi' + +export default factories.createCoreController('api::permissions-template.permissions-template'); diff --git a/src/api/permissions-template/routes/permissions-template.ts b/src/api/permissions-template/routes/permissions-template.ts new file mode 100644 index 0000000..dacecd0 --- /dev/null +++ b/src/api/permissions-template/routes/permissions-template.ts @@ -0,0 +1,7 @@ +/** + * permissions-template router + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreRouter('api::permissions-template.permissions-template'); diff --git a/src/api/permissions-template/services/permissions-template.ts b/src/api/permissions-template/services/permissions-template.ts new file mode 100644 index 0000000..12861b6 --- /dev/null +++ b/src/api/permissions-template/services/permissions-template.ts @@ -0,0 +1,7 @@ +/** + * permissions-template service + */ + +import { factories } from '@strapi/strapi'; + +export default factories.createCoreService('api::permissions-template.permissions-template'); diff --git a/src/components/user/permissions.json b/src/components/user/permissions.json new file mode 100644 index 0000000..7a95887 --- /dev/null +++ b/src/components/user/permissions.json @@ -0,0 +1,29 @@ +{ + "collectionName": "components_user_permissions", + "info": { + "displayName": "permissions", + "icon": "key" + }, + "options": {}, + "attributes": { + "module": { + "type": "enumeration", + "enum": [ + "information", + "chat", + "board", + "calendar", + "users" + ] + }, + "active": { + "type": "boolean" + }, + "read": { + "type": "boolean" + }, + "write": { + "type": "boolean" + } + } +} diff --git a/types/generated/components.d.ts b/types/generated/components.d.ts index 41aa563..3f64f86 100644 --- a/types/generated/components.d.ts +++ b/types/generated/components.d.ts @@ -1,3 +1,25 @@ -/* - * The app doesn't have any components yet. - */ +import type { Schema, Struct } from '@strapi/strapi'; + +export interface UserPermissions extends Struct.ComponentSchema { + collectionName: 'components_user_permissions'; + info: { + displayName: 'permissions'; + icon: 'key'; + }; + attributes: { + active: Schema.Attribute.Boolean; + module: Schema.Attribute.Enumeration< + ['information', 'chat', 'board', 'calendar', 'users'] + >; + read: Schema.Attribute.Boolean; + write: Schema.Attribute.Boolean; + }; +} + +declare module '@strapi/strapi' { + export module Public { + export interface ComponentSchemas { + 'user.permissions': UserPermissions; + } + } +} diff --git a/types/generated/contentTypes.d.ts b/types/generated/contentTypes.d.ts index 4768a95..35c6d6f 100644 --- a/types/generated/contentTypes.d.ts +++ b/types/generated/contentTypes.d.ts @@ -511,6 +511,10 @@ export interface ApiChoralChoral extends Struct.CollectionTypeSchema { 'oneToOne', 'plugin::users-permissions.user' >; + permissions_templates: Schema.Attribute.Relation< + 'oneToMany', + 'api::permissions-template.permissions-template' + >; postal: Schema.Attribute.Integer; publishedAt: Schema.Attribute.DateTime; updatedAt: Schema.Attribute.DateTime; @@ -553,6 +557,38 @@ export interface ApiEventEvent extends Struct.CollectionTypeSchema { }; } +export interface ApiPermissionsTemplatePermissionsTemplate + extends Struct.CollectionTypeSchema { + collectionName: 'permissions_templates'; + info: { + displayName: 'PermissionsTemplate'; + pluralName: 'permissions-templates'; + singularName: 'permissions-template'; + }; + options: { + draftAndPublish: false; + }; + attributes: { + createdAt: Schema.Attribute.DateTime; + createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + description: Schema.Attribute.String; + key: Schema.Attribute.UID; + locale: Schema.Attribute.String & Schema.Attribute.Private; + localizations: Schema.Attribute.Relation< + 'oneToMany', + 'api::permissions-template.permissions-template' + > & + Schema.Attribute.Private; + permissions: Schema.Attribute.Component<'user.permissions', true>; + publishedAt: Schema.Attribute.DateTime; + title: Schema.Attribute.String; + updatedAt: Schema.Attribute.DateTime; + updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & + Schema.Attribute.Private; + }; +} + export interface PluginContentReleasesRelease extends Struct.CollectionTypeSchema { collectionName: 'strapi_releases'; @@ -1089,6 +1125,7 @@ declare module '@strapi/strapi' { 'api::board.board': ApiBoardBoard; 'api::choral.choral': ApiChoralChoral; 'api::event.event': ApiEventEvent; + 'api::permissions-template.permissions-template': ApiPermissionsTemplatePermissionsTemplate; 'plugin::content-releases.release': PluginContentReleasesRelease; 'plugin::content-releases.release-action': PluginContentReleasesReleaseAction; 'plugin::i18n.locale': PluginI18NLocale;