@@ -166,7 +166,7 @@ const OrganizationProjects = ({
key={makeRandomString(5)}
project={project}
rewriteHref={rewriteHref ? rewriteHref(project.ref) : undefined}
- resourceWarnings={resourceWarnings?.find(
+ resourceWarnings={resourceWarnings.find(
(resourceWarning) => resourceWarning.project === project.ref
)}
/>
diff --git a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
index 7a1cd41cb61..586022bfbec 100644
--- a/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
+++ b/studio/components/layouts/ProjectLayout/ProjectLayout.tsx
@@ -18,7 +18,7 @@ import RestoringState from './RestoringState'
import UpgradingState from './UpgradingState'
import AppLayout from '../AppLayout/AppLayout'
import UsageWarningBanner from 'components/ui/UsageWarnings/UsageWarningBanner'
-import { useResourceWarningQuery } from 'data/usage/resource-warnings-query'
+import { useResourceWarningsQuery } from 'data/usage/resource-warnings-query'
// [Joshen] This is temporary while we unblock users from managing their project
// if their project is not responding well for any reason. Eventually needs a bit of an overhaul
@@ -179,7 +179,7 @@ const ContentWrapper = ({ isLoading, children }: ContentWrapperProps) => {
selectedProject?.status === PROJECT_STATUS.PAUSING
const isProjectOffline = selectedProject?.postgrestStatus === 'OFFLINE'
- const { data: resourceWarnings } = useResourceWarningQuery()
+ const { data: resourceWarnings } = useResourceWarningsQuery()
console.log(resourceWarnings)
return (
<>
diff --git a/studio/components/ui/CardButton.tsx b/studio/components/ui/CardButton.tsx
index f374f6cef82..9c0690af6ac 100644
--- a/studio/components/ui/CardButton.tsx
+++ b/studio/components/ui/CardButton.tsx
@@ -27,7 +27,7 @@ const CardButton = ({
imgAlt,
onClick,
icon,
- containerHeightClassName = 'h-48',
+ containerHeightClassName = '',
loading = false,
}: PropsWithChildren
) => {
const LinkContainer = ({ children }: { children: React.ReactNode }) => (
@@ -47,7 +47,7 @@ const CardButton = ({
'group relative text-left',
'bg-panel-header-light dark:bg-panel-header-dark',
'border border-panel-border-light dark:border-panel-border-dark',
- 'rounded-md py-4 px-6 flex flex-row',
+ 'rounded-md py-4 flex flex-row',
'transition ease-in-out duration-150',
containerHeightClassName,
]
diff --git a/studio/data/usage/keys.ts b/studio/data/usage/keys.ts
index b5aca6f8298..54be56a1858 100644
--- a/studio/data/usage/keys.ts
+++ b/studio/data/usage/keys.ts
@@ -1,5 +1,5 @@
export const usageKeys = {
usage: (projectRef: string | undefined) => ['projects', projectRef, 'usage'] as const,
orgUsage: (orgSlug: string | undefined) => ['organizations', orgSlug, 'usage'] as const,
- resourceWarnings: () => ['project', 'resource-warnings'] as const,
+ resourceWarnings: () => ['projects', 'resource-warnings'] as const,
}
diff --git a/studio/data/usage/resource-warnings-query.ts b/studio/data/usage/resource-warnings-query.ts
index 82be8e7f1eb..19a92acbe8d 100644
--- a/studio/data/usage/resource-warnings-query.ts
+++ b/studio/data/usage/resource-warnings-query.ts
@@ -1,40 +1,26 @@
import { useQuery, UseQueryOptions } from '@tanstack/react-query'
-import { get, isResponseOk } from 'lib/common/fetch'
-import { API_URL } from 'lib/constants'
-import { usageKeys } from './keys'
-export type ResourceWarningResponse = {
- project: string
- is_readonly_mode_enabled: boolean
- is_disk_io_budget_below_threshold: boolean
- is_disk_space_usage_beyond_threshold: boolean
- is_cpu_load_beyond_threshold: boolean
- is_memory_and_swap_usage_beyond_threshold: boolean
-}
+import { get } from 'data/fetchers'
+import { usageKeys } from './keys'
+import { ResponseError } from 'types'
+import { components } from 'data/api'
export async function getResourceWarnings(signal?: AbortSignal) {
- const response = await get(`${API_URL}/projects-resource-warnings`, {
- signal,
- })
- if (!isResponseOk(response)) {
- throw response.error
- }
-
- return response
+ const { data, error } = await get(`/platform/projects-resource-warnings`, { signal })
+ if (error) throw error
+ return data
}
-export type ResourceWarningData = Awaited>
-export type ResourceError = unknown
+export type ResourceWarning = components['schemas']['ProjectResourceWarningsResponse']
+export type ResourceWarningsData = Awaited>
+export type ResourceWarningsError = ResponseError
-export const useResourceWarningQuery = ({
+export const useResourceWarningsQuery = ({
enabled = true,
...options
-}: UseQueryOptions = {}) =>
- useQuery(
+}: UseQueryOptions = {}) =>
+ useQuery(
usageKeys.resourceWarnings(),
({ signal }) => getResourceWarnings(signal),
- {
- enabled: enabled,
- ...options,
- }
+ { enabled, ...options }
)
diff --git a/studio/pages/project/[ref]/index.tsx b/studio/pages/project/[ref]/index.tsx
index 727d5789606..06b56fd2a10 100644
--- a/studio/pages/project/[ref]/index.tsx
+++ b/studio/pages/project/[ref]/index.tsx
@@ -4,7 +4,6 @@ import ProjectUsageSection from 'components/interfaces/Home/ProjectUsageSection'
import { ProjectLayoutWithAuth } from 'components/layouts'
import ProjectPausedState from 'components/layouts/ProjectLayout/ProjectPausedState'
import ProjectUpgradeFailedBanner from 'components/ui/ProjectUpgradeFailedBanner'
-import { useResourceWarningQuery } from 'data/usage/resource-warnings-query'
import { useSelectedProject } from 'hooks'
import { IS_PLATFORM, PROJECT_STATUS } from 'lib/constants'
import { NextPageWithLayout } from 'types'
@@ -17,9 +16,6 @@ const Home: NextPageWithLayout = () => {
? project?.name
: 'Welcome to your project'
- const { data: resourceWarnings } = useResourceWarningQuery()
-
- console.log(resourceWarnings)
return (