Skip to content
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

Chrome extension experiments #177

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions clients/apps/chrome-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"polarkit": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"typescript": "^4.4.2",
"typescript": "^5.0.0",
"web-vitals": "^2.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && webpack --config webpack.config.js && mv dist/content.js ./extension",
"build": "webpack --config webpack.config.js && mv dist/content.js ./extension",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand Down
5 changes: 3 additions & 2 deletions clients/apps/chrome-extension/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { createRoot } from 'react-dom/client'
import App from './App'
// import App from './App'
import { Badge } from 'polarkit/components'
import './index.css'
import reportWebVitals from './reportWebVitals'

Expand All @@ -11,7 +12,7 @@ if (taskLists) {
const root = createRoot(badge)
root.render(
<React.StrictMode>
<App />
<Badge />
</React.StrictMode>,
)
}
Expand Down
4 changes: 2 additions & 2 deletions clients/apps/chrome-extension/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noImplicitAny": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"moduleResolution": "bundler",
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
Expand Down
1 change: 0 additions & 1 deletion clients/packages/polarkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"axios": "^0.27.2",
"cmdk": "^0.2.0",
"eventemitter3": "^5.0.0",
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-timeago": "^7.1.0",
Expand Down
10 changes: 5 additions & 5 deletions clients/packages/polarkit/scripts/generate-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ const main = async (schemaUrl, sourceFilename, generatedFilename) => {
save(generatedFilename, schema)
}

const argv = process.argv.slice(2)
if (argv.length !== 3) {
throw new Error('Args: <remoteSchemaUrl> <saveOriginalAs> <saveUpdatedAs>')
}
main(argv[0], argv[1], argv[2])
// const argv = process.argv.slice(2)
// if (argv.length !== 3) {
// throw new Error('Args: <remoteSchemaUrl> <saveOriginalAs> <saveUpdatedAs>')
// }
// main(argv[0], argv[1], argv[2])
2 changes: 1 addition & 1 deletion clients/packages/polarkit/src/components/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Badge = ({
}: {
width?: number
height?: number
showAmountRaised: boolean
showAmountRaised?: boolean
}) => {
return (
<>
Expand Down
3 changes: 1 addition & 2 deletions clients/packages/polarkit/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import IssueList from '../../../../apps/web/src/components/Dashboard/IssueList'
import Badge from './Badge'
import IssueLabel from './IssueLabel'
import IssueListItem from './IssueListItem'
import RepoSelection from './RepoSelection'

export { IssueList, IssueLabel, IssueListItem, Badge, RepoSelection }
export { IssueLabel, IssueListItem, Badge, RepoSelection }
15 changes: 10 additions & 5 deletions clients/packages/polarkit/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ const stringToNumber = (
}

export const CONFIG = {
BASE_URL: process?.env?.NEXT_PUBLIC_API_URL || 'http://127.0.0.1:8000',
BASE_URL:
// process?.env?.NEXT_PUBLIC_API_URL ||
'http://127.0.0.1:8000',
GITHUB_INSTALLATION_URL:
process?.env?.NEXT_PUBLIC_GITHUB_INSTALLATION_URL ||
// process?.env?.NEXT_PUBLIC_GITHUB_INSTALLATION_URL ||
'https://github.com/apps/polar-code/installations/new',
LOCALSTORAGE_PERSIST_KEY:
process?.env?.NEXT_PUBLIC_LOCALSTORAGE_PERSIST_KEY || 'polar',
// process?.env?.NEXT_PUBLIC_LOCALSTORAGE_PERSIST_KEY ||
'polar',
LOCALSTORAGE_PERSIST_VERSION: stringToNumber(
process?.env?.NEXT_PUBLIC_LOCALSTORAGE_PERSIST_VERSION,
// process?.env?.NEXT_PUBLIC_LOCALSTORAGE_PERSIST_VERSION,
undefined,
2,
),
// Minimum amount in cents
MINIMUM_PLEDGE_AMOUNT:
process?.env?.NEXT_PUBLIC_MINIMUM_PLEDGE_AMOUNT || 2000,
// process?.env?.NEXT_PUBLIC_MINIMUM_PLEDGE_AMOUNT ||
2000,
}
6 changes: 3 additions & 3 deletions clients/packages/polarkit/src/hooks/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRouter } from 'next/router'
// import { useRouter } from 'next/router'
import { CancelablePromise, type UserRead } from 'polarkit/api/client'
import { useEffect, useState } from 'react'
import { UserState, useStore } from '../store'
Expand Down Expand Up @@ -61,11 +61,11 @@ export const requireAuth = (
isChecking: boolean
} => {
// TODO: Change this to be given by the app. Currently forcing next router
const router = useRouter()
// const router = useRouter()
const session = useAuth()

if (!session.authenticated && session.hasChecked) {
router.push(redirectTo)
// router.push(redirectTo)
}

return session
Expand Down
9 changes: 6 additions & 3 deletions clients/packages/polarkit/src/hooks/org.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRouter } from 'next/router'
// import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import type { OrganizationRead, RepositoryRead } from '../api/client'
import { useStore } from '../store'
Expand All @@ -11,8 +11,11 @@ export const useCurrentOrgAndRepoFromURL = (): {
isLoaded: boolean
haveOrgs: boolean
} => {
const router = useRouter()
const { organization: queryOrg, repo: queryRepo } = router.query
// const router = useRouter()
const { organization: queryOrg, repo: queryRepo } = {
organization: 'hult',
repo: 'dotfiles',
} // router.query
const { currentUser } = requireAuth()
const userOrgQuery = useUserOrganizations(currentUser)
const [org, setOrg] = useState<OrganizationRead | undefined>(undefined)
Expand Down
2 changes: 1 addition & 1 deletion clients/packages/polarkit/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export * from './useOutsideClick'

export const getServerURL = (path?: string): string => {
path = path !== undefined ? path : ''
const baseURL = process?.env?.NEXT_PUBLIC_API_URL
const baseURL = 'http://127.0.0.1:8000' // process?.env?.NEXT_PUBLIC_API_URL
const baseWithPath = `${baseURL}${path}`
return baseWithPath
}
Expand Down
Loading