-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afdcad7
commit a31d533
Showing
56 changed files
with
1,363 additions
and
130 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 `Subscription`, this page is responsible of managing the current workspace subscription and it has a overview of the usage and limits of the plan |
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,45 @@ | ||
import { serverFetch as fetch } from '@rocket.chat/server-fetch'; | ||
|
||
import { SystemLogger } from '../../../../server/lib/logger/system'; | ||
import { settings } from '../../../settings/server'; | ||
import { getURL } from '../../../utils/server/getURL'; | ||
import { getWorkspaceAccessTokenOrThrow } from './getWorkspaceAccessToken'; | ||
|
||
export const getCheckoutUrl = async () => { | ||
try { | ||
const token = await getWorkspaceAccessTokenOrThrow(false, 'workspace:billing'); | ||
|
||
const subscriptionURL = getURL('admin/subscription', { | ||
full: true, | ||
}); | ||
|
||
const body = { | ||
okCallback: `${subscriptionURL}?subscriptionSuccess=true`, | ||
cancelCallback: subscriptionURL, | ||
}; | ||
|
||
const billingUrl = settings.get<string>('Cloud_Billing_Url'); | ||
|
||
const response = await fetch(`${billingUrl}/api/v2/checkout`, { | ||
method: 'POST', | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
body, | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error(await response.json()); | ||
} | ||
|
||
return response.json(); | ||
} catch (err: any) { | ||
SystemLogger.error({ | ||
msg: 'Failed to get Checkout URL with Rocket.Chat Billing Service', | ||
url: '/api/v2/checkout', | ||
err, | ||
}); | ||
|
||
throw err; | ||
} | ||
}; |
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 |
---|---|---|
@@ -1,23 +1,13 @@ | ||
import type { OperationResult } from '@rocket.chat/rest-typings'; | ||
import { useEndpoint } from '@rocket.chat/ui-contexts'; | ||
import type { UseQueryOptions, UseQueryResult } from '@tanstack/react-query'; | ||
import type { UseQueryResult } from '@tanstack/react-query'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
const queryKey = ['licenses', 'isEnterprise'] as const; | ||
|
||
export const useIsEnterprise = ( | ||
options?: UseQueryOptions< | ||
OperationResult<'GET', '/v1/licenses.isEnterprise'>, | ||
unknown, | ||
OperationResult<'GET', '/v1/licenses.isEnterprise'>, | ||
typeof queryKey | ||
>, | ||
): UseQueryResult<OperationResult<'GET', '/v1/licenses.isEnterprise'>> => { | ||
export const useIsEnterprise = (): UseQueryResult<OperationResult<'GET', '/v1/licenses.isEnterprise'>> => { | ||
const isEnterpriseEdition = useEndpoint('GET', '/v1/licenses.isEnterprise'); | ||
|
||
return useQuery(queryKey, () => isEnterpriseEdition(), { | ||
return useQuery(['licenses', 'isEnterprise'], () => isEnterpriseEdition(), { | ||
keepPreviousData: true, | ||
staleTime: Infinity, | ||
...options, | ||
}); | ||
}; |
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,9 @@ | ||
import { useStatistics } from '../views/hooks/useStatistics'; | ||
|
||
export const useIsSelfHosted = (): { isSelfHosted: boolean; isLoading: boolean } => { | ||
const { data, isLoading } = useStatistics(); | ||
|
||
const isSelfHosted = data?.deploy?.platform !== 'rocket-cloud'; | ||
|
||
return { isSelfHosted, isLoading }; | ||
}; |
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
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
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
Oops, something went wrong.