-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automatically share gsheets with editors (#291)
- Loading branch information
Showing
7 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@blinkk/root-cms': minor | ||
--- | ||
|
||
feat: automatically share gsheets with editors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {doc, getDoc} from 'firebase/firestore'; | ||
|
||
/** | ||
* Returns a list of users that can edit, e.g. users with role EDITOR or ADMIN. | ||
*/ | ||
export async function getAllEditors(): Promise<string[]> { | ||
const db = window.firebase.db; | ||
const projectId = window.__ROOT_CTX.rootConfig.projectId || 'default'; | ||
const docRef = doc(db, 'Projects', projectId); | ||
const snapshot = await getDoc(docRef); | ||
if (!snapshot.exists) { | ||
return []; | ||
} | ||
const data: any = snapshot.data() || {}; | ||
const roles: Record<string, string> = data.roles || {}; | ||
const editors: string[] = []; | ||
Object.entries(roles).forEach(([email, role]) => { | ||
if (role === 'ADMIN' || role === 'EDITOR') { | ||
editors.push(email); | ||
} | ||
}); | ||
return editors; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.