mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
fix rowy run buildFunction endpoint expecting old pathname for tables
This commit is contained in:
@@ -26,7 +26,10 @@ import { useSnackLogContext } from "@src/contexts/SnackLogContext";
|
||||
import { FieldType } from "@src/constants/fields";
|
||||
import { runRoutes } from "@src/constants/runRoutes";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { getTableSchemaPath } from "@src/utils/table";
|
||||
import {
|
||||
getTableSchemaPath,
|
||||
getTableBuildFunctionPathname,
|
||||
} from "@src/utils/table";
|
||||
|
||||
export default function ColumnConfigModal({
|
||||
onClose,
|
||||
@@ -193,9 +196,10 @@ export default function ColumnConfigModal({
|
||||
body: {
|
||||
tablePath: tableSettings.collection,
|
||||
// pathname must match old URL format
|
||||
pathname: `/table/${encodeURIComponent(
|
||||
tableSettings.collection
|
||||
)}`,
|
||||
pathname: getTableBuildFunctionPathname(
|
||||
tableSettings.id,
|
||||
tableSettings.tableType
|
||||
),
|
||||
tableConfigPath: getTableSchemaPath(tableSettings),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -26,7 +26,10 @@ import { useSnackLogContext } from "@src/contexts/SnackLogContext";
|
||||
import { emptyExtensionObject, IExtension, ExtensionType } from "./utils";
|
||||
import { runRoutes } from "@src/constants/runRoutes";
|
||||
import { analytics, logEvent } from "@src/analytics";
|
||||
import { getTableSchemaPath } from "@src/utils/table";
|
||||
import {
|
||||
getTableSchemaPath,
|
||||
getTableBuildFunctionPathname,
|
||||
} from "@src/utils/table";
|
||||
|
||||
export default function ExtensionsModal({ onClose }: ITableModalProps) {
|
||||
const [currentUser] = useAtom(currentUserAtom, globalScope);
|
||||
@@ -91,7 +94,11 @@ export default function ExtensionsModal({ onClose }: ITableModalProps) {
|
||||
route: runRoutes.buildFunction,
|
||||
body: {
|
||||
tablePath: tableSettings.collection,
|
||||
pathname: `/table/${encodeURIComponent(tableSettings.collection)}`,
|
||||
// pathname must match old URL format
|
||||
pathname: getTableBuildFunctionPathname(
|
||||
tableSettings.id,
|
||||
tableSettings.tableType
|
||||
),
|
||||
tableConfigPath: getTableSchemaPath(tableSettings),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -34,7 +34,10 @@ import { runRoutes } from "@src/constants/runRoutes";
|
||||
import { CONFIG } from "@src/config/dbPaths";
|
||||
import { ROUTES } from "@src/constants/routes";
|
||||
import { useSnackLogContext } from "@src/contexts/SnackLogContext";
|
||||
import { getTableSchemaPath } from "@src/utils/table";
|
||||
import {
|
||||
getTableSchemaPath,
|
||||
getTableBuildFunctionPathname,
|
||||
} from "@src/utils/table";
|
||||
|
||||
const customComponents = {
|
||||
tableName: {
|
||||
@@ -128,11 +131,11 @@ export default function TableSettingsDialog() {
|
||||
route: runRoutes.buildFunction,
|
||||
body: {
|
||||
tablePath,
|
||||
pathname: `/${
|
||||
data.tableType === "collectionGroup"
|
||||
? "tableGroup"
|
||||
: "table"
|
||||
}/${data.id}`,
|
||||
// pathname must match old URL format
|
||||
pathname: getTableBuildFunctionPathname(
|
||||
data.id,
|
||||
data.tableType
|
||||
),
|
||||
tableConfigPath,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -133,3 +133,25 @@ export const getTableSchemaPath = (
|
||||
*/
|
||||
export const formatSubTableName = (id?: string) =>
|
||||
id ? id.replace(formatPathRegex, "/subTables/$1").replace(/\//g, "_") : "";
|
||||
|
||||
/**
|
||||
* Gets the pathname of the table or sub-table
|
||||
* for Rowy Run `buildFunction` endpoint.
|
||||
* Rowy Run expects the previous URL format for sub-tables.
|
||||
* @param id - Table ID (or sub-table ID from tableIdAtom)
|
||||
* @param tableType - primaryCollection (default) or collectionGroup
|
||||
* @returns - pathname
|
||||
*/
|
||||
export const getTableBuildFunctionPathname = (
|
||||
id: string,
|
||||
tableType: "primaryCollection" | "collectionGroup" = "primaryCollection"
|
||||
) => {
|
||||
const root =
|
||||
"/" + (tableType === "collectionGroup" ? "tableGroup" : "table") + "/";
|
||||
|
||||
if (!id.includes("/")) return root + id;
|
||||
|
||||
const split = id.split("/");
|
||||
const rootTableId = split.shift();
|
||||
return root + rootTableId + encodeURIComponent("/" + split.join("/"));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user