diff --git a/src/components/Settings/Settings.scss b/src/components/Settings/Settings.scss
index f5281a9..652cec8 100644
--- a/src/components/Settings/Settings.scss
+++ b/src/components/Settings/Settings.scss
@@ -248,6 +248,11 @@
top: 0;
visibility: hidden;
+ &:disabled,
+ &:disabled + label {
+ opacity: 0.5;
+ }
+
&:before {
visibility: visible;
content: '';
diff --git a/src/components/Settings/SettingsOrganizations.svelte b/src/components/Settings/SettingsOrganizations.svelte
index 3e3d612..4e91578 100644
--- a/src/components/Settings/SettingsOrganizations.svelte
+++ b/src/components/Settings/SettingsOrganizations.svelte
@@ -4,6 +4,8 @@
export let init;
import { updateOrganization, isOffline } from '../../shared/store';
+ const getIsDisabled = organization => $isOffline || organization.isBroken;
+ const getIsChecked = organization => organization.checked && !organization.isBroken;
@@ -13,7 +15,7 @@
{#each $organizations as organization}
-
- updateOrganization(e, organization)} checked={organization.checked} />
+ updateOrganization(e, organization)} checked={getIsChecked(organization)} />
{/each}
diff --git a/src/shared/requester.js b/src/shared/requester.js
index 6eb89cb..e45927b 100644
--- a/src/shared/requester.js
+++ b/src/shared/requester.js
@@ -21,6 +21,7 @@ let data = [];
let loadedRepositories = 0;
let loadedOrganizations = 0;
let loadedPullRequests = [];
+let brokenOrganizations = [];
let refreshing = false;
export const getHeader = () => {
@@ -203,26 +204,35 @@ export const getProjects = async ({ organization, numberOfOrganizations }) => {
`https://dev.azure.com/${organization.accountName}/_apis/projects?$top=1000&api-version=5.1`,
);
+ let result = {
+ value: [],
+ };
+
if (res.ok) {
- const result = await res.json();
+ result = await res.json();
+ } else {
+ brokenOrganizations.push(organization.accountName);
+ }
- data = data.map(organizationItem => ({
- ...organizationItem,
- projects:
- organizationItem.accountId === organization.accountId
- ? result.value
- : organizationItem.projects,
- }));
+ loadedOrganizations += 1;
- loadedOrganizations += 1;
+ data = data.map(organizationItem => ({
+ ...organizationItem,
+ isBroken: brokenOrganizations.includes(organizationItem.accountName),
+ projects:
+ organizationItem.accountId === organization.accountId
+ ? result.value
+ : organizationItem.projects,
+ }));
- if (loadedOrganizations === numberOfOrganizations) {
- const numberOfProjects = data.reduce((acc, curr) => {
- acc += curr.projects.length;
- return acc;
- }, 0);
+ if (loadedOrganizations === numberOfOrganizations) {
+ const numberOfProjects = data.reduce((acc, curr) => {
+ acc += curr.projects ? curr.projects.length : 0;
+ return acc;
+ }, 0);
- data.forEach(organizationItem => {
+ data.forEach(organizationItem => {
+ if (organizationItem.projects) {
organizationItem.projects.forEach(({ id: projectId }) =>
getRepositories({
projectId,
@@ -230,10 +240,8 @@ export const getProjects = async ({ organization, numberOfOrganizations }) => {
numberOfProjects,
}),
);
- });
- }
- } else {
- throw new Error(res);
+ }
+ });
}
};