|
|
|
|
@ -1,11 +1,11 @@ |
|
|
|
|
import { Callout, ButtonGroup, Button } from '@rocket.chat/fuselage'; |
|
|
|
|
import { usePermission, useTranslation } from '@rocket.chat/ui-contexts'; |
|
|
|
|
import type { ReactElement } from 'react'; |
|
|
|
|
import React, { memo } from 'react'; |
|
|
|
|
import React, { memo, useState } from 'react'; |
|
|
|
|
|
|
|
|
|
import Page from '../../../components/Page'; |
|
|
|
|
import PageSkeleton from '../../../components/PageSkeleton'; |
|
|
|
|
import { useRefreshStatistics, useWorkspaceInfo } from '../../../hooks/useWorkspaceInfo'; |
|
|
|
|
import { useWorkspaceInfo } from '../../../hooks/useWorkspaceInfo'; |
|
|
|
|
import { downloadJsonAs } from '../../../lib/download'; |
|
|
|
|
import NotAuthorizedPage from '../../notAuthorized/NotAuthorizedPage'; |
|
|
|
|
import WorkspacePage from './WorkspacePage'; |
|
|
|
|
@ -14,8 +14,8 @@ const WorkspaceRoute = (): ReactElement => { |
|
|
|
|
const t = useTranslation(); |
|
|
|
|
const canViewStatistics = usePermission('view-statistics'); |
|
|
|
|
|
|
|
|
|
const [serverInfoQuery, instancesQuery, statisticsQuery] = useWorkspaceInfo(); |
|
|
|
|
const refetchStatistics = useRefreshStatistics(); |
|
|
|
|
const [refreshStatistics, setRefreshStatistics] = useState(false); |
|
|
|
|
const [serverInfoQuery, instancesQuery, statisticsQuery] = useWorkspaceInfo({ refreshStatistics }); |
|
|
|
|
|
|
|
|
|
if (!canViewStatistics) { |
|
|
|
|
return <NotAuthorizedPage />; |
|
|
|
|
@ -24,8 +24,10 @@ const WorkspaceRoute = (): ReactElement => { |
|
|
|
|
if (serverInfoQuery.isLoading || instancesQuery.isLoading || statisticsQuery.isLoading) { |
|
|
|
|
return <PageSkeleton />; |
|
|
|
|
} |
|
|
|
|
const handleClickRefreshButton = (): void => { |
|
|
|
|
refetchStatistics.mutate(); |
|
|
|
|
|
|
|
|
|
const handleClickRefreshButton = async () => { |
|
|
|
|
setRefreshStatistics(true); |
|
|
|
|
statisticsQuery.refetch(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (serverInfoQuery.isError || instancesQuery.isError || statisticsQuery.isError) { |
|
|
|
|
@ -33,7 +35,7 @@ const WorkspaceRoute = (): ReactElement => { |
|
|
|
|
<Page> |
|
|
|
|
<Page.Header title={t('Workspace')}> |
|
|
|
|
<ButtonGroup> |
|
|
|
|
<Button icon='reload' primary type='button' onClick={handleClickRefreshButton}> |
|
|
|
|
<Button icon='reload' primary type='button' onClick={handleClickRefreshButton} loading={statisticsQuery.isLoading}> |
|
|
|
|
{t('Refresh')} |
|
|
|
|
</Button> |
|
|
|
|
</ButtonGroup> |
|
|
|
|
@ -54,6 +56,7 @@ const WorkspaceRoute = (): ReactElement => { |
|
|
|
|
canViewStatistics={canViewStatistics} |
|
|
|
|
serverInfo={serverInfoQuery.data} |
|
|
|
|
statistics={statisticsQuery.data} |
|
|
|
|
statisticsIsLoading={statisticsQuery.isLoading} |
|
|
|
|
instances={instancesQuery.data} |
|
|
|
|
onClickRefreshButton={handleClickRefreshButton} |
|
|
|
|
onClickDownloadInfo={handleClickDownloadInfo} |
|
|
|
|
|