From 58208d032a3d9680222a3b95447b64addc87c325 Mon Sep 17 00:00:00 2001 From: shamsmosowi Date: Mon, 7 Feb 2022 15:43:07 +0800 Subject: [PATCH 1/7] handle delete cell errors --- src/contexts/ProjectContext.tsx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/contexts/ProjectContext.tsx b/src/contexts/ProjectContext.tsx index 8c6e9d660..f8f3b9155 100644 --- a/src/contexts/ProjectContext.tsx +++ b/src/contexts/ProjectContext.tsx @@ -301,7 +301,22 @@ export const ProjectContextProvider: React.FC = ({ children }) => { }) .then( () => console.log("Field Value deleted"), - (error) => console.error("Failed to delete", error) + (error) => { + if (error.code === "permission-denied") { + enqueueSnackbar( + `You do not have the permissions to make this change.`, + { + variant: "error", + anchorOrigin: { horizontal: "center", vertical: "top" }, + } + ); + } else { + enqueueSnackbar(error.message, { + variant: "error", + anchorOrigin: { horizontal: "center", vertical: "top" }, + }); + } + } ); }; @@ -335,6 +350,11 @@ export const ProjectContextProvider: React.FC = ({ children }) => { anchorOrigin: { horizontal: "center", vertical: "top" }, } ); + } else { + enqueueSnackbar(error.message, { + variant: "error", + anchorOrigin: { horizontal: "center", vertical: "top" }, + }); } } ); From 821516b3a13aa818794e505f14115fb10b3a5552 Mon Sep 17 00:00:00 2001 From: shamsmosowi Date: Mon, 7 Feb 2022 15:43:07 +0800 Subject: [PATCH 2/7] handle delete cell errors --- src/contexts/ProjectContext.tsx | 22 +++++++++++++++++++++- src/hooks/useTable/useTableConfig.ts | 15 ++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/contexts/ProjectContext.tsx b/src/contexts/ProjectContext.tsx index 8c6e9d660..f8f3b9155 100644 --- a/src/contexts/ProjectContext.tsx +++ b/src/contexts/ProjectContext.tsx @@ -301,7 +301,22 @@ export const ProjectContextProvider: React.FC = ({ children }) => { }) .then( () => console.log("Field Value deleted"), - (error) => console.error("Failed to delete", error) + (error) => { + if (error.code === "permission-denied") { + enqueueSnackbar( + `You do not have the permissions to make this change.`, + { + variant: "error", + anchorOrigin: { horizontal: "center", vertical: "top" }, + } + ); + } else { + enqueueSnackbar(error.message, { + variant: "error", + anchorOrigin: { horizontal: "center", vertical: "top" }, + }); + } + } ); }; @@ -335,6 +350,11 @@ export const ProjectContextProvider: React.FC = ({ children }) => { anchorOrigin: { horizontal: "center", vertical: "top" }, } ); + } else { + enqueueSnackbar(error.message, { + variant: "error", + anchorOrigin: { horizontal: "center", vertical: "top" }, + }); } } ); diff --git a/src/hooks/useTable/useTableConfig.ts b/src/hooks/useTable/useTableConfig.ts index d8e462449..a2fa953d1 100644 --- a/src/hooks/useTable/useTableConfig.ts +++ b/src/hooks/useTable/useTableConfig.ts @@ -153,21 +153,30 @@ const useTableConfig = (tableId?: string) => { }); }; /** remove column by index - * @param index of column. + * @param key of column. */ const remove = (key: string) => { const { columns } = tableConfigState; - let updatedColumns: any = Object.values(columns) + /** + * Filter column, and remove key index + * Sort and reorder column + * Rewrite column index for firestore + */ + const updatedColumns: any = Object.values(columns) .filter((c: any) => c.key !== key) .sort((c: any) => c.index) .reduce((acc: any, curr: any, index: any) => { acc[curr.key] = { ...curr, index }; return acc; }, {}); + + const deleteColumn = { [key]: deleteField() }; + const finalColumns = { ...updatedColumns, ...deleteColumn }; + documentDispatch({ action: DocActions.update, - data: { columns: updatedColumns }, + data: { columns: finalColumns }, }); }; /** reorder columns by key From bf7d52c770d8d613cb482c510af4dd3bfb458a7b Mon Sep 17 00:00:00 2001 From: Gibson Han Date: Mon, 7 Feb 2022 15:27:19 +0700 Subject: [PATCH 3/7] fix multi-selection options --- .../fields/Status/ConditionModalContent.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/fields/Status/ConditionModalContent.tsx b/src/components/fields/Status/ConditionModalContent.tsx index 625431b76..8c234f266 100644 --- a/src/components/fields/Status/ConditionModalContent.tsx +++ b/src/components/fields/Status/ConditionModalContent.tsx @@ -33,8 +33,11 @@ export default function ConditionModalContent({ DATA TYPE (input) handleUpdate("type")(v)} value={type} @@ -46,11 +49,8 @@ export default function ConditionModalContent({ {type === "boolean" && ( handleUpdate("value")(v === "true")} value={value ? "true" : "false"} From c0aa3a06b51bd2673ceb872742a2f49d3a89a533 Mon Sep 17 00:00:00 2001 From: Gibson Han Date: Mon, 7 Feb 2022 15:29:58 +0700 Subject: [PATCH 4/7] remove duplicate validation check --- .../fields/Status/ConditionModal.tsx | 14 +++---------- .../fields/Status/ConditionModalContent.tsx | 21 ------------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/src/components/fields/Status/ConditionModal.tsx b/src/components/fields/Status/ConditionModal.tsx index 1e4b88de6..a027e761a 100644 --- a/src/components/fields/Status/ConditionModal.tsx +++ b/src/components/fields/Status/ConditionModal.tsx @@ -19,14 +19,11 @@ export default function ConditionModal({ setModal(EMPTY_STATE); }; const handleAdd = () => { - const labelIsEmpty = Boolean(modal.condition.label.length < 4); + const labelIsEmpty = Boolean(modal.condition.label.length === 0); const stringValueIsEmpty = Boolean( modal.condition.type === "string" && modal.condition.value.length === 0 ); - const hasDuplicate = Boolean(_find(conditions, modal.condition)); - const validation = Boolean( - labelIsEmpty || stringValueIsEmpty || hasDuplicate - ); + const validation = Boolean(labelIsEmpty || stringValueIsEmpty); if (validation) return; function setConditionHack(type, condition) { let rCondition = condition; @@ -100,12 +97,7 @@ export default function ConditionModal({ secondary: secondaryAction(modal.index), }} children={ - + } /> ); diff --git a/src/components/fields/Status/ConditionModalContent.tsx b/src/components/fields/Status/ConditionModalContent.tsx index 8c234f266..eb7340ae7 100644 --- a/src/components/fields/Status/ConditionModalContent.tsx +++ b/src/components/fields/Status/ConditionModalContent.tsx @@ -4,29 +4,12 @@ import TextField from "@mui/material/TextField"; import Typography from "@mui/material/Typography"; import MultiSelect from "@rowy/multiselect"; -interface I_ConditionModalContent { - handleUpdate: () => void; - modal: any; -} - export default function ConditionModalContent({ - isEditing, condition, - conditions, handleUpdate, }: any) { const { label, operator, type, value } = condition; const labelReqLen = Boolean(condition.label.length < 1); - const onNewHasDuplicate = Boolean(_find(conditions, condition)); - const onEditConditions = conditions.filter( - (c) => c.value !== condition.value - ); //remove the current condition from list of conditions, to prevent false positive error on duplicate value - const onEditHasDuplicate = Boolean(_find(onEditConditions, condition)); - - const errorTextType = (isEditing: boolean, error: string) => { - const hasError = isEditing ? onEditHasDuplicate : onNewHasDuplicate; - return hasError ? error : ""; - }; return ( <> @@ -76,23 +59,19 @@ export default function ConditionModalContent({ /> handleUpdate("value")(Number(e.target.value))} - helperText={errorTextType(isEditing, "Number value already exists")} /> )} {type === "string" && ( handleUpdate("value")(e.target.value)} - helperText={errorTextType(isEditing, "String value already exists")} /> )} Date: Mon, 7 Feb 2022 15:54:19 +0700 Subject: [PATCH 5/7] remove label length validation and string value validation --- src/components/fields/Status/ConditionModal.tsx | 6 ------ src/components/fields/Status/ConditionModalContent.tsx | 2 -- 2 files changed, 8 deletions(-) diff --git a/src/components/fields/Status/ConditionModal.tsx b/src/components/fields/Status/ConditionModal.tsx index a027e761a..c5455f8a3 100644 --- a/src/components/fields/Status/ConditionModal.tsx +++ b/src/components/fields/Status/ConditionModal.tsx @@ -19,12 +19,6 @@ export default function ConditionModal({ setModal(EMPTY_STATE); }; const handleAdd = () => { - const labelIsEmpty = Boolean(modal.condition.label.length === 0); - const stringValueIsEmpty = Boolean( - modal.condition.type === "string" && modal.condition.value.length === 0 - ); - const validation = Boolean(labelIsEmpty || stringValueIsEmpty); - if (validation) return; function setConditionHack(type, condition) { let rCondition = condition; if (type === "undefined") rCondition = { ...condition, value: undefined }; diff --git a/src/components/fields/Status/ConditionModalContent.tsx b/src/components/fields/Status/ConditionModalContent.tsx index eb7340ae7..22669a894 100644 --- a/src/components/fields/Status/ConditionModalContent.tsx +++ b/src/components/fields/Status/ConditionModalContent.tsx @@ -9,7 +9,6 @@ export default function ConditionModalContent({ handleUpdate, }: any) { const { label, operator, type, value } = condition; - const labelReqLen = Boolean(condition.label.length < 1); return ( <> @@ -75,7 +74,6 @@ export default function ConditionModalContent({ /> )} Date: Mon, 7 Feb 2022 17:11:22 +0800 Subject: [PATCH 6/7] add tracked fields to extention initial object --- src/components/TableHeader/Extensions/utils.ts | 3 ++- src/contexts/ProjectContext.tsx | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/TableHeader/Extensions/utils.ts b/src/components/TableHeader/Extensions/utils.ts index d8029d45f..6150ace71 100644 --- a/src/components/TableHeader/Extensions/utils.ts +++ b/src/components/TableHeader/Extensions/utils.ts @@ -172,12 +172,13 @@ export function emptyExtensionObject( user: IExtensionEditor ): IExtension { return { - name: "Untitled extension", + name: `${type} extension`, active: false, triggers: [], type, extensionBody: extensionBodyTemplate[type] ?? extensionBodyTemplate["task"], requiredFields: [], + trackedFields: [], conditions: `const condition: Condition = async({row, change}) => { // feel free to add your own code logic here return true; diff --git a/src/contexts/ProjectContext.tsx b/src/contexts/ProjectContext.tsx index f8f3b9155..1729a3e6d 100644 --- a/src/contexts/ProjectContext.tsx +++ b/src/contexts/ProjectContext.tsx @@ -303,13 +303,10 @@ export const ProjectContextProvider: React.FC = ({ children }) => { () => console.log("Field Value deleted"), (error) => { if (error.code === "permission-denied") { - enqueueSnackbar( - `You do not have the permissions to make this change.`, - { - variant: "error", - anchorOrigin: { horizontal: "center", vertical: "top" }, - } - ); + enqueueSnackbar(`You don't have permission to delete this field`, { + variant: "error", + anchorOrigin: { horizontal: "center", vertical: "top" }, + }); } else { enqueueSnackbar(error.message, { variant: "error", From 0bd7d8173d65462f076667e762629890206742ed Mon Sep 17 00:00:00 2001 From: Sidney Alcantara Date: Wed, 9 Feb 2022 18:11:54 +1100 Subject: [PATCH 7/7] bump version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e47dc70a..f3ee252df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Rowy", - "version": "2.3.0", + "version": "2.3.1", "homepage": "https://rowy.io", "repository": { "type": "git",