Skip to content

Commit

Permalink
Merge pull request #500 from Quetzacoalt91/display-progress-of-verifi…
Browse files Browse the repository at this point in the history
…cation

Display progress of verification
  • Loading branch information
Quetzacoalt91 authored Nov 9, 2023
2 parents 851de1c + 454a46d commit 559bdfd
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 4 deletions.
3 changes: 2 additions & 1 deletion _dev/src/assets/json/translations/en/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@
"stepDetails": "We check your products for errors before sending them to Facebook. If a product is not compliant, you can fix the error and verify your catalog again. Only compliant products will be sent to Facebook during the next synchronization.",
"scanStatus": {
"notSubscribed": "No verification yet.",
"inProgress": "Verification in progress...",
"inProgress": "Verification in progress... {progress}",
"nbOfVerifiedProducts": " |{xProducts} verified.|{xProducts} verified.",
"lastScanDate": "Last verification on {date} at {time}."
},
"reportCards": {
Expand Down
16 changes: 13 additions & 3 deletions _dev/src/components/catalog/summary/panel/verified-products.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<script lang="ts">
import {PropType, defineComponent} from 'vue';
import showdown from 'showdown';
import {State as CatalogState, ValidationReport} from '@/store/modules/catalog/state';
import StatusCardComponent, {StatusCardParameters} from '../status-card.vue';
import {ValidationReport} from '@/store/modules/catalog/state';
import CatalogTabPages from '@/components/catalog/pages';
import {RequestState} from '@/store/types';
Expand Down Expand Up @@ -99,11 +99,21 @@ export default defineComponent({
},
computed: {
scanRequestStatus(): RequestState {
return this.$store.state.catalog.requests.scan;
return (this.$store.state.catalog as CatalogState).requests.scan;
},
scanProgress(): number|null {
return (this.$store.state.catalog as CatalogState).progress.prevalidation;
},
lastScanText(): string {
if (this.scanRequestStatus === RequestState.PENDING) {
return this.$t('catalog.summaryPage.productCatalog.productVerification.scanStatus.inProgress');
return this.$t('catalog.summaryPage.productCatalog.productVerification.scanStatus.inProgress',
{
progress: this.$tc('catalog.summaryPage.productCatalog.productVerification.scanStatus.nbOfVerifiedProducts',
+this.scanProgress,
{xProducts: this.scanProgress},
),
},
);
}
if (!this.verificationsStats.lastScanDate) {
Expand Down
4 changes: 4 additions & 0 deletions _dev/src/store/modules/catalog/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ export default {
lastScanDate: new Date(result.prevalidation.lastScanDate),
},
} as Partial<ProductFeedReport>);
} else {
commit(MutationsTypes.SET_VALIDATION_PROGRESS, result.progress);
}
}

Expand All @@ -171,6 +173,8 @@ export default {
request: 'scan',
newState: RequestState.FAILED,
});
} finally {
commit(MutationsTypes.SET_VALIDATION_PROGRESS, null);
}

return page;
Expand Down
1 change: 1 addition & 0 deletions _dev/src/store/modules/catalog/mutations-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ enum MutationsTypes {
SET_CATALOG_PAGE_ENABLED = 'SET_CATALOG_PAGE_ENABLED',
SET_SYNCHRONIZATION_ACTIVE = 'SET_SYNCHRONIZATION_ACTIVE',
SET_SYNCHRONIZATION_SUMMARY = 'SET_SYNCHRONIZATION_SUMMARY',
SET_VALIDATION_PROGRESS = 'SET_VALIDATION_PROGRESS',
SET_CATEGORY_MATCHING_SUMMARY = 'SET_CATEGORY_MATCHING_SUMMARY',

SET_REQUEST_STATE = 'SET_REQUEST_STATE',
Expand Down
6 changes: 6 additions & 0 deletions _dev/src/store/modules/catalog/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export default {
...payload,
};
},
[MutationsTypes.SET_VALIDATION_PROGRESS](
state: LocalState,
payload: number|null,
) {
state.progress.prevalidation = payload;
},
[MutationsTypes.SET_CATEGORY_MATCHING_SUMMARY](
state: LocalState,
payload: CategoryMatchingStatus,
Expand Down
8 changes: 8 additions & 0 deletions _dev/src/store/modules/catalog/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type State = {
exportOn: boolean,
categoryMatching: CategoryMatchingStatus,
report: ProductFeedReport,
progress: ProductFeedProgress,
requests: CatalogRequests,
}

Expand All @@ -23,6 +24,10 @@ export type ValidationReport = {
lastScanDate: Date|null,
}

export type ProductFeedProgress = {
prevalidation: number|null,
}

export type SyncReport = {
catalog: number|null,
errored: number|null,
Expand Down Expand Up @@ -57,6 +62,9 @@ export const state: State = {
lastSyncDate: null,
},
},
progress: {
prevalidation: null,
},
categoryMatching: {
matchingDone: false,
matchingProgress: {
Expand Down
15 changes: 15 additions & 0 deletions _dev/stories/201-catalog-summary.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ CatalogNotShared.args = {
errored: null,
},
},
progress: {
prevalidation: null,
},
requests: {
requestNextSyncFull: RequestState.IDLE,
scan: RequestState.IDLE,
Expand Down Expand Up @@ -75,6 +78,9 @@ CatalogRecentlyShared.args = {
errored: null,
},
},
progress: {
prevalidation: null,
},
requests: {
requestNextSyncFull: RequestState.IDLE,
scan: RequestState.IDLE,
Expand Down Expand Up @@ -109,6 +115,9 @@ SyncOn.args = {
errored: 42,
},
},
progress: {
prevalidation: null,
},
requests: {
requestNextSyncFull: RequestState.IDLE,
scan: RequestState.IDLE,
Expand Down Expand Up @@ -143,6 +152,9 @@ SyncPaused.args = {
errored: 42,
},
},
progress: {
prevalidation: null,
},
requests: {
requestNextSyncFull: RequestState.IDLE,
scan: RequestState.IDLE,
Expand Down Expand Up @@ -177,6 +189,9 @@ FullConfiguration.args = {
errored: 42,
},
},
progress: {
prevalidation: null,
},
requests: {
requestNextSyncFull: RequestState.IDLE,
scan: RequestState.IDLE,
Expand Down

0 comments on commit 559bdfd

Please sign in to comment.