Skip to content

Commit

Permalink
Merge pull request rowyio#1124 from rowyio/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
shamsmosowi authored Feb 17, 2023
2 parents 8474668 + 36bd687 commit 9163a71
Show file tree
Hide file tree
Showing 41 changed files with 1,417 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,17 @@ function CodeEditor({ type, column, handleChange }: ICodeEditorProps) {
} else if (column.config?.defaultValue?.dynamicValueFn) {
dynamicValueFn = column.config?.defaultValue?.dynamicValueFn;
} else if (column.config?.defaultValue?.script) {
dynamicValueFn = `const dynamicValueFn : DefaultValue = async ({row,ref,db,storage,auth,logging})=>{
dynamicValueFn = `const dynamicValueFn: DefaultValue = async ({row,ref,db,storage,auth,logging})=>{
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("dynamicValueFn started")
${column.config?.defaultValue.script}
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
}`;
} else {
dynamicValueFn = `const dynamicValueFn : DefaultValue = async ({row,ref,db,storage,auth,logging})=>{
dynamicValueFn = `const dynamicValueFn: DefaultValue = async ({row,ref,db,storage,auth,logging})=>{
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("dynamicValueFn started")
// Example: generate random hex color
// const color = "#" + Math.floor(Math.random() * 16777215).toString(16);
Expand Down
12 changes: 11 additions & 1 deletion src/components/SteppedAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ export default function SteppedAccordion({
}
{...labelButtonProps}
>
<StepLabel error={error} {...labelProps}>
<StepLabel
error={error}
{...labelProps}
StepIconProps={{
sx: {
"&.Mui-active": {
transform: "rotate(0deg) !important",
},
},
}}
>
{title}
{content && <ExpandIcon sx={{ mr: -0.5 }} />}
</StepLabel>
Expand Down
32 changes: 1 addition & 31 deletions src/components/Table/Breadcrumbs/BreadcrumbsTableRoot.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useAtom } from "jotai";
import { useParams, Link as RouterLink } from "react-router-dom";
import { find, camelCase, uniq } from "lodash-es";
import { find, camelCase } from "lodash-es";

import {
Stack,
Expand All @@ -12,13 +12,9 @@ import {
} from "@mui/material";
import ReadOnlyIcon from "@mui/icons-material/EditOffOutlined";

import InfoTooltip from "@src/components/InfoTooltip";
import RenderedMarkdown from "@src/components/RenderedMarkdown";

import {
projectScope,
userRolesAtom,
tableDescriptionDismissedAtom,
tablesAtom,
} from "@src/atoms/projectScope";
import { ROUTES } from "@src/constants/routes";
Expand All @@ -31,10 +27,6 @@ export default function BreadcrumbsTableRoot(props: StackProps) {
const { id } = useParams();

const [userRoles] = useAtom(userRolesAtom, projectScope);
const [dismissed, setDismissed] = useAtom(
tableDescriptionDismissedAtom,
projectScope
);
const [tables] = useAtom(tablesAtom, projectScope);

const tableSettings = find(tables, ["id", id]);
Expand Down Expand Up @@ -83,28 +75,6 @@ export default function BreadcrumbsTableRoot(props: StackProps) {
<ReadOnlyIcon fontSize="small" sx={{ ml: 0.5 }} color="action" />
</Tooltip>
)}

{tableSettings.description && (
<InfoTooltip
description={
<div>
<RenderedMarkdown
children={tableSettings.description}
restrictionPreset="singleLine"
/>
</div>
}
buttonLabel="Table info"
tooltipProps={{
componentsProps: {
popper: { sx: { zIndex: "appBar" } },
tooltip: { sx: { maxWidth: "75vw" } },
} as any,
}}
defaultOpen={!dismissed.includes(tableSettings.id)}
onClose={() => setDismissed((d) => uniq([...d, tableSettings.id]))}
/>
)}
</Stack>
);
}
36 changes: 33 additions & 3 deletions src/components/TableModals/ExtensionsModal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export const triggerTypes: ExtensionTrigger[] = ["create", "update", "delete"];
const extensionBodyTemplate = {
task: `const extensionBody: TaskBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
// Import any NPM package needed
// const vision = require('@google-cloud/vision');
// Task Extension is very flexible, you can do anything.
// From updating other documents in your database, to making an api request to 3rd party service.
Expand Down Expand Up @@ -90,7 +94,8 @@ const extensionBodyTemplate = {
}`,
docSync: `const extensionBody: DocSyncBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
return ({
fieldsToSync: [], // a list of string of column names
row: row, // object of data to sync, usually the row itself
Expand All @@ -100,6 +105,7 @@ const extensionBodyTemplate = {
}`,
historySnapshot: `const extensionBody: HistorySnapshotBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
return ({
trackedFields: [], // a list of string of column names
Expand All @@ -109,6 +115,7 @@ const extensionBodyTemplate = {
}`,
algoliaIndex: `const extensionBody: AlgoliaIndexBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
return ({
fieldsToSync: [], // a list of string of column names
Expand All @@ -120,7 +127,8 @@ const extensionBodyTemplate = {
}`,
meiliIndex: `const extensionBody: MeiliIndexBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
return({
fieldsToSync: [], // a list of string of column names
row: row, // object of data to sync, usually the row itself
Expand All @@ -131,7 +139,8 @@ const extensionBodyTemplate = {
}`,
bigqueryIndex: `const extensionBody: BigqueryIndexBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
return ({
fieldsToSync: [], // a list of string of column names
row: row, // object of data to sync, usually the row itself
Expand All @@ -142,6 +151,10 @@ const extensionBodyTemplate = {
}`,
slackMessage: `const extensionBody: SlackMessageBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
// Import any NPM package needed
// const lodash = require('lodash');
return ({
channels: [], // a list of slack channel IDs in string
Expand All @@ -153,6 +166,10 @@ const extensionBodyTemplate = {
}`,
sendgridEmail: `const extensionBody: SendgridEmailBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
// Import any NPM package needed
// const lodash = require('lodash');
return ({
from: "Name<[email protected]>", // send from field
Expand All @@ -174,6 +191,10 @@ const extensionBodyTemplate = {
}`,
apiCall: `const extensionBody: ApiCallBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
// Import any NPM package needed
// const lodash = require('lodash');
return ({
body: "",
Expand All @@ -185,6 +206,10 @@ const extensionBodyTemplate = {
}`,
twilioMessage: `const extensionBody: TwilioMessageBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
// Import any NPM package needed
// const lodash = require('lodash');
// Setup twilio secret key: https://docs.rowy.io/extensions/twilio-message#secret-manager-setup
// Add any code here to customize your message or dynamically get the from/to numbers
Expand All @@ -197,6 +222,10 @@ const extensionBodyTemplate = {
}`,
pushNotification: `const extensionBody: PushNotificationBody = async({row, db, change, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("extensionBody started")
// Import any NPM package needed
// const lodash = require('lodash');
// You can use FCM token from the row or from the user document in the database
// const FCMtoken = row.FCMtoken
Expand Down Expand Up @@ -248,6 +277,7 @@ export function emptyExtensionObject(
trackedFields: [],
conditions: `const condition: Condition = async({row, change, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("condition started")
return true;
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
Expand Down
13 changes: 13 additions & 0 deletions src/components/TableModals/ImportExistingWizard/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,24 @@ export const REGEX_URL =
export const REGEX_HTML = /<\/?[a-z][\s\S]*>/;

const inferTypeFromValue = (value: any) => {
// by default the type of value is string, so trying to convert it to JSON/Object.
try {
value = JSON.parse(value);
} catch (e) {}
if (!value || typeof value === "function") return;

if (Array.isArray(value) && typeof value[0] === "string")
return FieldType.multiSelect;
if (typeof value === "boolean") return FieldType.checkbox;
if (isDate(value)) return FieldType.dateTime;
// trying to convert the value to date
if (+new Date(value)) {
// date and time are separated by a blank space, checking if time present.
if (value.split(" ").length > 1) {
return FieldType.dateTime;
}
return FieldType.date;
}

if (typeof value === "object") {
if ("hex" in value && "rgb" in value) return FieldType.color;
Expand Down Expand Up @@ -71,6 +83,7 @@ const inferTypeFromValue = (value: any) => {
export const suggestType = (data: { [key: string]: any }[], field: string) => {
const results: Record<string, number> = {};

// console.log(data)
data.forEach((row) => {
const result = inferTypeFromValue(row[field]);
if (!result) return;
Expand Down
7 changes: 6 additions & 1 deletion src/components/TableModals/WebhooksModal/Schemas/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export const webhookBasic = {
table: TableSettings
) => `const basicParser: Parser = async({req, db, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("basicParser started")
// Import any NPM package needed
// const lodash = require('lodash');
// Optionally return an object to be added as a new row to the table
// Example: add the webhook body as row
const {body} = req;
Expand All @@ -91,6 +95,7 @@ export const webhookBasic = {
table: TableSettings
) => `const condition: Condition = async({ref, req, db, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("condition started")
return true;
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
Expand Down
5 changes: 5 additions & 0 deletions src/components/TableModals/WebhooksModal/Schemas/sendgrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const webhookSendgrid = {
table: TableSettings
) => `const sendgridParser: Parser = async ({ req, db, ref, logging }) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("sendgridParser started")
// Import any NPM package needed
// const lodash = require('lodash');
const { body } = req
const eventHandler = async (sgEvent) => {
Expand All @@ -41,6 +45,7 @@ export const webhookSendgrid = {
table: TableSettings
) => `const condition: Condition = async({ref, req, db, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("condition started")
return true;
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
Expand Down
7 changes: 6 additions & 1 deletion src/components/TableModals/WebhooksModal/Schemas/stripe.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ export const webhookStripe = {
extraLibs: null,
template: (
table: TableSettings
) => `const sendgridParser: Parser = async ({ req, db, ref, logging }) => {
) => `const stripeParser: Parser = async ({ req, db, ref, logging }) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("stripeParser started")
// Import any NPM package needed
// const lodash = require('lodash');
const event = req.body
switch (event.type) {
Expand All @@ -39,6 +43,7 @@ export const webhookStripe = {
table: TableSettings
) => `const condition: Condition = async({ref, req, db, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("condition started")
return true;
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
Expand Down
5 changes: 5 additions & 0 deletions src/components/TableModals/WebhooksModal/Schemas/typeform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const webhookTypeform = {
table: TableSettings
) => `const typeformParser: Parser = async({req, db, ref, logging}) =>{
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("typeformParser started")
// Import any NPM package needed
// const lodash = require('lodash');
// This reduces the form submission into a single object of key value pairs
// Example: {name: "John", age: 20}
Expand Down Expand Up @@ -73,6 +77,7 @@ export const webhookTypeform = {
table: TableSettings
) => `const condition: Condition = async({ref, req, db, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("condition started")
return true;
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
Expand Down
5 changes: 5 additions & 0 deletions src/components/TableModals/WebhooksModal/Schemas/webform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const webhook = {
table: TableSettings
) => `const formParser: Parser = async({req, db, ref, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("formParser started")
// Import any NPM package needed
// const lodash = require('lodash');
// Optionally return an object to be added as a new row to the table
// Example: add the webhook body as row
Expand All @@ -41,6 +45,7 @@ export const webhook = {
table: TableSettings
) => `const condition: Condition = async({ref, req, db, logging}) => {
// WRITE YOUR CODE ONLY BELOW THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
logging.log("condition started")
return true;
// WRITE YOUR CODE ONLY ABOVE THIS LINE. DO NOT WRITE CODE/COMMENTS OUTSIDE THE FUNCTION BODY
Expand Down
Loading

0 comments on commit 9163a71

Please sign in to comment.