Skip to content

Commit

Permalink
fix: importers progress bar (#30141)
Browse files Browse the repository at this point in the history
Co-authored-by: Hugo Costa <20212776+hugocostadev@users.noreply.github.com>
  • Loading branch information
felipe-rod123 and hugocostadev committed Sep 8, 2023
1 parent 839789c commit d6f0c6a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .changeset/importer-progress-bar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
---

Fixed Importer Progress Bar progress indicator

26 changes: 11 additions & 15 deletions apps/meteor/client/views/admin/import/ImportProgressPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ProgressStep } from '@rocket.chat/core-typings';
import { Box, Margins, Throbber } from '@rocket.chat/fuselage';
import { Box, Margins, ProgressBar, Throbber } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useToastMessageDispatch, useEndpoint, useTranslation, useStream, useRouter } from '@rocket.chat/ui-contexts';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
Expand Down Expand Up @@ -137,16 +137,14 @@ const ImportProgressPage = function ImportProgressPage() {
useEffect(() => {
return streamer('progress', (progress) => {
// There shouldn't be any progress update sending only the rate at this point of the process
if ('rate' in progress) {
return;
if (!('rate' in progress)) {
handleProgressUpdated({
key: progress.key,
step: progress.step,
completed: progress.count.completed,
total: progress.count.total,
});
}

handleProgressUpdated({
key: progress.key,
step: progress.step,
completed: progress.count.completed,
total: progress.count.total,
});
});
}, [handleProgressUpdated, streamer]);

Expand All @@ -167,11 +165,9 @@ const ImportProgressPage = function ImportProgressPage() {
{t((progress.data.step[0].toUpperCase() + progress.data.step.slice(1)) as any)}
</Box>
<Box display='flex' justifyContent='center'>
<Box is='progress' value={progress.data.completed} max={progress.data.total} marginInlineEnd={24} />
<Box is='span' fontScale='p2'>
{progress.data.completed}/{progress.data.total} (
{numberFormat((progress.data.completed / progress.data.total) * 100, 0)}
%)
<ProgressBar percentage={(progress.data.completed / progress.data.total) * 100} />
<Box is='span' fontScale='p2' mis={24}>
{numberFormat((progress.data.completed / progress.data.total) * 100, 0)}%
</Box>
</Box>
</>
Expand Down
8 changes: 5 additions & 3 deletions apps/meteor/client/views/admin/import/PrepareImportPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Badge, Box, Button, ButtonGroup, Margins, Throbber, Tabs } from '@rocket.chat/fuselage';
import { Badge, Box, Button, ButtonGroup, Margins, ProgressBar, Throbber, Tabs } from '@rocket.chat/fuselage';
import { useDebouncedValue, useSafely } from '@rocket.chat/fuselage-hooks';
import { useEndpoint, useTranslation, useStream, useRouter } from '@rocket.chat/ui-contexts';
import React, { useEffect, useState, useMemo } from 'react';
Expand Down Expand Up @@ -204,8 +204,10 @@ function PrepareImportPage() {
<>
{progressRate ? (
<Box display='flex' justifyContent='center' fontScale='p2'>
<Box is='progress' value={(progressRate * 10).toFixed(0)} max='1000' marginInlineEnd='x24' />
<Box is='span'>{numberFormat(progressRate, 0)}%</Box>
<ProgressBar percentage={progressRate.toFixed(0)} />
<Box is='span' mis='x24'>
{numberFormat(progressRate, 0)}%
</Box>
</Box>
) : (
<Throbber justifyContent='center' />
Expand Down

0 comments on commit d6f0c6a

Please sign in to comment.