remove isGroupCollection

This commit is contained in:
shamsmosowi
2021-09-17 11:48:15 +10:00
parent 9a616924c5
commit 18c57cc708
5 changed files with 15 additions and 21 deletions

View File

@@ -49,9 +49,10 @@ export default function NavDrawerItem({
{tables
.filter((x) => x)
.map((table) => {
const route = table.isCollectionGroup
? `${routes.tableGroup}/${table.id}`
: `${routes.table}/${table.id.replace(/\//g, "~2F")}`;
const route =
table.tableType === "collectionGroup"
? `${routes.tableGroup}/${table.id}`
: `${routes.table}/${table.id.replace(/\//g, "~2F")}`;
return (
<li key={table.id}>

View File

@@ -122,12 +122,9 @@ export default function WebhooksDialog({ open, handleClose }) {
label={"Enable webhooks for this table"}
labelPlacement="end"
checked={state.enabled}
onChange={
() => {
handleChange("enabled")(!state.enabled);
}
// handleChange("isCollectionGroup", !formState.isCollectionGroup)
}
onChange={() => {
handleChange("enabled")(!state.enabled);
}}
// classes={{ root: classes.formControlLabel, label: classes.label }}
/>
<InputLabel htmlFor="webhook-type">Webhook Type</InputLabel>

View File

@@ -32,7 +32,6 @@ const FORM_EMPTY_STATE = {
collection: "",
section: "",
description: "",
isCollectionGroup: false,
roles: ["ADMIN"],
};
@@ -92,7 +91,6 @@ export default function TableSettingsDialog({
const handleSubmit = async (values) => {
const data: any = {
...values,
isCollectionGroup: values.tableType === "collectionGroup",
};
if (values.schemaSource)
@@ -132,13 +130,15 @@ export default function TableSettingsDialog({
const tablesDocRef = db.doc(SETTINGS);
const tableData = (await tablesDocRef.get()).data();
const updatedTables = tableData?.tables.filter(
(table) =>
table.id !== data?.id ||
table.isCollectionGroup !== data?.isCollectionGroup
(table) => table.id !== data?.id || table.tableType !== data?.tableType
);
await tablesDocRef.update({ tables: updatedTables });
await db
.collection(data?.isCollectionGroup ? TABLE_SCHEMAS : TABLE_GROUP_SCHEMAS)
.collection(
data?.tableType === "primaryCollection"
? TABLE_SCHEMAS
: TABLE_GROUP_SCHEMAS
)
.doc(data?.id)
.delete();
window.location.reload();
@@ -160,9 +160,6 @@ export default function TableSettingsDialog({
tables?.map((table) => ({ label: table.name, value: table.id }))
)}
values={{
tableType: data?.isCollectionGroup
? "collectionGroup"
: "primaryCollection",
...data,
}}
onSubmit={handleSubmit}

View File

@@ -20,8 +20,7 @@ export type Table = {
roles: string[];
description: string;
section: string;
isCollectionGroup: boolean;
tableType: string;
tableType: "primaryCollection" | "collectionGroup";
};
interface IProjectContext {

View File

@@ -151,7 +151,7 @@ export default function HomePage() {
const getLink = (table: Table) =>
`${
table.isCollectionGroup ? routes.tableGroup : routes.table
table.tableType === "primaryCollection" ? routes.table : routes.tableGroup
}/${table.id.replace(/\//g, "~2F")}`;
const handleFavorite = (id: string) => (e: ChangeEvent<HTMLInputElement>) => {