Skip to content

Commit

Permalink
Merge branch 'loading-msg' of 'https://github.com/evamillan/grimoirel…
Browse files Browse the repository at this point in the history
…ab-sortinghat'

Merges #906 
Closes #866
  • Loading branch information
jjmerchante authored Aug 9, 2024
2 parents 51f29eb + fcb57d0 commit 2d5a9b1
Show file tree
Hide file tree
Showing 13 changed files with 5,382 additions and 3,282 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Improve loading and error indicators
category: added
author: Eva Millán <[email protected]>
issue: 866
notes: >
Added error and loading messages to improve the user experience
when the data takes time to load.
2 changes: 2 additions & 0 deletions ui/src/apollo/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,6 @@ export {
getOrganization,
getScheduledTasks,
findOrganization,
GET_INDIVIDUAL_BYUUID,
GET_ORGANIZATION,
};
47 changes: 47 additions & 0 deletions ui/src/components/IndividualsTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,50 @@ export const HiddenHeader = () => ({
isExpandable: false,
}),
});

export const OnError = () => ({
components: { IndividualsTable },
template: IndividualsTableTemplate,
methods: {
queryIndividuals() {
throw new Error("Test error message");
},
deleteIndividual() {
return true;
},
getCountries() {
return true;
},
recommendMatches() {
return {
data: {
recommendMatches: {
jobId: "b65d2170-a560-4b20-954e-fc8c9f5afdd4",
},
},
};
},
},
provide: () => ({
getRecommendations: () => {},
getRecommendationsCount: () => {
return {
data: {
recommendedMerge: {
pageInfo: {
totalResults: 0,
},
},
},
};
},
manageRecommendation: () => {},
}),
data: () => ({
query: query,
hideHeader: false,
outlined: true,
isExpandable: false,
}),
});

48 changes: 32 additions & 16 deletions ui/src/components/IndividualsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@
</v-col>
</div>
</template>
<template v-slot:no-data>
<v-alert v-if="error" class="text-left" density="compact" type="error">
{{ error }}
</v-alert>
<p v-else-if="Object.keys(filters).length > 0">
No results matched your search.
</p>
<p v-else>No data available</p>
</template>
</v-data-table-server>

<v-dialog v-model="dialog.open" max-width="500px">
Expand Down Expand Up @@ -447,6 +456,7 @@ export default {
uuid: "",
},
selected: [],
error: null,
};
},
computed: {
Expand All @@ -472,24 +482,30 @@ export default {
) {
if (this.disabledSearch) return;
this.loading = true;
let response = await this.fetchPage(
page,
this.itemsPerPage,
filters,
orderBy
);
if (response) {
this.individuals = formatIndividuals(
response.data.individuals.entities
this.error = null;
try {
let response = await this.fetchPage(
page,
this.itemsPerPage,
filters,
orderBy
);
this.pageCount = response.data.individuals.pageInfo.numPages;
this.page = response.data.individuals.pageInfo.page;
this.totalResults = response.data.individuals.pageInfo.totalResults;
this.allSelected = false;
this.$emit("updateIndividuals", this.individuals);
if (response) {
this.individuals = formatIndividuals(
response.data.individuals.entities
);
this.pageCount = response.data.individuals.pageInfo.numPages;
this.page = response.data.individuals.pageInfo.page;
this.totalResults = response.data.individuals.pageInfo.totalResults;
this.allSelected = false;
this.$emit("updateIndividuals", this.individuals);
}
} catch (error) {
this.error = this.$getErrorMessage(error);
} finally {
this.loading = false;
this.selected = [];
}
this.loading = false;
this.selected = [];
},
startDrag(item, isSelected, toggleSelect, event) {
if (!isSelected(item)) {
Expand Down
24 changes: 24 additions & 0 deletions ui/src/components/JobsTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,27 @@ export const Empty = () => ({
},
}),
});

export const OnError = () => ({
components: { JobsTable },
template: JobsTableTemplate,
methods: {
getJobs() {
throw new Error("Test error message")
},
},
data: () => ({
query: {
data: {
jobs: {
entities: [],
pageInfo: {
page: 1,
numPages: 1,
totalResults: 0,
},
},
},
},
}),
});
27 changes: 21 additions & 6 deletions ui/src/components/JobsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
Add
</v-btn>
</header>
<v-table v-if="jobs.length > 0">
<v-alert v-if="error" :text="error" density="compact" type="error" />
<v-progress-linear v-if="isLoading" color="primary" indeterminate />
<v-table v-else-if="jobs.length > 0">
<template v-slot:default>
<thead>
<tr>
Expand Down Expand Up @@ -89,18 +91,31 @@ export default {
pageSize: 10,
pageCount: 1,
openModal: false,
error: null,
isLoading: false,
};
},
created() {
this.getPaginatedJobs(1);
},
methods: {
async getPaginatedJobs(page = this.page, pageSize = this.pageSize) {
let response = await this.getJobs(page, pageSize);
if (response) {
this.jobs = response.data.jobs.entities;
this.pageCount = response.data.jobs.pageInfo.numPages;
this.page = response.data.jobs.pageInfo.page;
this.isLoading = true;
try {
let response = await this.getJobs(page, pageSize);
if (response.data.jobs.entities) {
this.jobs = response.data.jobs.entities;
this.pageCount = response.data.jobs.pageInfo.numPages;
this.page = response.data.jobs.pageInfo.page;
} else if (response.errors) {
this.error = `Error fetching data: ${this.$getErrorMessage(
response.errors
)}`;
}
} catch (error) {
this.error = `Error fetching data: ${this.$getErrorMessage(error)}`;
} finally {
this.isLoading = false;
}
},
getColor(status) {
Expand Down
24 changes: 24 additions & 0 deletions ui/src/components/LoadingSpinner.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import LoadingSpinner from "./LoadingSpinner.vue";

export default {
title: "LoadingSpinner",
excludeStories: /.*Data$/,
};

const template = `<loading-spinner :label="label"/>`;

export const Default = () => ({
components: { LoadingSpinner },
template: template,
data: () => ({
label: null,
}),
});

export const Label = () => ({
components: { LoadingSpinner },
template: template,
data: () => ({
label: "Loading...",
}),
});
23 changes: 23 additions & 0 deletions ui/src/components/LoadingSpinner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div class="d-flex flex-column justify-center align-center pa-4 h-100">
<v-progress-circular :size="size" color="primary" indeterminate />
<p v-if="label" class="subtitle-1 text-medium-emphasis mt-4">{{ label }}</p>
</div>
</template>
<script>
export default {
name: "LoadingSpinner",
props: {
label: {
type: String,
required: false,
default: null,
},
size: {
type: [String, Number],
required: false,
default: 48,
},
},
};
</script>
38 changes: 38 additions & 0 deletions ui/src/components/OrganizationsTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,41 @@ export const Groups = () => ({
name: "Groups",
}),
});

export const OnError = () => ({

Check warning on line 305 in ui/src/components/OrganizationsTable.stories.js

View workflow job for this annotation

GitHub Actions / Node 18.x

'page' is defined but never used

Check warning on line 305 in ui/src/components/OrganizationsTable.stories.js

View workflow job for this annotation

GitHub Actions / Node 18.x

'items' is defined but never used

Check warning on line 305 in ui/src/components/OrganizationsTable.stories.js

View workflow job for this annotation

GitHub Actions / Node 18.x

'filters' is defined but never used

Check warning on line 305 in ui/src/components/OrganizationsTable.stories.js

View workflow job for this annotation

GitHub Actions / Node 20.x

'page' is defined but never used

Check warning on line 305 in ui/src/components/OrganizationsTable.stories.js

View workflow job for this annotation

GitHub Actions / Node 20.x

'items' is defined but never used

Check warning on line 305 in ui/src/components/OrganizationsTable.stories.js

View workflow job for this annotation

GitHub Actions / Node 20.x

'filters' is defined but never used
components: { OrganizationsTable },
template: OrganizationsTableTemplate,
methods: {
getOrganizations(page, items, filters) {
throw new Error("Test error message");
},
enroll() {
return true;
},
addOrganization() {
return;
},
addDomain() {
return;
},
deleteDomain() {
return;
},
deleteOrganization() {
return;
},
addTeam() {
return;
},
deleteTeam() {
return;
},
fetchTeams() {
return;
},
},
data: () => ({
isGroup: false,
name: "Organizations",
}),
});
30 changes: 23 additions & 7 deletions ui/src/components/OrganizationsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@
></v-text-field>
</div>
</template>
<template v-slot:no-data>
<v-alert v-if="error" class="text-left" density="compact" type="error">
{{ error }}
</v-alert>
<p v-else-if="Object.keys(filters).length > 0">
No results matched your search.
</p>
<p v-else>No data available</p>
</template>
</v-data-table-server>

<organization-modal
Expand Down Expand Up @@ -267,6 +276,7 @@ export default {
teamName: "",
},
loading: false,
error: null,
};
},
created() {
Expand All @@ -275,14 +285,20 @@ export default {
methods: {
async getTableItems(page = this.page, filters = this.filters) {
this.loading = true;
let response = await this.fetchPage(page, this.itemsPerPage, filters);
if (response) {
this.items = response.entities;
this.pageCount = response.pageInfo.numPages;
this.page = response.pageInfo.page;
this.totalResults = response.pageInfo.totalResults;
this.error = null;
try {
let response = await this.fetchPage(page, this.itemsPerPage, filters);
if (response) {
this.items = response.entities;
this.pageCount = response.pageInfo.numPages;
this.page = response.pageInfo.page;
this.totalResults = response.pageInfo.totalResults;
}
} catch (error) {
this.error = this.$getErrorMessage(error);
} finally {
this.loading = false;
}
this.loading = false;
},
confirmEnroll(event) {
Object.assign(this.dialog, {
Expand Down
Loading

0 comments on commit 2d5a9b1

Please sign in to comment.