Skip to content

Commit

Permalink
Merge pull request #1179 from rowyio/rc
Browse files Browse the repository at this point in the history
Rc
  • Loading branch information
shamsmosowi authored Mar 28, 2023
2 parents 0795758 + 9382d8c commit 4a077b5
Show file tree
Hide file tree
Showing 124 changed files with 4,855 additions and 1,273 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ to start.
## Working on existing issues



Before you get started working on an [issue](https://github.com/rowyio/rowy/issues), please make sure to share that you are working on it by commenting on the issue and posting a message on #contributions channel in Rowy's [Discord](https://discord.com/invite/fjBugmvzZP). The maintainers will then assign the issue to you after making sure any relevant information or context in addition is provided before you can start on the task.

Once you are assigned a task, please provide periodic updates or share any questions or roadblocks on either discord or the Github issue, so that the commmunity or the project maintainers can provide you any feedback or guidance as needed. If you are inactive for more than 1-2 week on a issue that was assigned to you, then we will assume you have stopped working on it and we will unassign it from you - so that we can give a chance to others in the community to work on it.
Expand Down
4 changes: 2 additions & 2 deletions src/atoms/projectScope/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const tablesAtom = atom<TableSettings[]>((get) => {
return sortBy(tables, "name")
.filter((table) =>
userRoles.includes("ADMIN") || Array.isArray(table.roles)
? table.roles.some((role) => userRoles.includes(role))
? table.roles?.some((role) => userRoles.includes(role))
: false
)
.map((table) => ({
Expand Down Expand Up @@ -105,7 +105,7 @@ export const deleteTableAtom = atom<

/** Stores a function to get a table’s schema doc (without listener) */
export const getTableSchemaAtom = atom<
((id: string) => Promise<TableSchema>) | undefined
((id: string, withSubtables?: boolean) => Promise<TableSchema>) | undefined
>(undefined);

/** Roles used in the project based on table settings */
Expand Down
2 changes: 0 additions & 2 deletions src/atoms/projectScope/rowyRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const rowyRunAtom = atom((get) => {
handleNotSetUp,
}: IRowyRunRequestProps): Promise<Response | any | false> => {
if (!currentUser) {
console.log("Rowy Run: Not signed in", route.path);
if (handleNotSetUp) handleNotSetUp();
return false;
}
Expand All @@ -85,7 +84,6 @@ export const rowyRunAtom = atom((get) => {
? rowyRunServices?.[service]
: rowyRunUrl;
if (!serviceUrl) {
console.log("Rowy Run: Not set up", route.path);
if (handleNotSetUp) handleNotSetUp();
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/projectScope/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const tableSettingsDialogSchemaAtom = atom(async (get) => {
const tableId = get(tableSettingsDialogIdAtom);
const getTableSchema = get(getTableSchemaAtom);
if (!tableId || !getTableSchema) return {} as TableSchema;
return getTableSchema(tableId);
return getTableSchema(tableId, true);
});

/** Open the Get Started checklist from anywhere */
Expand Down
10 changes: 6 additions & 4 deletions src/atoms/tableScope/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export const tableRowsDbAtom = atom<TableRow[]>([]);

/** Combine tableRowsLocal and tableRowsDb */
export const tableRowsAtom = atom<TableRow[]>((get) => {
const rowsDb = [...get(tableRowsDbAtom)];
const rowsDb = get(tableRowsDbAtom);
const rowsLocal = get(tableRowsLocalAtom);

// Optimization: create Map of rowsDb by path to index for faster lookup
Expand All @@ -178,15 +178,17 @@ export const tableRowsAtom = atom<TableRow[]>((get) => {
if (rowsDbMap.has(row._rowy_ref.path)) {
const index = rowsDbMap.get(row._rowy_ref.path)!;
const merged = updateRowData({ ...rowsDb[index] }, row);
rowsDb.splice(index, 1);
rowsDbMap.delete(row._rowy_ref.path);
return merged;
}

return row;
});

// Merge the two arrays
return [...rowsLocalToMerge, ...rowsDb];
return [
...rowsLocalToMerge,
...rowsDb.filter((row) => rowsDbMap.has(row._rowy_ref.path)),
];
});

/** Store next page state for infinite scroll */
Expand Down
16 changes: 14 additions & 2 deletions src/atoms/tableScope/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export type ImportAirtableData = { records: Record<string, any>[] };

/** Store import CSV popover and wizard state */
export const importCsvAtom = atom<{
importType: "csv" | "tsv";
importType: "csv" | "tsv" | "json";
csvData: ImportCsvData | null;
}>({ importType: "csv", csvData: null });

Expand Down Expand Up @@ -142,14 +142,26 @@ export const selectedCellAtom = atom<SelectedCell | null>(null);
export const contextMenuTargetAtom = atom<HTMLElement | null>(null);

export type CloudLogFilters = {
type: "webhook" | "functions" | "audit" | "build";
type: "extension" | "webhook" | "column" | "audit" | "build" | "functions";
timeRange:
| { type: "seconds" | "minutes" | "hours" | "days"; value: number }
| { type: "range"; start: Date; end: Date };
severity?: Array<keyof typeof SEVERITY_LEVELS>;
webhook?: string[];
extension?: string[];
column?: string[];
auditRowId?: string;
buildLogExpanded?: number;
functionType?: (
| "connector"
| "derivative-script"
| "action"
| "derivative-function"
| "extension"
| "defaultValue"
| "hooks"
)[];
loggingSource?: ("backend-scripts" | "backend-function" | "hooks")[];
};
/** Store cloud log modal filters in URL */
export const cloudLogFiltersAtom = atomWithHash<CloudLogFilters>(
Expand Down
38 changes: 37 additions & 1 deletion src/components/CodeEditor/CodeEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from "react";
import Editor, { EditorProps } from "@monaco-editor/react";
import Editor, { EditorProps, Monaco } from "@monaco-editor/react";
import type { editor } from "monaco-editor/esm/vs/editor/editor.api";

import { useTheme, Box, BoxProps, AppBar, Toolbar } from "@mui/material";
Expand Down Expand Up @@ -72,6 +72,36 @@ export default function CodeEditor({
onValidate?.(markers);
};

const validate = (monaco: Monaco, model: editor.ITextModel) => {
const markers = [];
for (let i = 1; i < model.getLineCount() + 1; i++) {
const range = {
startLineNumber: i,
startColumn: 1,
endLineNumber: i,
endColumn: model.getLineLength(i) + 1,
};
const line = model.getValueInRange(range);
for (const keyword of ["console.log", "console.warn", "console.error"]) {
const consoleLogIndex = line.indexOf(keyword);
if (consoleLogIndex >= 0) {
markers.push({
message: `Replace with ${keyword.replace(
"console",
"logging"
)}: Rowy Cloud Logging provides a better experience to view logs. Simply replace 'console' with 'logging'. \n\nhttps://docs.rowy.io/cloud-logs`,
severity: monaco.MarkerSeverity.Warning,
startLineNumber: range.startLineNumber,
endLineNumber: range.endLineNumber,
startColumn: consoleLogIndex + 1,
endColumn: consoleLogIndex + keyword.length + 1,
});
}
}
}
monaco.editor.setModelMarkers(model, "owner", markers);
};

return (
<TrapFocus open={fullScreen}>
<Box
Expand All @@ -94,6 +124,12 @@ export default function CodeEditor({
beforeMount={(monaco) => {
monaco.editor.defineTheme("github-light", githubLightTheme as any);
monaco.editor.defineTheme("github-dark", githubDarkTheme as any);
monaco.editor.onDidCreateModel((model) => {
validate(monaco, model);
model.onDidChangeContent(() => {
validate(monaco, model);
});
});
}}
onMount={(editor) => {
if (onFocus) editor.onDidFocusEditorWidget(onFocus);
Expand Down
96 changes: 56 additions & 40 deletions src/components/CodeEditor/CodeEditorHelper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { projectScope, projectIdAtom } from "@src/atoms/projectScope";

export interface ICodeEditorHelperProps {
docLink: string;
disableDefaultVariables?: boolean;
disableSecretManagerLink?: boolean;
disableCloudManagerLink?: boolean;
additionalVariables?: {
key: string;
description: string;
Expand All @@ -17,28 +20,37 @@ export interface ICodeEditorHelperProps {

export default function CodeEditorHelper({
docLink,
disableDefaultVariables,
disableSecretManagerLink,
disableCloudManagerLink,
additionalVariables,
}: ICodeEditorHelperProps) {
const [projectId] = useAtom(projectIdAtom, projectScope);

const availableVariables = [
{
key: "db",
description: `db object provides access to firestore database instance of this project. giving you access to any collection or document in this firestore instance`,
},
{
key: "auth",
description: `auth provides access to a firebase auth instance, can be used to manage auth users or generate tokens.`,
},
{
key: "storage",
description: `firebase Storage can be accessed through this, storage.bucket() returns default storage bucket of the firebase project.`,
},
{
key: "rowy",
description: `rowy provides a set of functions that are commonly used, such as easy file uploads & access to GCP Secret Manager`,
},
];
const availableVariables = disableDefaultVariables
? []
: [
{
key: "db",
description: `db object provides access to firestore database instance of this project. giving you access to any collection or document in this firestore instance`,
},
{
key: "auth",
description: `auth provides access to a firebase auth instance, can be used to manage auth users or generate tokens.`,
},
{
key: "storage",
description: `firebase Storage can be accessed through this, storage.bucket() returns default storage bucket of the firebase project.`,
},
{
key: "rowy",
description: `rowy provides a set of functions that are commonly used, such as easy file uploads & access to GCP Secret Manager`,
},
{
key: "logging",
description: `logging.log is encouraged to replace console.log`,
},
];

return (
<Stack
Expand Down Expand Up @@ -73,29 +85,33 @@ export default function CodeEditorHelper({
spacing={1}
style={{ marginTop: -4 }}
>
<Tooltip title="Secret Manager&nbsp;↗">
<IconButton
size="small"
color="primary"
target="_blank"
rel="noopener noreferrer"
href={`https://console.cloud.google.com/security/secret-manager?project=${projectId}`}
>
<SecretsIcon fontSize="small" />
</IconButton>
</Tooltip>
{!disableSecretManagerLink && (
<Tooltip title="Secret Manager&nbsp;↗">
<IconButton
size="small"
color="primary"
target="_blank"
rel="noopener noreferrer"
href={`https://console.cloud.google.com/security/secret-manager?project=${projectId}`}
>
<SecretsIcon fontSize="small" />
</IconButton>
</Tooltip>
)}

<Tooltip title="Configure Cloud Function&nbsp;↗">
<IconButton
size="small"
color="primary"
target="_blank"
rel="noopener noreferrer"
href={`https://console.cloud.google.com/functions/list?project=${projectId}`}
>
<FunctionsIcon fontSize="small" />
</IconButton>
</Tooltip>
{!disableCloudManagerLink && (
<Tooltip title="Configure Cloud Function&nbsp;↗">
<IconButton
size="small"
color="primary"
target="_blank"
rel="noopener noreferrer"
href={`https://console.cloud.google.com/functions/list?project=${projectId}`}
>
<FunctionsIcon fontSize="small" />
</IconButton>
</Tooltip>
)}

<Tooltip title="Examples & documentation&nbsp;↗">
<IconButton
Expand Down
1 change: 1 addition & 0 deletions src/components/CodeEditor/extensions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type ExtensionContext = {
extensionBody: any;
};
RULES_UTILS: any;
logging: RowyLogging;
};

// extension body definition
Expand Down
5 changes: 5 additions & 0 deletions src/components/CodeEditor/rowy.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type uploadOptions = {
folderPath?: string;
fileName?: string;
};
type RowyLogging = {
log: (...payload: any[]) => void;
warn: (...payload: any[]) => void;
error: (...payload: any[]) => void;
};
interface Rowy {
metadata: {
/**
Expand Down
Loading

1 comment on commit 4a077b5

@vercel
Copy link

@vercel vercel bot commented on 4a077b5 Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

rowy-os – ./

rowy-os-rowy.vercel.app
rowy-os-git-main-rowy.vercel.app
rowy-os.vercel.app

Please sign in to comment.