Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cyp3rius authored Jul 25, 2023
1 parent a22cd23 commit 03d504a
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions admin/src/custom-fields/comments/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const CustomFieldInput: React.FC<CustomFieldInputProps> = ({
onChange={onRenderTypeChange}
>
{getRenderTypeOptions(getMessage).map(({ value, label }) => (
<Option key={value} value={value}>
<Option key={`renderTypeOptions-${value}`} value={value}>
{label}
</Option>
))}
Expand All @@ -170,9 +170,10 @@ export const CustomFieldInput: React.FC<CustomFieldInputProps> = ({
)}
value={currentState.sortByDate}
onChange={onSortByDateChange}
onClear={() => onSortByDateChange(undefined)}
>
{getSortByDateOptions(getMessage).map(({ value, label }) => (
<Option key={value} value={value}>
<Option key={`sortByDataOptions-${value}`} value={value}>
{label}
</Option>
))}
Expand All @@ -190,9 +191,10 @@ export const CustomFieldInput: React.FC<CustomFieldInputProps> = ({
)}
value={currentState.filterBy}
onChange={onFilterByChange}
onClear={() => onFilterByChange(undefined)}
>
{getFilterByOptions(getMessage).map(({ value, label }) => (
<Option key={value} value={value}>
<Option key={`filterByOptions-${value}`} value={value}>
{label}
</Option>
))}
Expand All @@ -208,10 +210,11 @@ export const CustomFieldInput: React.FC<CustomFieldInputProps> = ({
name={`${name}.filterBy.approvalStatus`}
value={currentState.filterByValue}
onChange={onFilterByValueChange}
onClear={() => onFilterByValueChange(undefined)}
>
{getApprovalStatusOptions(getMessage).map(
({ value, label }) => (
<Option key={value} value={value}>
<Option key={`approvalStatusOptions-${value}`} value={value}>
{label}
</Option>
)
Expand All @@ -227,6 +230,7 @@ export const CustomFieldInput: React.FC<CustomFieldInputProps> = ({
disabled={disabled}
name={`${name}.filterBy.dateCreated`}
onChange={onFilterByValueChange}
onClear={() => onFilterByValueChange(undefined)}
selectedDate={currentState.filterByValue}
selectedDateLabel={asString}
/>
Expand Down
28 changes: 8 additions & 20 deletions admin/src/custom-fields/comments/components/input/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const handlePopulateChange =
});
};

export const getRenderTypeOptions = (translate: typeof getMessage) => [
export const getRenderTypeOptions = (translate: typeof getMessage) => ([
{
value: "TREE",
label: translate({
Expand All @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand All @@ -168,7 +156,7 @@ export const getApprovalStatusOptions = (translate: typeof getMessage) => [
defaultMessage: "Rejected",
}),
},
];
]);

const stringFields = [
"renderType",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion server/services/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,6 @@ export = ({ strapi }: StrapiContext): IServiceAdmin => ({
};
}

return undefined;
return true;
},
});
Loading

0 comments on commit 03d504a

Please sign in to comment.