-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: workspace info admin page (#30434)
- Loading branch information
1 parent
180d400
commit 5d55a93
Showing
49 changed files
with
966 additions
and
1,228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": minor | ||
--- | ||
|
||
Added a new Admin page called `Workspace info` in place of Information page, to make it easier to check the license |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import type { IStats, IWorkspaceInfo, Serialized } from '@rocket.chat/core-typings'; | ||
import type { IInstance } from '@rocket.chat/rest-typings'; | ||
import { useEndpoint } from '@rocket.chat/ui-contexts'; | ||
import { useMutation, useQueries, useQueryClient } from '@tanstack/react-query'; | ||
|
||
export const useWorkspaceInfo = () => { | ||
const getStatistics = useEndpoint('GET', '/v1/statistics'); | ||
const getInstances = useEndpoint('GET', '/v1/instances.get'); | ||
const getServerInfo = useEndpoint('GET', '/info'); | ||
|
||
return useQueries({ | ||
queries: [ | ||
{ | ||
queryKey: ['info', 'serverInfo'], | ||
queryFn: async () => { | ||
const data = await getServerInfo(); | ||
|
||
if (!('minimumClientVersions' in data)) { | ||
throw new Error('Invalid server info'); | ||
} | ||
if (!('info' in data)) { | ||
throw new Error('Invalid server info'); | ||
} | ||
if (!('version' in data)) { | ||
throw new Error('Invalid server info'); | ||
} | ||
|
||
return data as IWorkspaceInfo; | ||
}, | ||
staleTime: Infinity, | ||
keepPreviousData: true, | ||
}, | ||
{ | ||
queryKey: ['info', 'instances'], | ||
queryFn: () => getInstances(), | ||
staleTime: Infinity, | ||
keepPreviousData: true, | ||
select({ instances }: Serialized<{ instances: IInstance[] }>) { | ||
return instances.map((instance) => ({ | ||
...instance, | ||
...(instance.instanceRecord && { | ||
instanceRecord: { | ||
...instance.instanceRecord, | ||
_createdAt: new Date(instance.instanceRecord._createdAt), | ||
}, | ||
}), | ||
})) as IInstance[]; | ||
}, | ||
}, | ||
{ | ||
queryKey: ['info', 'statistics'], | ||
queryFn: () => getStatistics({ refresh: 'true' }), | ||
staleTime: Infinity, | ||
keepPreviousData: true, | ||
select: (data: Serialized<IStats>) => ({ | ||
...data, | ||
lastMessageSentAt: data.lastMessageSentAt ? new Date(data.lastMessageSentAt) : undefined, | ||
}), | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
export const useRefreshStatistics = () => { | ||
const queryClient = useQueryClient(); | ||
return useMutation({ | ||
mutationFn: () => queryClient.invalidateQueries(['info', 'statistics']), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { LicenseLimitKind } from '@rocket.chat/license'; | ||
|
||
type Limits = Record< | ||
LicenseLimitKind, | ||
{ | ||
max: number; | ||
value?: number; | ||
} | ||
>; | ||
|
||
export const isOverLicenseLimits = (limits: Limits): boolean => | ||
Object.values(limits).some((limit) => limit.value !== undefined && limit.value > limit.max); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.