From 03d504aa86ad7611bd6c1b25845b8c410c712e9a Mon Sep 17 00:00:00 2001 From: Mateusz Ziarko Date: Tue, 25 Jul 2023 13:49:55 +0200 Subject: [PATCH] fix: issue #220, issue #221 (#222) --- .../components/input/__tests__/utils.test.ts | 12 -- .../comments/components/input/input.tsx | 12 +- .../comments/components/input/utils.ts | 28 ++-- package.json | 6 +- server/services/admin.ts | 2 +- yarn.lock | 121 +++++++++--------- 6 files changed, 77 insertions(+), 104 deletions(-) diff --git a/admin/src/custom-fields/comments/components/input/__tests__/utils.test.ts b/admin/src/custom-fields/comments/components/input/__tests__/utils.test.ts index b4878a37..9e5623d8 100644 --- a/admin/src/custom-fields/comments/components/input/__tests__/utils.test.ts +++ b/admin/src/custom-fields/comments/components/input/__tests__/utils.test.ts @@ -369,10 +369,6 @@ describe("Custom fields", () => { expect(getSortByDateOptions(({ id }) => `translated.${id}`)) .toMatchInlineSnapshot(` [ - { - "label": "", - "value": undefined, - }, { "label": "translated.customField.comments.input.sortByDate.option.asc.label", "value": "ASC", @@ -390,10 +386,6 @@ describe("Custom fields", () => { expect(getFilterByOptions(({ id }) => `translated.${id}`)) .toMatchInlineSnapshot(` [ - { - "label": "", - "value": undefined, - }, { "label": "translated.customField.comments.input.filterBy.option.dateCreated.label", "value": "DATE_CREATED", @@ -411,10 +403,6 @@ describe("Custom fields", () => { expect(getApprovalStatusOptions(({ id }) => `translated.${id}`)) .toMatchInlineSnapshot(` [ - { - "label": "", - "value": undefined, - }, { "label": "translated.customField.comments.input.filterBy.option.approvalStatus.option.approved.label", "value": "APPROVED", diff --git a/admin/src/custom-fields/comments/components/input/input.tsx b/admin/src/custom-fields/comments/components/input/input.tsx index a7c0ebc1..c6ca2303 100644 --- a/admin/src/custom-fields/comments/components/input/input.tsx +++ b/admin/src/custom-fields/comments/components/input/input.tsx @@ -154,7 +154,7 @@ export const CustomFieldInput: React.FC = ({ onChange={onRenderTypeChange} > {getRenderTypeOptions(getMessage).map(({ value, label }) => ( - ))} @@ -170,9 +170,10 @@ export const CustomFieldInput: React.FC = ({ )} value={currentState.sortByDate} onChange={onSortByDateChange} + onClear={() => onSortByDateChange(undefined)} > {getSortByDateOptions(getMessage).map(({ value, label }) => ( - ))} @@ -190,9 +191,10 @@ export const CustomFieldInput: React.FC = ({ )} value={currentState.filterBy} onChange={onFilterByChange} + onClear={() => onFilterByChange(undefined)} > {getFilterByOptions(getMessage).map(({ value, label }) => ( - ))} @@ -208,10 +210,11 @@ export const CustomFieldInput: React.FC = ({ name={`${name}.filterBy.approvalStatus`} value={currentState.filterByValue} onChange={onFilterByValueChange} + onClear={() => onFilterByValueChange(undefined)} > {getApprovalStatusOptions(getMessage).map( ({ value, label }) => ( - ) @@ -227,6 +230,7 @@ export const CustomFieldInput: React.FC = ({ disabled={disabled} name={`${name}.filterBy.dateCreated`} onChange={onFilterByValueChange} + onClear={() => onFilterByValueChange(undefined)} selectedDate={currentState.filterByValue} selectedDateLabel={asString} /> diff --git a/admin/src/custom-fields/comments/components/input/utils.ts b/admin/src/custom-fields/comments/components/input/utils.ts index 1079ea8e..c06e6180 100644 --- a/admin/src/custom-fields/comments/components/input/utils.ts +++ b/admin/src/custom-fields/comments/components/input/utils.ts @@ -83,7 +83,7 @@ export const handlePopulateChange = }); }; -export const getRenderTypeOptions = (translate: typeof getMessage) => [ +export const getRenderTypeOptions = (translate: typeof getMessage) => ([ { value: "TREE", label: translate({ @@ -98,13 +98,9 @@ export const getRenderTypeOptions = (translate: typeof getMessage) => [ defaultMessage: "Flat list", }), }, -]; +]); -export const getSortByDateOptions = (translate: typeof getMessage) => [ - { - value: undefined, - label: "", - }, +export const getSortByDateOptions = (translate: typeof getMessage) => ([ { value: "ASC", label: translate({ @@ -119,13 +115,9 @@ export const getSortByDateOptions = (translate: typeof getMessage) => [ defaultMessage: "Descending", }), }, -]; +]); -export const getFilterByOptions = (translate: typeof getMessage) => [ - { - value: undefined, - label: "", - }, +export const getFilterByOptions = (translate: typeof getMessage) => ([ { value: "DATE_CREATED", label: translate({ @@ -140,13 +132,9 @@ export const getFilterByOptions = (translate: typeof getMessage) => [ defaultMessage: "Approval Status", }), }, -]; +]); -export const getApprovalStatusOptions = (translate: typeof getMessage) => [ - { - value: undefined, - label: "", - }, +export const getApprovalStatusOptions = (translate: typeof getMessage) => ([ { value: APPROVAL_STATUS.APPROVED, label: translate({ @@ -168,7 +156,7 @@ export const getApprovalStatusOptions = (translate: typeof getMessage) => [ defaultMessage: "Rejected", }), }, -]; +]); const stringFields = [ "renderType", diff --git a/package.json b/package.json index 8c5dc192..f548a1bc 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "url": "https://github.com/VirtusLab-Open-Source/strapi-plugin-comments" }, "dependencies": { - "@strapi/plugin-graphql": "^4.10.7", - "@strapi/utils": "^4.10.7", + "@strapi/plugin-graphql": "^4.11.7", + "@strapi/utils": "^4.11.7", "@types/axios": "^0.14.0", "@types/react-intl": "^3.0.0", "@types/react-query": "^1.2.9", @@ -39,7 +39,7 @@ "codemirror5": "npm:codemirror@^5.65.11" }, "devDependencies": { - "@strapi/helper-plugin": "^4.10.7", + "@strapi/helper-plugin": "^4.11.7", "@types/bad-words": "^3.0.1", "@types/jest": "^29.4.0", "codecov": "^3.7.2", diff --git a/server/services/admin.ts b/server/services/admin.ts index 0c03154e..54eb75e3 100644 --- a/server/services/admin.ts +++ b/server/services/admin.ts @@ -776,6 +776,6 @@ export = ({ strapi }: StrapiContext): IServiceAdmin => ({ }; } - return undefined; + return true; }, }); diff --git a/yarn.lock b/yarn.lock index a957f3c3..262355d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -632,11 +632,6 @@ resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.2.2.tgz#66f62cf1b7de2ed23a09c101808536e68caffaec" integrity sha512-FaO9KVLFnxknZaGWGmNtjD2CVFuc0u4yeGEofoyXO2wgRA7fLtkngT6UB0vtWQWuhH3iMTZZ/Y89CMeyGfn8pA== -"@floating-ui/core@^1.2.3": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.2.4.tgz#89e6311b021190c9e121fcf20306e76ac66e4066" - integrity sha512-SQOeVbMwb1di+mVWWJLpsUTToKfqVNioXys011beCAhyOIFtS+GQoW4EQSneuxzmQKddExDwQ+X0hLl4lJJaSQ== - "@floating-ui/core@^1.3.1": version "1.3.1" resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.3.1.tgz#4d795b649cc3b1cbb760d191c80dcb4353c9a366" @@ -649,13 +644,6 @@ dependencies: "@floating-ui/core" "^1.2.2" -"@floating-ui/dom@^1.2.1": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.2.4.tgz#e2eb2674f57fc182c425587e48ea43e336f4b8f8" - integrity sha512-4+k+BLhtWj+peCU60gp0+rHeR8+Ohqx6kjJf/lHMnJ8JD5Qj6jytcq1+SZzRwD7rvHKRhR7TDiWWddrNrfwQLg== - dependencies: - "@floating-ui/core" "^1.2.3" - "@floating-ui/dom@^1.3.0": version "1.4.4" resolved "https://registry.yarnpkg.com/@floating-ui/dom/-/dom-1.4.4.tgz#cf859dde33995a4e7b6ded16c98cb73b2ebfffd0" @@ -663,14 +651,7 @@ dependencies: "@floating-ui/core" "^1.3.1" -"@floating-ui/react-dom@^1.3.0": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-1.3.0.tgz#4d35d416eb19811c2b0e9271100a6aa18c1579b3" - integrity sha512-htwHm67Ji5E/pROEAr7f8IKFShuiCKHwUC/UY4vC3I5jiSvGFAYnSYiZO5MlGmads+QqvUkR9ANHEguGrDv72g== - dependencies: - "@floating-ui/dom" "^1.2.1" - -"@floating-ui/react-dom@^2.0.0": +"@floating-ui/react-dom@^2.0.0", "@floating-ui/react-dom@^2.0.1": version "2.0.1" resolved "https://registry.yarnpkg.com/@floating-ui/react-dom/-/react-dom-2.0.1.tgz#7972a4fc488a8c746cded3cfe603b6057c308a91" integrity sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA== @@ -867,14 +848,14 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.1.2.tgz#6fc464307cbe3c8ca5064549b806360d84457b04" integrity sha512-9anpBMM9mEgZN4wr2v8wHJI2/u5TnnggewRN6OlvXTTnuVyoY19X6rOv9XTqKRw6dcGKwZsBi8n0kDE2I5i4VA== -"@internationalized/date@^3.2.0": +"@internationalized/date@^3.3.0": version "3.3.0" resolved "https://registry.yarnpkg.com/@internationalized/date/-/date-3.3.0.tgz#90386d4b4e707f28507d1a1b3cc0e162ad5ee038" integrity sha512-qfRd7jCIgUjabI8RxeAsxhLDRS1u8eUPX96GB5uBp1Tpm6YY6dVveE7YwsTEV6L4QOp5LKFirFHHGsL/XQwJIA== dependencies: "@swc/helpers" "^0.5.0" -"@internationalized/number@^3.2.0": +"@internationalized/number@^3.2.1": version "3.2.1" resolved "https://registry.yarnpkg.com/@internationalized/number/-/number-3.2.1.tgz#570e4010544a84a8225e65b34a689a36187caaa8" integrity sha512-hK30sfBlmB1aIe3/OwAPg9Ey0DjjXvHEiGVhNaOiBJl31G0B6wMaX8BN3ibzdlpyRNE9p7X+3EBONmxtJO9Yfg== @@ -1528,29 +1509,29 @@ dependencies: "@sinonjs/commons" "^2.0.0" -"@strapi/design-system@1.8.1": - version "1.8.1" - resolved "https://registry.yarnpkg.com/@strapi/design-system/-/design-system-1.8.1.tgz#de0ea1b8eb702ed1032cb7592e39fa03fe9d3fc2" - integrity sha512-2mpTgY6xgL/BBIIcOGqfy2Pf4nHxwUZC3VKU7cNPwAMJSxO+uRW4KN9FnkFXHEvfXUlDuCx7CutAoKsOXF5LjA== +"@strapi/design-system@1.8.2": + version "1.8.2" + resolved "https://registry.yarnpkg.com/@strapi/design-system/-/design-system-1.8.2.tgz#8f70d7231f5a3bf43ac9e36bf903fc13f06ae746" + integrity sha512-PBS/F9bCiNbM4hr6AY4QOR+QhxajLvtoJKLIhPfmmPCkPorT46DzvggTveJku/1bWiJmkVHhqytsKEhrvMsjHQ== dependencies: "@codemirror/lang-json" "^6.0.1" - "@floating-ui/react-dom" "^1.3.0" - "@internationalized/date" "^3.2.0" - "@internationalized/number" "^3.2.0" + "@floating-ui/react-dom" "^2.0.1" + "@internationalized/date" "^3.3.0" + "@internationalized/number" "^3.2.1" "@radix-ui/react-dismissable-layer" "^1.0.4" "@radix-ui/react-dropdown-menu" "^2.0.5" "@radix-ui/react-focus-scope" "1.0.3" - "@strapi/ui-primitives" "^1.8.1" - "@uiw/react-codemirror" "^4.21.3" + "@strapi/ui-primitives" "^1.8.2" + "@uiw/react-codemirror" "^4.21.7" aria-hidden "^1.2.3" compute-scroll-into-view "^3.0.3" prop-types "^15.8.1" - react-remove-scroll "^2.5.5" + react-remove-scroll "^2.5.6" -"@strapi/helper-plugin@4.11.4", "@strapi/helper-plugin@^4.10.7": - version "4.11.4" - resolved "https://registry.yarnpkg.com/@strapi/helper-plugin/-/helper-plugin-4.11.4.tgz#f6317ac7d97e4963d8d6312d0122a960ebefe395" - integrity sha512-H0DObDZP6jIitNPvv2nFbtwbUzD8MYJCDoclbdooeyKW1UoxNOuphoVpZdbsHbyUgN2HqHo08GWevaX6NPhQwQ== +"@strapi/helper-plugin@4.11.7", "@strapi/helper-plugin@^4.11.7": + version "4.11.7" + resolved "https://registry.yarnpkg.com/@strapi/helper-plugin/-/helper-plugin-4.11.7.tgz#7cf4291e0585d9fcb19cff9ff1daee400d18f5db" + integrity sha512-Q6uAgkwrvSw3UQgS5UiCSqFmzpnQl/U6fQlSvPdeOTfWHOt1YdzSEVCUP6K0zx1VCydByzGYNe/EjEGuGZDsJA== dependencies: axios "1.4.0" date-fns "2.30.0" @@ -1564,29 +1545,29 @@ react-query "3.39.3" react-select "5.7.0" -"@strapi/icons@1.8.1": - version "1.8.1" - resolved "https://registry.yarnpkg.com/@strapi/icons/-/icons-1.8.1.tgz#7a07f7b9002505ee7c0208befd2eacac7f680935" - integrity sha512-iafpAfqPXJbuIkBMjJ4wuPR8ovPjIlDsA9BdGsexfrlGofvePkYDHRZxzxt/VGJprFpac4+RilFtpombCYQoGg== +"@strapi/icons@1.8.2": + version "1.8.2" + resolved "https://registry.yarnpkg.com/@strapi/icons/-/icons-1.8.2.tgz#d838e6566ba67ecb9adc0fce773cf54e93a13d59" + integrity sha512-FiSYN7bDk7B8nieXLddyRgU3xMWjOcRSL2Q7b8A+pedIDLiIpfrDnsSlzmpVpU7LtQSnkOcDlFHqEXEm7zwIvg== -"@strapi/plugin-graphql@^4.10.7": - version "4.11.4" - resolved "https://registry.yarnpkg.com/@strapi/plugin-graphql/-/plugin-graphql-4.11.4.tgz#1f286792fe281fcf8908bc3810664e221e66d1ac" - integrity sha512-KgzOhKuv31AGIOx1CkoYPkK2+zgDWGo0cPsnYLn8iF8NAU3V7rvMx9UL+8PDSzcOIGSYZlOmcnOZQpc05o7oCg== +"@strapi/plugin-graphql@^4.11.7": + version "4.11.7" + resolved "https://registry.yarnpkg.com/@strapi/plugin-graphql/-/plugin-graphql-4.11.7.tgz#d094deb01b7971267bb195599ab72ef7594436d0" + integrity sha512-gNKvjcBpR1Hb8pegLodVkCqkqwP/XmIVZfk9bB5qeUTyvFdyrwNY2BgPST2MAKt2PZw0fZPaigda6VTX24hHVA== dependencies: "@graphql-tools/schema" "8.5.1" "@graphql-tools/utils" "^8.13.1" - "@strapi/design-system" "1.8.1" - "@strapi/helper-plugin" "4.11.4" - "@strapi/icons" "1.8.1" - "@strapi/utils" "4.11.4" + "@strapi/design-system" "1.8.2" + "@strapi/helper-plugin" "4.11.7" + "@strapi/icons" "1.8.2" + "@strapi/utils" "4.11.7" apollo-server-core "3.12.0" apollo-server-koa "3.10.0" glob "^7.1.7" graphql "^15.5.1" graphql-depth-limit "^1.1.0" graphql-playground-middleware-koa "^1.6.21" - graphql-scalars "1.20.1" + graphql-scalars "1.22.2" graphql-upload "^13.0.0" koa-compose "^4.1.0" lodash "4.17.21" @@ -1615,7 +1596,7 @@ pluralize "^8.0.0" subscriptions-transport-ws "0.9.19" -"@strapi/ui-primitives@^1.8.1": +"@strapi/ui-primitives@^1.8.2": version "1.8.2" resolved "https://registry.yarnpkg.com/@strapi/ui-primitives/-/ui-primitives-1.8.2.tgz#31e056c50993a898df7704329a87f3ef7d85221d" integrity sha512-33GDdBXyH8BtBNyjUNiiZVoZ0R9BPtcKhCIb9VtR6RoyR/OVoAOgA3cOO9isxrwh8LZFP2BgofKW62ew3Y801w== @@ -1642,10 +1623,10 @@ aria-hidden "^1.2.3" react-remove-scroll "^2.5.6" -"@strapi/utils@4.11.4", "@strapi/utils@^4.10.7": - version "4.11.4" - resolved "https://registry.yarnpkg.com/@strapi/utils/-/utils-4.11.4.tgz#9b006498159aac345bad3231029487e2a45c6656" - integrity sha512-eNpaj9OmwfdkeDBPYZxTDgCHo1vbhrd4PrFxEJr6vdSd3YYhmX53/OgdL277xbVokt+LOdYKSUUJwsfTQp1Fbw== +"@strapi/utils@4.11.7", "@strapi/utils@^4.11.7": + version "4.11.7" + resolved "https://registry.yarnpkg.com/@strapi/utils/-/utils-4.11.7.tgz#5d22866fc3df011af31a014870e9dd51e1eee704" + integrity sha512-NAnjcKxR9rpJFKsRgqDtjImoKEUrK0Zf5y+5AAowWtteyWXYujkUxNpWYKJ8D08sFnp//MyP8fT6Rtu196ZQTQ== dependencies: "@sindresorhus/slugify" "1.1.0" date-fns "2.30.0" @@ -2010,10 +1991,10 @@ dependencies: "@types/yargs-parser" "*" -"@uiw/codemirror-extensions-basic-setup@4.21.7": - version "4.21.7" - resolved "https://registry.yarnpkg.com/@uiw/codemirror-extensions-basic-setup/-/codemirror-extensions-basic-setup-4.21.7.tgz#59bcaea0e9075f733a6331fb0c4d2e9ef2e965e0" - integrity sha512-T5JvfGcocytnIOxTMvHxzcBn1PDAqZS1wnPblGnvOLRW0pUnXoqaOeBC+QI7h+3PGM5uCzPnzvaY+jqYwFDiZg== +"@uiw/codemirror-extensions-basic-setup@4.21.8": + version "4.21.8" + resolved "https://registry.yarnpkg.com/@uiw/codemirror-extensions-basic-setup/-/codemirror-extensions-basic-setup-4.21.8.tgz#89980ffd4801b29984162ab4c44203b4d29038ae" + integrity sha512-uOPRPxexapuvlZ+hkVun5oyhQ0AtXIapBqv56cgjkzwZ49EILUk9mTubHFBY0B5kPqme7d57hSXYRLW8EH80LA== dependencies: "@codemirror/autocomplete" "^6.0.0" "@codemirror/commands" "^6.0.0" @@ -2023,16 +2004,16 @@ "@codemirror/state" "^6.0.0" "@codemirror/view" "^6.0.0" -"@uiw/react-codemirror@^4.21.3": - version "4.21.7" - resolved "https://registry.yarnpkg.com/@uiw/react-codemirror/-/react-codemirror-4.21.7.tgz#4f04d3d60f530633ab6aff79991d366313f165bf" - integrity sha512-nrWlH0PZyfew+5gj6o5vp5imJYO8jgkxjqO+tfLovo7T/6AlKJaZIlU1nAobxqKn3mSbgjSZ9GCEDybvrbF6DA== +"@uiw/react-codemirror@^4.21.7": + version "4.21.8" + resolved "https://registry.yarnpkg.com/@uiw/react-codemirror/-/react-codemirror-4.21.8.tgz#0b2d833a0c7256c23f83b342463276c762863bad" + integrity sha512-IwnWdZcBkNIHrQie/AAsBoz2Q/XpWe/Up1nGIrpWxMXEE/+RxW3CIkqcYEwVcYDJlbfP3hcIRqN/Aoz6OeXc5Q== dependencies: "@babel/runtime" "^7.18.6" "@codemirror/commands" "^6.1.0" "@codemirror/state" "^6.1.1" "@codemirror/theme-one-dark" "^6.0.0" - "@uiw/codemirror-extensions-basic-setup" "4.21.7" + "@uiw/codemirror-extensions-basic-setup" "4.21.8" codemirror "^6.0.0" abbrev@1: @@ -3198,6 +3179,13 @@ graphql-scalars@1.20.1: dependencies: tslib "~2.4.0" +graphql-scalars@1.22.2: + version "1.22.2" + resolved "https://registry.yarnpkg.com/graphql-scalars/-/graphql-scalars-1.22.2.tgz#6326e6fe2d0ad4228a9fea72a977e2bf26b86362" + integrity sha512-my9FB4GtghqXqi/lWSVAOPiTzTnnEzdOXCsAC2bb5V7EFNQjVjwy3cSSbUvgYOtDuDibd+ZsCDhz+4eykYOlhQ== + dependencies: + tslib "^2.5.0" + graphql-tag@^2.11.0: version "2.12.6" resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.6.tgz#d441a569c1d2537ef10ca3d1633b48725329b5f1" @@ -4643,7 +4631,7 @@ react-remove-scroll@2.5.5: use-callback-ref "^1.3.0" use-sidecar "^1.1.2" -react-remove-scroll@^2.5.5, react-remove-scroll@^2.5.6: +react-remove-scroll@^2.5.6: version "2.5.6" resolved "https://registry.yarnpkg.com/react-remove-scroll/-/react-remove-scroll-2.5.6.tgz#7510b8079e9c7eebe00e65a33daaa3aa29a10336" integrity sha512-bO856ad1uDYLefgArk559IzUNeQ6SWH4QnrevIUjH+GczV56giDfl3h0Idptf2oIKxQmd1p9BN25jleKodTALg== @@ -5203,6 +5191,11 @@ tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf" integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg== +tslib@^2.5.0: + version "2.6.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" + integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== + tslib@~2.4.0: version "2.4.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.1.tgz#0d0bfbaac2880b91e22df0768e55be9753a5b17e"