Skip to content

Commit a6ab3cc

Browse files
committed
feat(accounts): warn when missing scopes
Signed-off-by: Adam Setch <[email protected]>
1 parent 0788e82 commit a6ab3cc

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

src/renderer/__mocks__/partial-mocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function partialMockNotification(
1313
hostname: Constants.GITHUB_API_BASE_URL as Hostname,
1414
token: mockToken,
1515
user: mockGitifyUser,
16+
hasRequiredScopes: true,
1617
},
1718
subject: subject as Subject,
1819
};

src/renderer/__mocks__/state-mocks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const mockOAuthAccount: Account = {
4343
token: '1234568790' as Token,
4444
hostname: 'github.gitify.io' as Hostname,
4545
user: mockGitifyUser,
46+
hasRequiredScopes: true,
4647
};
4748

4849
export const mockGitHubCloudAccount: Account = {
@@ -52,6 +53,7 @@ export const mockGitHubCloudAccount: Account = {
5253
hostname: Constants.DEFAULT_AUTH_OPTIONS.hostname,
5354
user: mockGitifyUser,
5455
version: 'latest',
56+
hasRequiredScopes: true,
5557
};
5658

5759
export const mockGitHubEnterpriseServerAccount: Account = {
@@ -60,6 +62,7 @@ export const mockGitHubEnterpriseServerAccount: Account = {
6062
token: '1234568790' as Token,
6163
hostname: 'github.gitify.io' as Hostname,
6264
user: mockGitifyUser,
65+
hasRequiredScopes: true,
6366
};
6467

6568
export const mockGitHubAppAccount: Account = {
@@ -68,6 +71,7 @@ export const mockGitHubAppAccount: Account = {
6871
token: '987654321' as Token,
6972
hostname: Constants.DEFAULT_AUTH_OPTIONS.hostname,
7073
user: mockGitifyUser,
74+
hasRequiredScopes: true,
7175
};
7276

7377
export const mockAuth: AuthState = {

src/renderer/routes/Accounts.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,22 @@ export const AccountsRoute: FC = () => {
102102
</span>
103103
</button>
104104

105-
{account.method === 'Personal Access Token' &&
106-
account.hasRequiredScopes === false && (
107-
<span className="text-xs font-medium italic">
108-
<button
109-
type="button"
110-
className="cursor-pointer"
111-
title={`This account is missing one or more required scopes: \n - ${Constants.AUTH_SCOPE.join('\n - ')}`}
112-
aria-label="missing-scopes"
113-
onClick={() => openDeveloperSettings(account)}
114-
>
115-
<AlertFillIcon
116-
size={Size.XSMALL}
117-
className={IconColor.RED}
118-
/>
119-
</button>
120-
</span>
121-
)}
105+
{account.hasRequiredScopes === false && (
106+
<span className="text-xs font-medium italic">
107+
<button
108+
type="button"
109+
className="cursor-pointer"
110+
title={`This account is missing one or more required scopes: \n - ${Constants.AUTH_SCOPE.join('\n - ')}`}
111+
aria-label="missing-scopes"
112+
onClick={() => openDeveloperSettings(account)}
113+
>
114+
<AlertFillIcon
115+
size={Size.XSMALL}
116+
className={IconColor.RED}
117+
/>
118+
</button>
119+
</span>
120+
)}
122121
</div>
123122
<div>
124123
<button

0 commit comments

Comments
 (0)