Skip to content

Commit

Permalink
some adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
luancazarine committed May 13, 2024
1 parent 7eff245 commit 2b5b344
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { camelCaseToWords } from "../../common/utils.mjs";
import {
camelCaseToWords, parseObject,
} from "../../common/utils.mjs";
import twenty from "../../twenty.app.mjs";

export default {
Expand All @@ -23,6 +25,12 @@ export default {
],
reloadProps: true,
},
additionalProp: {
type: "object",
label: "Additional Prop",
description: "Any additional prop you want to fill.",
optional: true,
},
},
async additionalProps() {
const props = {};
Expand Down Expand Up @@ -94,6 +102,7 @@ export default {
id,
recordId,
actionType,
additionalProp,
...data
} = this;

Expand All @@ -110,7 +119,12 @@ export default {
id,
actionType: this.actionType,
recordName: tags[index + 1].name,
data,
data: {
...data,
...(additionalProp
? parseObject(additionalProp)
: {}),
},
});

$.export("$summary", `Successfully performed ${actionType} ${recordId} on record with ID: ${id || response.data[`${actionType}${recordId}`].id}`);
Expand Down
23 changes: 23 additions & 0 deletions components/twenty/common/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,26 @@ export const camelCaseToWords = (s) => {
export const capitalizeFirstLetter = (string) => {
return string.charAt(0).toLowerCase() + string.slice(1);
};

export const parseObject = (obj) => {
if (Array.isArray(obj)) {
return obj.map((item) => {
if (typeof item === "string") {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
}
return item;
});
}
if (typeof obj === "string") {
try {
return JSON.parse(obj);
} catch (e) {
return obj;
}
}
return obj;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import twenty from "../../twenty.app.mjs";
import sampleEmit from "./test-event.mjs";

export default {
key: "twenty-new-record-instant",
name: "New Record (Instant)",
key: "twenty-new-record-modified-instant",
name: "New Record Modified (Instant)",
description: "Emit new event when a record is created, updated, or deleted.",
version: "0.0.1",
type: "source",
Expand Down

0 comments on commit 2b5b344

Please sign in to comment.