diff --git a/src/components/Table/ColumnMenu/FieldSettings/index.tsx b/src/components/Table/ColumnMenu/FieldSettings/index.tsx index b699facc..f7a5a432 100644 --- a/src/components/Table/ColumnMenu/FieldSettings/index.tsx +++ b/src/components/Table/ColumnMenu/FieldSettings/index.tsx @@ -130,6 +130,7 @@ export default function FieldSettings(props: IMenuModalProps) { body: { tablePath: tableState?.tablePath, pathname: window.location.pathname, + tableConfigPath: tableState?.config.tableConfig.path, }, params: [], }); diff --git a/src/components/Table/TableHeader/Extensions/index.tsx b/src/components/Table/TableHeader/Extensions/index.tsx index a6b5eb5f..97dccfb6 100644 --- a/src/components/Table/TableHeader/Extensions/index.tsx +++ b/src/components/Table/TableHeader/Extensions/index.tsx @@ -92,6 +92,7 @@ export default function ExtensionsEditor() { body: { tablePath: tableState?.tablePath, pathname: window.location.pathname, + tableConfigPath: tableState?.config.tableConfig.path, }, }); analytics.logEvent("deployed_extensions"); diff --git a/src/components/Table/TableHeader/TableLogs.tsx b/src/components/Table/TableHeader/TableLogs.tsx index e570049c..660c45fb 100644 --- a/src/components/Table/TableHeader/TableLogs.tsx +++ b/src/components/Table/TableHeader/TableLogs.tsx @@ -3,10 +3,8 @@ import useRouter from "hooks/useRouter"; import useCollection from "hooks/useCollection"; import { useProjectContext } from "contexts/ProjectContext"; import useStateRef from "react-usestateref"; -import { db } from "../../../firebase"; import { useSnackLogContext } from "contexts/SnackLogContext"; import { isCollectionGroup } from "utils/fns"; - import _throttle from "lodash/throttle"; import { format } from "date-fns"; import moment from "moment"; @@ -390,42 +388,25 @@ function SnackLog({ log, onClose, onOpenPanel }) { export default function TableLogs() { const router = useRouter(); const { tableState } = useProjectContext(); - const classes = useStyles(); const [panalOpen, setPanelOpen] = useState(false); - const [buildURLConfigured, setBuildURLConfigured] = useState(true); const [tabIndex, setTabIndex] = React.useState(0); const snackLogContext = useSnackLogContext(); + const functionConfigPath = tableState?.config.functionConfigPath; + console.log(functionConfigPath); + const [collectionState, collectionDispatch] = useCollection({}); useEffect(() => { - checkBuildURL(); - }, []); - - const checkBuildURL = async () => { - const settingsDoc = await db.doc(SETTINGS).get(); - const buildUrl = settingsDoc.get("buildUrl"); - if (!buildUrl) { - setBuildURLConfigured(false); + if (functionConfigPath) { + const path = `${functionConfigPath}/buildLogs`; + console.log(path); + collectionDispatch({ + path, + orderBy: [{ key: "startTimeStamp", direction: "desc" }], + limit: 30, + }); } - }; - - const tableCollection = decodeURIComponent(router.match.params.id); - const buildStreamID = - (isCollectionGroup() ? TABLE_GROUP_SCHEMAS : TABLE_SCHEMAS) + - "/" + - tableCollection - .split("/") - .filter(function (_, i) { - // replace IDs with subTables that appears at even indexes - return i % 2 === 0; - }) - .join("/subTables/"); - - const [collectionState] = useCollection({ - path: `${buildStreamID}/buildLogs`, - orderBy: [{ key: "startTimeStamp", direction: "desc" }], - limit: 30, - }); + }, [functionConfigPath]); const latestLog = collectionState?.documents?.[0]; const latestStatus = latestLog?.status; const latestActiveLog = @@ -491,7 +472,7 @@ export default function TableLogs() { } children={ <> - {!latestStatus && buildURLConfigured && ( + {!latestStatus && ( )} - {!latestStatus && !buildURLConfigured && ( - - - Function builder is not currently setup.{" "} - - - - } - /> - )} {latestStatus && (
{ }); useEffect(() => { - const { doc, columns, rowHeight } = tableConfigState; + const { doc, columns, rowHeight, functionConfigPath } = tableConfigState; // TODO: REMOVE THIS // Copy columns, rowHeight to tableConfigState if (doc && columns !== doc.columns) { @@ -36,6 +36,9 @@ const useTableConfig = (tablePath?: string) => { if (doc && rowHeight !== doc.rowHeight) { documentDispatch({ rowHeight: doc.rowHeight }); } + if (doc && functionConfigPath !== doc.functionConfigPath) { + documentDispatch({ functionConfigPath: doc.functionConfigPath }); + } }, [tableConfigState.doc]); /** used for specifying the table in use * @param table firestore collection path