strapi-plugin-comments 3.0.7-beta.1 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,7 +41,7 @@ A plugin for [Strapi Headless CMS](https://github.com/strapi/strapi) that provid
41
41
  9. [⚗️ Custom fields](#-custom-fields)
42
42
  10. [🧩 Examples](#-examples)
43
43
  11. [💬 FAQ](#-faq)
44
- 12. [🤝 Contributing](#-contributing)
44
+ 12. [🤝 Contributing](#-contributing-to-the-plugin)
45
45
  13. [👨‍💻 Community support](#-community-support)
46
46
 
47
47
  ## 💎 Versions
@@ -104,7 +104,7 @@ In our minimum support we're following [official Node.js releases timelines](htt
104
104
 
105
105
  **Supported Strapi versions**:
106
106
 
107
- - Strapi v5.8.1 (recently tested)
107
+ - Strapi v5.10.3 (recently tested)
108
108
  - Strapi v5.x
109
109
 
110
110
  > This plugin is designed for **Strapi v5**. To get support for other Strapi versions, please follow the [versions](#-versions) section.
@@ -948,7 +948,25 @@ Example:
948
948
  });
949
949
  ```
950
950
 
951
- ## 🤝 Contributing
951
+ ## 💬 FAQ
952
+
953
+ ### GraphQL tricks
954
+
955
+ **Q:** I would like to use GraphQL schemas but I'm not getting any response, just 403 or 500 for every query or even proper types etc. What should I do?
956
+
957
+ **A:** There is a one trick you might try. Strapi by default is ordering plugins by the way which takes `strapi-plugin-graphql` to initialize earlier than other plugins so types might not be injected. If you don't have it yet, please create `config/plugins.{js|ts}` file and put there following lines (put `graphql` at the end):
958
+
959
+ ```ts
960
+ module.exports = {
961
+ 'comments': { enabled: true },
962
+ 'graphql': { enabled: true },
963
+ };
964
+ ```
965
+
966
+ If you already got it, make sure that `comments` plugin is inserted before `graphql`. That should do the job.
967
+
968
+
969
+ ## 🤝 Contributing to the plugin
952
970
 
953
971
  Feel free to fork and make a Pull Request to this plugin project. All the input is warmly welcome!
954
972
 
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-BGCzzYSK.js"),h=require("@strapi/strapi/admin"),c=require("@tanstack/react-query"),m=require("react"),D=require("styled-components"),s=require("./index-Chf4p7eV.js"),N=r=>r&&r.__esModule?r:{default:r},W=N(D),S=({children:r,condition:a})=>a?e.jsx(e.Fragment,{children:r}):null,_=(r={})=>{const a=s.useAPI(),x=c.useMutation({mutationFn:a.settings.update,onSuccess:r.updateSettingsMutationSuccess,onError:r.updateSettingsMutationError}),j=c.useMutation({mutationFn:a.settings.restore,onSuccess:r.restoreSettingsMutationSuccess,onError:r.restoreSettingsMutationError}),g=c.useMutation({mutationFn:a.settings.restart,onSuccess:r.restartStrapiMutationSuccess,onError:r.restartStrapiMutationError}),b=c.useQuery({queryKey:a.config.getKey(),queryFn:a.config.query}),u=c.useQuery({queryKey:a.contentTypeBuilder.all.getKey(),queryFn:a.contentTypeBuilder.all.query}),p=c.useQuery({queryKey:a.roles.getKey(),queryFn:a.roles.query});return m.useMemo(()=>({config:b,collectionTypes:u,roles:p,restoreSettingsMutation:j,updateSettingsMutation:x,restartStrapiMutation:g}),[b,p,u,j,x,g])},y={background:"neutral0",hasRadius:!0,shadow:"filterShadow",padding:6,width:"100%"},U=W.default(t.Alert)(()=>({"[role]":{flexDirection:"column"}})),z=()=>{const{trackUsage:r}=h.useTracking(),a=m.useRef(null),{toggleNotification:x}=h.useNotification(),[j,g]=m.useState(!1),{isLoadingForPermissions:b,canSettingsChange:u}=s.usePermissions(),p=c.useQueryClient(),w=s.useAPI(),{config:l,collectionTypes:R,roles:M,restoreSettingsMutation:T,updateSettingsMutation:I,restartStrapiMutation:A}=_({restoreSettingsMutationSuccess:()=>{p.invalidateQueries({queryKey:w.config.getKey(),exact:!1}),g(!0),x({message:s.getMessage("page.settings.actions.restore.success"),type:"success"})},restartStrapiMutationSuccess:()=>{g(!1)},updateSettingsMutationSuccess:()=>{p.invalidateQueries({queryKey:w.config.getKey(),exact:!1}),g(!0)}}),P=m.useCallback(()=>{a.current?.requestSubmit()},[]),G=m.useCallback(n=>{I.mutate({...n,blockedAuthorProps:n.blockedAuthorProps.split(",").map(o=>o.trim())})},[I]);if(l.status!=="success"||R.status!=="success"||M.status!=="success"||b)return s.getMessage("page.settings.loading");const F=R.data.filter(n=>n.uid.includes("api::")),v=l.data.enabledCollections.filter(n=>F.some(o=>o.uid===n)),k=t.lodashExports.isNil(l.data.badWords)?!0:l.data?.badWords,B=!!l.data.gql?.auth,E=l.data.moderatorRoles.filter(n=>M.data.filter(o=>o.code===n)),H=l.data.client?.url,K=l.data.client?.contactEmail,Q=l.data.blockedAuthorProps??[],O=()=>g(!1);return e.jsxs(e.Fragment,{children:[e.jsx(h.Page.Title,{children:"Comments - settings"}),e.jsxs(h.Page.Main,{children:[e.jsx(h.Layouts.Header,{title:s.getMessage("page.settings.header.title"),subtitle:s.getMessage("page.settings.header.description"),as:"h2",primaryAction:e.jsx(S,{condition:u,children:e.jsx(t.Button,{type:"submit",startIcon:e.jsx(t.ForwardRef$4z,{}),onClick:P,children:s.getMessage("page.settings.actions.submit")})})}),e.jsxs(h.Layouts.Content,{children:[j&&e.jsx(t.Box,{marginBottom:4,children:e.jsx(U,{closeLabel:s.getMessage("page.settings.actions.restart.alert.cancel"),title:s.getMessage("page.settings.actions.restart.alert.title"),onClose:O,action:e.jsx(t.Box,{children:e.jsx(t.Button,{onClick:A.mutate,startIcon:e.jsx(t.ForwardRef$1f,{}),children:s.getMessage("page.settings.actions.restart")})}),children:e.jsx(t.Box,{marginTop:4,children:s.getMessage("page.settings.actions.restart.alert.description")})})}),e.jsx(h.Form,{method:"POST",width:"auto",height:"auto",ref:a,onSubmit:G,initialValues:{enabledCollections:v,moderatorRoles:E,badWords:k,clientEmail:K,clientUrl:H,gqlAuthEnabled:B,approvalFlow:l.data.approvalFlow,entryLabel:l.data.entryLabel,blockedAuthorProps:Q.join(", ")},children:({values:n,onChange:o})=>e.jsxs(t.Flex,{gap:4,direction:"column",children:[e.jsxs(t.Box,{...y,children:[e.jsx(t.Typography,{variant:"delta",as:"h2",children:s.getMessage("page.settings.section.general")}),e.jsxs(t.Grid.Root,{gap:4,marginTop:4,width:"100%",children:[e.jsx(t.Grid.Item,{xs:12,children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage("page.settings.form.enabledCollections.hint"),children:[e.jsx(t.Field.Label,{htmlFor:"enabledCollections",children:s.getMessage("page.settings.form.enabledCollections.label")}),e.jsx(t.MultiSelect,{withTags:!0,name:"enabledCollections",value:n.enabledCollections,onChange:i=>{o("enabledCollections",i)},children:F.map(i=>e.jsx(t.MultiSelectOption,{value:i.uid,children:i.schema.displayName},i.uid))}),e.jsx(t.Field.Hint,{})]})}),n.enabledCollections.length>0&&e.jsx(t.Grid.Item,{children:e.jsxs(t.Grid.Root,{gap:4,width:"100%",children:[e.jsx(t.Grid.Item,{children:e.jsx(t.Typography,{children:s.getMessage("page.settings.form.contentTypesSettings.label")})}),e.jsx(t.Grid.Item,{children:e.jsx(t.Accordion.Root,{style:{width:"100%"},children:t.lodashExports.orderBy(n.enabledCollections).map(i=>{const C=F.find(f=>f.uid===i);if(C){const{schema:{displayName:f,attributes:q}}=C,L=Object.keys(q).filter(d=>q[d].type==="string");return e.jsxs(t.Accordion.Item,{value:i,children:[e.jsx(t.Accordion.Header,{children:e.jsx(t.Accordion.Trigger,{children:e.jsx(t.Typography,{variant:"epsilon",as:"h3",children:f})})}),e.jsx(t.Accordion.Content,{children:e.jsxs(t.Grid.Root,{padding:6,gap:4,children:[e.jsx(t.Grid.Item,{children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage({id:"page.settings.form.approvalFlow.hint",props:{name:f}}),children:[e.jsx(t.Field.Label,{children:s.getMessage("page.settings.form.approvalFlow.label")}),e.jsx(t.SwitchImpl,{visibleLabels:!0,onLabel:s.getMessage("components.toogle.enabled"),offLabel:s.getMessage("components.toogle.disabled"),checked:n.approvalFlow.includes(i),onCheckedChange:d=>{o("approvalFlow",d?[...n.approvalFlow,i]:n.approvalFlow.filter($=>$!==i))}}),e.jsx(t.Field.Hint,{})]})}),e.jsx(S,{condition:L.length>0,children:e.jsx(t.Grid.Item,{children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage("page.settings.form.entryLabel.hint"),children:[e.jsx(t.Field.Label,{children:s.getMessage("page.settings.form.entryLabel.label")}),e.jsx(t.MultiSelect,{withTags:!0,placeholder:s.getMessage("page.settings.form.entryLabel.placeholder"),name:"enabledCollections",value:n.entryLabel[i]??[],onChange:d=>{o("entryLabel",{...n.entryLabel,[i]:d})},children:L.map(d=>e.jsx(t.MultiSelectOption,{value:d,children:d},d))}),e.jsx(t.Field.Hint,{})]})})})]})})]},i)}return null})})})]})})]})]}),e.jsxs(t.Box,{...y,children:[e.jsx(t.Typography,{variant:"delta",as:"h2",children:s.getMessage("page.settings.section.additional")}),e.jsxs(t.Grid.Root,{gap:4,marginTop:4,width:"100%",children:[e.jsx(t.Grid.Item,{xs:4,alignItems:"start",children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage("page.settings.form.enabledCollections.hint"),children:[e.jsx(t.Field.Label,{htmlFor:"enabledCollections",children:s.getMessage("page.settings.form.enabledCollections.label")}),e.jsx(t.Toggle,{name:"badWords",checked:n.badWords,onChange:o,onLabel:s.getMessage("components.toogle.enabled"),offLabel:s.getMessage("components.toogle.disabled"),width:"100%"}),e.jsx(t.Field.Hint,{})]})}),e.jsx(t.Grid.Item,{xs:4,alignItems:"start",children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage("page.settings.form.author.blockedProps.hint"),children:[e.jsx(t.Field.Label,{htmlFor:"enabledCollections",children:s.getMessage("page.settings.form.author.blockedProps.label")}),e.jsx(t.Field.Input,{name:"blockedProps",onChange:o}),e.jsx(t.Field.Hint,{})]})}),e.jsx(t.Grid.Item,{xs:4,alignItems:"start",children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage("page.settings.form.gqlAuth.hint"),children:[e.jsx(t.Field.Label,{children:s.getMessage("page.settings.form.gqlAuth.label")}),e.jsx(t.Toggle,{name:"gqlAuthEnabled",checked:n.gqlAuthEnabled,onChange:o,onLabel:s.getMessage("components.toogle.enabled"),offLabel:s.getMessage("components.toogle.disabled"),width:"100%"}),e.jsx(t.Field.Hint,{})]})})]})]}),e.jsxs(t.Box,{...y,children:[e.jsx(t.Typography,{variant:"delta",as:"h2",children:s.getMessage("page.settings.section.client")}),e.jsxs(t.Grid.Root,{gap:4,marginTop:4,width:"100%",children:[e.jsx(t.Grid.Item,{xs:4,alignItems:"start",children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage("page.settings.form.client.url.hint"),children:[e.jsx(t.Field.Label,{children:s.getMessage("page.settings.form.client.url.label")}),e.jsx(t.Field.Input,{name:"clientUrl",onChange:o}),e.jsx(t.Field.Hint,{})]})}),e.jsx(t.Grid.Item,{xs:4,alignItems:"start",children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage("page.settings.form.client.email.hint"),children:[e.jsx(t.Field.Label,{children:s.getMessage("page.settings.form.client.email.label")}),e.jsx(t.Field.Input,{name:"clientEmail",onChange:o}),e.jsx(t.Field.Hint,{})]})}),e.jsx(t.Grid.Item,{xs:4,alignItems:"start",children:e.jsxs(t.Field.Root,{width:"100%",hint:s.getMessage("page.settings.form.moderatorRoles.hint"),children:[e.jsx(t.Field.Label,{children:s.getMessage("page.settings.form.moderatorRoles.label")}),e.jsx(t.MultiSelect,{withTags:!0,placeholder:s.getMessage("page.settings.form.moderatorRoles.placeholder"),name:"enabledCollections",value:n.moderatorRoles,onChange:i=>{o("moderatorRoles",i)},children:M.data.map(i=>e.jsx(t.MultiSelectOption,{value:i.code,children:i.name},i.code))}),e.jsx(t.Field.Hint,{})]})})]})]}),e.jsx(S,{condition:u,children:e.jsx(t.Box,{...y,children:e.jsxs(t.Flex,{gap:4,direction:"column",alignItems:"flex-start",children:[e.jsxs(t.Flex,{gap:2,direction:"column",alignItems:"flex-start",children:[e.jsx(t.Typography,{variant:"delta",as:"h2",children:s.getMessage("page.settings.section.restore")}),e.jsx(t.Typography,{variant:"pi",as:"h4",children:s.getMessage("page.settings.section.restore.subtitle")})]}),e.jsx(s.ConfirmationDialog,{Trigger:({onClick:i})=>e.jsx(t.Button,{variant:"danger-light",startIcon:e.jsx(t.ForwardRef$5b,{}),onClick:i,children:s.getMessage("page.settings.actions.restore")}),onConfirm:T.mutate,title:s.getMessage("page.settings.actions.restore.confirmation.header"),labelConfirm:s.getMessage("page.settings.actions.restore.confirmation.button.confirm"),iconConfirm:e.jsx(t.ForwardRef$5b,{}),children:s.getMessage("page.settings.actions.restore.confirmation.description")})]})})})]})})]})]})]})};new c.QueryClient;const V=()=>e.jsx(s.CommonProviders,{children:e.jsx(z,{})});exports.default=V;