diff --git a/firestore.indexes.json b/firestore.indexes.json
index 94fccba4..93e19249 100644
--- a/firestore.indexes.json
+++ b/firestore.indexes.json
@@ -1,19 +1,5 @@
{
"indexes": [
- {
- "collectionGroup": "documents",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "dependencies",
- "arrayConfig": "CONTAINS"
- },
- {
- "fieldPath": "rendered",
- "order": "ASCENDING"
- }
- ]
- },
{
"collectionGroup": "documents",
"queryScope": "COLLECTION",
@@ -23,11 +9,7 @@
"order": "ASCENDING"
},
{
- "fieldPath": "status",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "published",
+ "fieldPath": "createdAt",
"order": "DESCENDING"
}
]
@@ -41,21 +23,7 @@
"order": "ASCENDING"
},
{
- "fieldPath": "title",
- "order": "ASCENDING"
- }
- ]
- },
- {
- "collectionGroup": "documents",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "documentType",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "title",
+ "fieldPath": "updatedAt",
"order": "DESCENDING"
}
]
@@ -69,21 +37,7 @@
"order": "ASCENDING"
},
{
- "fieldPath": "updated",
- "order": "ASCENDING"
- }
- ]
- },
- {
- "collectionGroup": "documents",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "documentType",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "updated",
+ "fieldPath": "publishedAt",
"order": "DESCENDING"
}
]
@@ -101,166 +55,7 @@
"order": "ASCENDING"
}
]
- },
- {
- "collectionGroup": "documents",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "status",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "title",
- "order": "ASCENDING"
- }
- ]
- },
- {
- "collectionGroup": "documents",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "status",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "title",
- "order": "DESCENDING"
- }
- ]
- },
- {
- "collectionGroup": "documents",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "status",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "updated",
- "order": "ASCENDING"
- }
- ]
- },
- {
- "collectionGroup": "documents",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "status",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "updated",
- "order": "DESCENDING"
- }
- ]
- },
- {
- "collectionGroup": "files",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "fileType",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "updated",
- "order": "DESCENDING"
- }
- ]
- },
- {
- "collectionGroup": "notifications",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "isRead",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "created",
- "order": "DESCENDING"
- }
- ]
- },
- {
- "collectionGroup": "notifications",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "isRead",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "updated",
- "order": "DESCENDING"
- }
- ]
- },
- {
- "collectionGroup": "themes",
- "queryScope": "COLLECTION",
- "fields": [
- {
- "fieldPath": "fileType",
- "order": "ASCENDING"
- },
- {
- "fieldPath": "updated",
- "order": "DESCENDING"
- }
- ]
}
],
- "fieldOverrides": [
- {
- "collectionGroup": "user",
- "fieldPath": "uid",
- "ttl": false,
- "indexes": [
- {
- "order": "ASCENDING",
- "queryScope": "COLLECTION"
- },
- {
- "order": "DESCENDING",
- "queryScope": "COLLECTION"
- },
- {
- "arrayConfig": "CONTAINS",
- "queryScope": "COLLECTION"
- },
- {
- "order": "ASCENDING",
- "queryScope": "COLLECTION_GROUP"
- }
- ]
- },
- {
- "collectionGroup": "user-invites",
- "fieldPath": "email",
- "ttl": false,
- "indexes": [
- {
- "order": "ASCENDING",
- "queryScope": "COLLECTION"
- },
- {
- "order": "DESCENDING",
- "queryScope": "COLLECTION"
- },
- {
- "arrayConfig": "CONTAINS",
- "queryScope": "COLLECTION"
- },
- {
- "order": "ASCENDING",
- "queryScope": "COLLECTION_GROUP"
- }
- ]
- }
- ]
+ "fieldOverrides": []
}
diff --git a/firestore.rules b/firestore.rules
index 5048beaf..3417d472 100644
--- a/firestore.rules
+++ b/firestore.rules
@@ -1,14 +1,24 @@
service cloud.firestore {
match /databases/{database}/documents {
+ match /tanam/{siteId} {
+ allow read: if true;
+ match /documents/{documentId} {
+ allow read: if true;
+ }
+ }
match /tanam-types/{typeId} {
- allow read: if hasAnyRole();
- allow write: if isAtLeastAdmin();
+ allow read: if true;
+ allow write: if true;
+ match /fields/{fieldId} {
+ allow read: if true;
+ allow write: if true;
+ }
}
match /tanam-documents/{documentId} {
- allow read: if hasAnyRole();
- allow write: if isPublisher();
+ allow read: if true;
+ allow write: if true;
match /revisions/{revisionId} {
allow read: if hasAnyRole();
@@ -16,12 +26,40 @@ service cloud.firestore {
}
}
+ match /files/{fileId} {
+ allow read: if hasAnyRole();
+ allow write: if isPublisher();
+ }
+
+ match /notifications/{notificationId} {
+ allow read: if isAtLeastAdmin();
+ allow write: if isAtLeastAdmin();
+ }
+
+ match /themes/{document=**} {
+ allow read: if hasAnyRole();
+ allow write: if isAtLeastAdmin();
+ }
+
+ match /users/{document=**} {
+ allow read, write: if isAtLeastAdmin();
+ }
+
+ match /user-invites/{document=**} {
+ allow read, write: if isSuperAdmin();
+ }
+
+ match /users/{userId} {
+ allow read: if isSignedInAs(userId);
+ allow write: if isSignedInAs(userId);
+ }
+
function hasUserRole(role) {
- return isSignedIn() && role == request.auth.token.tanamRole;
+ return isSignedIn() && role in request.auth.token.tanam[siteId];
}
function hasAnyRole() {
- return isSignedIn() && request.auth.token.tanamRole != null;
+ return isSignedIn() && request.auth.token.tanam[siteId].size() > 0;
}
function isSuperAdmin() {
diff --git a/hosting/src/app/(protected)/[site]/dashboard/page.tsx b/hosting/src/app/(protected)/[site]/dashboard/page.tsx
new file mode 100644
index 00000000..82be3f91
--- /dev/null
+++ b/hosting/src/app/(protected)/[site]/dashboard/page.tsx
@@ -0,0 +1,47 @@
+"use client";
+import Notification from "@/components/common/Notification";
+import Loader from "@/components/common/Loader";
+import ContentCard from "@/components/Containers/ContentCard";
+import {Table} from "@/components/Table";
+import {useTanamDocumentTypes} from "@/hooks/useTanamDocumentTypes";
+import {useParams} from "next/navigation";
+import {Suspense} from "react";
+
+export default function DashboardPage() {
+ const {site} = useParams<{site: string}>() ?? {
+ site: null,
+ };
+ const {data: documentTypes, totalRecords: typeTotalRecords, error: typeError} = useTanamDocumentTypes();
+
+ if (typeError) {
+ return (
+ <>
+