Skip to content

Commit 8842e0f

Browse files
authored
Merge pull request #643 from rowyio/rc
v2.3.1
2 parents 2c1e4b0 + 0bd7d81 commit 8842e0f

File tree

6 files changed

+41
-51
lines changed

6 files changed

+41
-51
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Rowy",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"homepage": "https://rowy.io",
55
"repository": {
66
"type": "git",

src/components/TableHeader/Extensions/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,13 @@ export function emptyExtensionObject(
172172
user: IExtensionEditor
173173
): IExtension {
174174
return {
175-
name: "Untitled extension",
175+
name: `${type} extension`,
176176
active: false,
177177
triggers: [],
178178
type,
179179
extensionBody: extensionBodyTemplate[type] ?? extensionBodyTemplate["task"],
180180
requiredFields: [],
181+
trackedFields: [],
181182
conditions: `const condition: Condition = async({row, change}) => {
182183
// feel free to add your own code logic here
183184
return true;

src/components/fields/Status/ConditionModal.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ export default function ConditionModal({
1919
setModal(EMPTY_STATE);
2020
};
2121
const handleAdd = () => {
22-
const labelIsEmpty = Boolean(modal.condition.label.length < 4);
23-
const stringValueIsEmpty = Boolean(
24-
modal.condition.type === "string" && modal.condition.value.length === 0
25-
);
26-
const hasDuplicate = Boolean(_find(conditions, modal.condition));
27-
const validation = Boolean(
28-
labelIsEmpty || stringValueIsEmpty || hasDuplicate
29-
);
30-
if (validation) return;
3122
function setConditionHack(type, condition) {
3223
let rCondition = condition;
3324
if (type === "undefined") rCondition = { ...condition, value: undefined };
@@ -100,12 +91,7 @@ export default function ConditionModal({
10091
secondary: secondaryAction(modal.index),
10192
}}
10293
children={
103-
<Content
104-
isEditing={modal.index}
105-
condition={modal.condition}
106-
conditions={conditions}
107-
handleUpdate={handleUpdate}
108-
/>
94+
<Content condition={modal.condition} handleUpdate={handleUpdate} />
10995
}
11096
/>
11197
);

src/components/fields/Status/ConditionModalContent.tsx

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,22 @@ import TextField from "@mui/material/TextField";
44
import Typography from "@mui/material/Typography";
55
import MultiSelect from "@rowy/multiselect";
66

7-
interface I_ConditionModalContent {
8-
handleUpdate: () => void;
9-
modal: any;
10-
}
11-
127
export default function ConditionModalContent({
13-
isEditing,
148
condition,
15-
conditions,
169
handleUpdate,
1710
}: any) {
1811
const { label, operator, type, value } = condition;
19-
const labelReqLen = Boolean(condition.label.length < 1);
20-
const onNewHasDuplicate = Boolean(_find(conditions, condition));
21-
const onEditConditions = conditions.filter(
22-
(c) => c.value !== condition.value
23-
); //remove the current condition from list of conditions, to prevent false positive error on duplicate value
24-
const onEditHasDuplicate = Boolean(_find(onEditConditions, condition));
25-
26-
const errorTextType = (isEditing: boolean, error: string) => {
27-
const hasError = isEditing ? onEditHasDuplicate : onNewHasDuplicate;
28-
return hasError ? error : "";
29-
};
3012

3113
return (
3214
<>
3315
<Typography variant="overline">DATA TYPE (input)</Typography>
3416
<MultiSelect
3517
options={[
36-
{ label: "True", value: "true" },
37-
{ label: "False", value: "false" },
18+
{ label: "Boolean", value: "boolean" },
19+
{ label: "Number", value: "number" },
20+
{ label: "String", value: "string" },
21+
{ label: "Undefined", value: "undefined" },
22+
{ label: "Null", value: "null" },
3823
]}
3924
onChange={(v) => handleUpdate("type")(v)}
4025
value={type}
@@ -46,11 +31,8 @@ export default function ConditionModalContent({
4631
{type === "boolean" && (
4732
<MultiSelect
4833
options={[
49-
{ label: "Boolean", value: "boolean" },
50-
{ label: "Number", value: "number" },
51-
{ label: "String", value: "string" },
52-
{ label: "Undefined", value: "undefined" },
53-
{ label: "Null", value: "null" },
34+
{ label: "True", value: "true" },
35+
{ label: "False", value: "false" },
5436
]}
5537
onChange={(v) => handleUpdate("value")(v === "true")}
5638
value={value ? "true" : "false"}
@@ -76,27 +58,22 @@ export default function ConditionModalContent({
7658
/>
7759
</div>
7860
<TextField
79-
error={isEditing ? onEditHasDuplicate : onNewHasDuplicate}
8061
type="number"
8162
label="Value"
8263
value={value}
8364
onChange={(e) => handleUpdate("value")(Number(e.target.value))}
84-
helperText={errorTextType(isEditing, "Number value already exists")}
8565
/>
8666
</Grid>
8767
)}
8868
{type === "string" && (
8969
<TextField
90-
error={isEditing ? onEditHasDuplicate : onNewHasDuplicate}
9170
fullWidth
9271
label="Value"
9372
value={value}
9473
onChange={(e) => handleUpdate("value")(e.target.value)}
95-
helperText={errorTextType(isEditing, "String value already exists")}
9674
/>
9775
)}
9876
<TextField
99-
error={labelReqLen}
10077
value={label}
10178
label="Label"
10279
fullWidth

src/contexts/ProjectContext.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,19 @@ export const ProjectContextProvider: React.FC = ({ children }) => {
301301
})
302302
.then(
303303
() => console.log("Field Value deleted"),
304-
(error) => console.error("Failed to delete", error)
304+
(error) => {
305+
if (error.code === "permission-denied") {
306+
enqueueSnackbar(`You don't have permission to delete this field`, {
307+
variant: "error",
308+
anchorOrigin: { horizontal: "center", vertical: "top" },
309+
});
310+
} else {
311+
enqueueSnackbar(error.message, {
312+
variant: "error",
313+
anchorOrigin: { horizontal: "center", vertical: "top" },
314+
});
315+
}
316+
}
305317
);
306318
};
307319

@@ -335,6 +347,11 @@ export const ProjectContextProvider: React.FC = ({ children }) => {
335347
anchorOrigin: { horizontal: "center", vertical: "top" },
336348
}
337349
);
350+
} else {
351+
enqueueSnackbar(error.message, {
352+
variant: "error",
353+
anchorOrigin: { horizontal: "center", vertical: "top" },
354+
});
338355
}
339356
}
340357
);

src/hooks/useTable/useTableConfig.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,30 @@ const useTableConfig = (tableId?: string) => {
153153
});
154154
};
155155
/** remove column by index
156-
* @param index of column.
156+
* @param key of column.
157157
*/
158158
const remove = (key: string) => {
159159
const { columns } = tableConfigState;
160160

161-
let updatedColumns: any = Object.values(columns)
161+
/**
162+
* Filter column, and remove key index
163+
* Sort and reorder column
164+
* Rewrite column index for firestore
165+
*/
166+
const updatedColumns: any = Object.values(columns)
162167
.filter((c: any) => c.key !== key)
163168
.sort((c: any) => c.index)
164169
.reduce((acc: any, curr: any, index: any) => {
165170
acc[curr.key] = { ...curr, index };
166171
return acc;
167172
}, {});
173+
174+
const deleteColumn = { [key]: deleteField() };
175+
const finalColumns = { ...updatedColumns, ...deleteColumn };
176+
168177
documentDispatch({
169178
action: DocActions.update,
170-
data: { columns: updatedColumns },
179+
data: { columns: finalColumns },
171180
});
172181
};
173182
/** reorder columns by key

0 commit comments

Comments
 (0)