-
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.
* style updates to match mockups * update extension icons * update extension icon when user logs in or out * move code that will be called by both popup and background script to shared file * update extension icon on startup
- Loading branch information
Showing
18 changed files
with
82 additions
and
48 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,51 @@ | ||
import { action, cookies } from 'webextension-polyfill'; | ||
import type { User } from './types'; | ||
|
||
const IconPaths = { | ||
Grey: { | ||
16: '/icons/gk-grey-16.png', | ||
32: '/icons/gk-grey-32.png', | ||
48: '/icons/gk-grey-48.png', | ||
128: '/icons/gk-grey-128.png', | ||
}, | ||
Green: { | ||
16: '/icons/gk-green-16.png', | ||
32: '/icons/gk-green-32.png', | ||
48: '/icons/gk-green-48.png', | ||
128: '/icons/gk-green-128.png', | ||
}, | ||
}; | ||
|
||
export const updateExtensionIcon = (isLoggedIn: boolean) => action.setIcon({ path: isLoggedIn ? IconPaths.Green : IconPaths.Grey }); | ||
|
||
export const getAccessToken = async () => { | ||
// Attempt to get the access token cookie from GitKraken.dev | ||
const cookie = await cookies.get({ | ||
url: 'https://gitkraken.dev', | ||
name: 'accessToken' | ||
}); | ||
|
||
return cookie?.value; | ||
}; | ||
|
||
export const fetchUser = async () => { | ||
const token = await getAccessToken(); | ||
if (!token) { | ||
// The user is not logged in. | ||
return; | ||
} | ||
|
||
const res = await fetch('https://api.gitkraken.dev/user', { | ||
headers: { | ||
Authorization: `Bearer ${token}` | ||
} | ||
}); | ||
|
||
if (!res.ok) { | ||
// The access token is invalid or expired. | ||
return; | ||
} | ||
|
||
const user = await res.json(); | ||
return user as User; | ||
}; |
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,10 @@ | ||
export interface User { | ||
email: string; | ||
name?: string; | ||
proAccessState?: { | ||
trial?: { | ||
end?: string; | ||
} | ||
}; | ||
username: string; | ||
} |
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