-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
feat: replace iframe with chrome sidepanel #5197
Merged
FelixMalfait
merged 16 commits into
twentyhq:main
from
AdityaPimpalkar:chrome-side-panel
May 21, 2024
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c231fcf
add id to parameter graphql mutations
AdityaPimpalkar 40d33d9
add sidepanel
AdityaPimpalkar 2ed2228
navigate url for sidepanel
AdityaPimpalkar ed1cf3a
fix signup route
AdityaPimpalkar 7abc210
change button gradient
AdityaPimpalkar 1387b05
add inaccessible page to sidepanel
AdityaPimpalkar 5f4b598
change button text content
AdityaPimpalkar d62bbb5
bug fix
AdityaPimpalkar d2b8231
Merge branch 'main' into chrome-side-panel
lucasbordeau 167a99d
rename options.html to sidepanel.html
AdityaPimpalkar 2c66ec1
change sidepanel url on default button click
AdityaPimpalkar 8cddc88
Merge remote-tracking branch 'refs/remotes/origin/chrome-side-panel' …
AdityaPimpalkar 31fb6bb
Merge branch 'main' into chrome-side-panel
AdityaPimpalkar fec4c55
change sidepanel url if top site navigation changes
AdityaPimpalkar 7ac804c
add ExchangeAuthorizationCode to token middleware
AdityaPimpalkar c083420
Merge branch 'main' into chrome-side-panel
AdityaPimpalkar 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 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,22 @@ | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/icons/android/android-launchericon-48-48.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Twenty</title> | ||
<style> | ||
/* Reset margin and padding */ | ||
html, body { | ||
margin: 0; | ||
padding: 0; | ||
height: 100%; /* Ensure body takes full viewport height */ | ||
overflow: hidden; /* Prevents scrollbars from appearing */ | ||
} | ||
</style> | ||
|
||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/options/index.tsx"></script> | ||
</body> | ||
</html> |
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
5 changes: 0 additions & 5 deletions
5
packages/twenty-chrome-extension/src/background/utils/openOptionsPage.ts
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { createDefaultButton } from '~/contentScript/createButton'; | ||
import changeSidePanelUrl from '~/contentScript/utils/changeSidepanelUrl'; | ||
import extractFirstAndLastName from '~/contentScript/utils/extractFirstAndLastName'; | ||
import { createPerson, fetchPerson } from '~/db/person.db'; | ||
import { PersonInput } from '~/db/types/person.types'; | ||
|
@@ -82,44 +83,58 @@ export const addPerson = async () => { | |
} | ||
|
||
personData.linkedinLink = { url: activeTabUrl, label: activeTabUrl }; | ||
const person = await createPerson(personData); | ||
return person; | ||
const personId = await createPerson(personData); | ||
|
||
if (isDefined(personId)) { | ||
await changeSidePanelUrl( | ||
`${import.meta.env.VITE_FRONT_BASE_URL}/object/person/${personId}`, | ||
); | ||
} | ||
|
||
return personId; | ||
}; | ||
|
||
export const insertButtonForPerson = async () => { | ||
const personButtonDiv = createDefaultButton('twenty-person-btn', async () => { | ||
if (isDefined(personButtonDiv)) { | ||
const personBtnSpan = personButtonDiv.getElementsByTagName('span')[0]; | ||
personBtnSpan.textContent = 'Saving...'; | ||
const person = await addPerson(); | ||
if (isDefined(person)) { | ||
personBtnSpan.textContent = 'Saved'; | ||
Object.assign(personButtonDiv.style, { pointerEvents: 'none' }); | ||
} else { | ||
personBtnSpan.textContent = 'Try again'; | ||
} | ||
} | ||
}); | ||
const personButtonDiv = createDefaultButton('twenty-person-btn'); | ||
|
||
if (isDefined(personButtonDiv)) { | ||
const parentDiv: HTMLDivElement | null = document.querySelector( | ||
'.pv-top-card-v2-ctas', | ||
const addedProfileDiv: HTMLDivElement | null = document.querySelector( | ||
'.pv-top-card-v2-ctas__custom', | ||
); | ||
|
||
if (isDefined(parentDiv)) { | ||
if (isDefined(addedProfileDiv)) { | ||
Object.assign(personButtonDiv.style, { | ||
marginRight: '.8rem', | ||
}); | ||
parentDiv.prepend(personButtonDiv); | ||
addedProfileDiv.prepend(personButtonDiv); | ||
} | ||
|
||
const personBtnSpan = personButtonDiv.getElementsByTagName('span')[0]; | ||
const personButtonSpan = personButtonDiv.getElementsByTagName('span')[0]; | ||
const person = await checkIfPersonExists(); | ||
|
||
const openPersonOnSidePanel = (personId: string) => { | ||
personButtonSpan.textContent = 'View in Twenty'; | ||
personButtonDiv.onClickHandler(async () => { | ||
await changeSidePanelUrl( | ||
`${import.meta.env.VITE_FRONT_BASE_URL}/object/person/${personId}`, | ||
); | ||
chrome.runtime.sendMessage({ action: 'openSidepanel' }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should change side panel url if already open ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct! I fixed it :) |
||
}); | ||
}; | ||
|
||
if (isDefined(person)) { | ||
personBtnSpan.textContent = 'Saved'; | ||
Object.assign(personButtonDiv.style, { pointerEvents: 'none' }); | ||
await changeSidePanelUrl( | ||
`${import.meta.env.VITE_FRONT_BASE_URL}/object/person/${person.id}`, | ||
); | ||
if (isDefined(person.id)) openPersonOnSidePanel(person.id); | ||
} else { | ||
personBtnSpan.textContent = 'Add to Twenty'; | ||
personButtonSpan.textContent = 'Add to Twenty'; | ||
personButtonDiv.onClickHandler(async () => { | ||
personButtonSpan.textContent = 'Saving...'; | ||
const personId = await addPerson(); | ||
if (isDefined(personId)) openPersonOnSidePanel(personId); | ||
else personButtonSpan.textContent = 'Try again'; | ||
}); | ||
} | ||
} | ||
}; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting this for now, will replace it with a call to a dedicated page for chrome extension of twenty documentation