-
Notifications
You must be signed in to change notification settings - Fork 4
Google Drive #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gconsigli
wants to merge
19
commits into
main
Choose a base branch
from
GoogleDrive
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Google Drive #13
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f363d3a
Main
gconsigli fe41717
Merge branch 'main' into GoogleDrive
gconsigli e841ec6
Update src/background.ts
gconsigli a852bf6
Bug fixes
gconsigli e32b61e
Bug fixes
gconsigli 4ca6d69
client_id fix
gconsigli c9f97e8
Update src/background.ts
gconsigli 269278c
Update src/background.ts
gconsigli 0193bc2
Update src/connections/googleDrive/connection.tsx
gconsigli 55d5aca
Update src/background.ts
gconsigli 16d4440
Fixes
gconsigli 5b2c6e4
Removed client_id env (Plasmo limitation prevents injecting the clien…
gconsigli a2c743d
Merge branch 'main' into GoogleDrive
gconsigli f3df338
Fixes 2
gconsigli 8f08ef1
Merge branch 'GoogleDrive' of https://github.com/KellisLab/MantisExte…
gconsigli d9b17c9
Removed http import
gconsigli 1988b03
set extension ID
gconsigli c9d74be
fix
gconsigli eed6933
Update client_id
gconsigli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -39,4 +39,5 @@ keys.json | |
| .tsbuildinfo | ||
|
|
||
| # Windows Zone.Identifier files | ||
| *:Zone.Identifier | ||
| *:Zone.Identifier | ||
| package-lock.json | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| export default { | ||
| import { defineConfig } from "@plasmohq/config" | ||
|
|
||
| export default defineConfig({ | ||
| name: "Mantis connection", | ||
| version: "0.0.1", | ||
| manifest: { | ||
| permissions: [ | ||
| "storage", | ||
| "cookies", | ||
| "webRequest" | ||
| ] | ||
| permissions: ["storage", "cookies", "identity"], | ||
| } | ||
| } | ||
| }) |
This file contains hidden or 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 hidden or 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 hidden or 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,81 @@ | ||
| import type { MantisConnection, injectUIType, onMessageType, registerListenersType, setProgressType, establishLogSocketType } from "../types"; | ||
| import { GenerationProgress } from "../types"; | ||
|
|
||
| import driveIcon from "data-base64:../../../assets/drive.png"; | ||
| import { getSpacePortal, reqSpaceCreation} from "../../driver"; | ||
|
|
||
| const trigger = (url: string) => { | ||
| return url.includes("drive.google.com"); | ||
| } | ||
|
|
||
| const getDriveFiles = async () => { | ||
| try { | ||
| const response = await new Promise<{ | ||
| success: boolean; | ||
| token?: string; | ||
| driveFiles?: any[]; | ||
gconsigli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| error?: string; | ||
| }>((resolve, reject) => { | ||
| chrome.runtime.sendMessage({ action: "initiateOAuth" }, (response) => { | ||
| if (chrome.runtime.lastError) { | ||
| return reject(new Error("Runtime error: " + chrome.runtime.lastError.message)); | ||
| } | ||
| resolve(response); | ||
| }); | ||
| }); | ||
|
|
||
| if (response.success && response.driveFiles) { | ||
| console.log("Token:", response.token); | ||
| console.log("Drive files:", response.driveFiles); | ||
gconsigli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return response.driveFiles; | ||
| } else { | ||
| console.error("OAuth failed:", response.error); | ||
| } | ||
| } catch (err) { | ||
| console.error("Error during Drive file fetch:", err); | ||
| } | ||
gconsigli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| const createSpace = async (injectUI: injectUIType, setProgress: setProgressType, onMessage: onMessageType, registerListeners: registerListenersType, establishLogSocket: establishLogSocketType) => { | ||
| setProgress(GenerationProgress.GATHERING_DATA); | ||
| const fileMetadata = await getDriveFiles(); | ||
gconsigli marked this conversation as resolved.
Show resolved
Hide resolved
gconsigli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (!fileMetadata) { | ||
| console.error("Failed to retrieve file metadata from Google Drive."); | ||
| return; | ||
| } | ||
|
|
||
| setProgress(GenerationProgress.CREATING_SPACE); | ||
|
|
||
| const spaceData = await reqSpaceCreation(fileMetadata, { | ||
| "name": "semantic", | ||
gconsigli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, establishLogSocket); | ||
|
|
||
| setProgress(GenerationProgress.INJECTING_UI); | ||
|
|
||
| const spaceId = spaceData.space_id; | ||
| const createdWidget = await injectUI(spaceId, onMessage, registerListeners); | ||
|
|
||
| setProgress(GenerationProgress.COMPLETED); | ||
|
|
||
| return { spaceId, createdWidget }; | ||
| }; | ||
|
|
||
| const injectUI = async (space_id: string, onMessage: onMessageType, registerListeners: registerListenersType) => { | ||
|
|
||
| const iframeScalerParent = await getSpacePortal (space_id, onMessage, registerListeners); | ||
|
|
||
| document.body.prepend (iframeScalerParent); | ||
|
|
||
| return iframeScalerParent; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| export const GoogleDriveConnection: MantisConnection = { | ||
| name: "Google Drive", | ||
| description: "Builds spaces based on the content of an entire Google Drive", | ||
| icon: driveIcon, | ||
| trigger: trigger, | ||
| createSpace: createSpace, | ||
| injectUI: injectUI, | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.