Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ export const environments = createQueryKeys('environments', {
)
},
}),
// TODO [To update once rust-backed will be deployed]: To remove
// NOTE: Value is set by WebSocket
checkRunningStatusClosed: (clusterId: string) => ({
queryKey: [clusterId],
queryFn() {
// eslint-disable-next-line @typescript-eslint/no-empty-function
return new Promise<{ clusterId: string; reason: string }>(() => {})
},
}),
details: ({ environmentId }: { environmentId: string }) => ({
queryKey: [environmentId],
async queryFn() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import { twMerge, upperCaseFirstLetter } from '@qovery/shared/util-js'
import { CreateCloneEnvironmentModal } from '../create-clone-environment-modal/create-clone-environment-modal'
import { EnvironmentActionToolbar } from '../environment-action-toolbar/environment-action-toolbar'
import { EnvironmentMode } from '../environment-mode/environment-mode'
import { useCheckRunningStatusClosed } from '../hooks/use-check-running-status-closed/use-check-running-status-closed'
import { useEnvironments } from '../hooks/use-environments/use-environments'
import { EnvironmentListSkeleton } from './environment-list-skeleton'

Expand Down Expand Up @@ -88,30 +87,6 @@ function EnvironmentStatusCell({
runningStatus?: RunningState
value?: string
}) {
const { data: checkRunningStatusClosed } = useCheckRunningStatusClosed({
clusterId: environment.cluster_id,
})
// TODO [To update once rust-backed will be deployed]: To remove
if (checkRunningStatusClosed) {
return (
<Tooltip content="See cluster">
<Link
as="button"
to={CLUSTER_URL(environment.organization.id, environment.cluster_id)}
onClick={(e) => e.stopPropagation()}
className="gap-2 whitespace-nowrap text-sm"
size="md"
color="neutral"
variant="outline"
radius="full"
>
<StatusChip status="UNAVAILABLE" />
Status unavailable
</Link>
</Tooltip>
)
}

return (
<Skeleton width={102} height={34} show={!value}>
<Tooltip content="See overview">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Skeleton, StatusChip, type StatusChipProps } from '@qovery/shared/ui'
import { useCheckRunningStatusClosed } from '../hooks/use-check-running-status-closed/use-check-running-status-closed'
import { useDeploymentStatus } from '../hooks/use-deployment-status/use-deployment-status'
import { useEnvironment } from '../hooks/use-environment/use-environment'
import { useRunningStatus } from '../hooks/use-running-status/use-running-status'

/**
Expand Down Expand Up @@ -45,17 +43,7 @@ function DeploymentStateChip({ environmentId, mode, ...props }: DeploymentStateC
type RunningStateChipProps = Omit<EnvironmentStateChipProps, 'mode'>

function RunningStateChip({ environmentId, ...props }: RunningStateChipProps) {
const { data: environment } = useEnvironment({ environmentId })
const { data: runningStatus } = useRunningStatus({ environmentId })
const { data: checkRunningStatusClosed } = useCheckRunningStatusClosed({
clusterId: environment?.cluster_id ?? '',
})

// TODO [To update once rust-backed will be deployed]: To remove
if (checkRunningStatusClosed) {
return <StatusChip status="STOPPED" {...props} />
}

return (
<Skeleton width={16} height={16} show={!runningStatus?.state} rounded>
<StatusChip status={runningStatus?.state} {...props} />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,6 @@ export const services = createQueryKeys('services', {
return new Promise<ApplicationStatusDto | DatabaseStatusDto | TerraformStatusDto | null>(() => {})
},
}),
// TODO [To update once rust-backed will be deployed]: To remove
checkRunningStatusClosed: (clusterId: string, environmentId: string) => ({
queryKey: [clusterId, environmentId],
// NOTE: Value is set by WebSocket
queryFn() {
// eslint-disable-next-line @typescript-eslint/no-empty-function
return new Promise<{ clusterId: string; environmentId: string; reason: string }>(() => {})
},
}),
metrics: (environmentId: string, serviceId: string) => ({
queryKey: [environmentId, serviceId],
// NOTE: Value is set by WebSocket
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
import {
APPLICATION_GENERAL_URL,
APPLICATION_URL,
CLUSTER_URL,
DATABASE_GENERAL_URL,
DATABASE_URL,
DEPLOYMENT_LOGS_VERSION_URL,
Expand Down Expand Up @@ -74,7 +73,6 @@ import {
twMerge,
upperCaseFirstLetter,
} from '@qovery/shared/util-js'
import { useCheckRunningStatusClosed } from '../hooks/use-check-running-status-closed/use-check-running-status-closed'
import { useListDeploymentStages } from '../hooks/use-list-deployment-stages/use-list-deployment-stages'
import { useServices } from '../hooks/use-services/use-services'
import { LastCommit } from '../last-commit/last-commit'
Expand Down Expand Up @@ -334,10 +332,6 @@ export function ServiceList({ environment, className, ...props }: ServiceListPro
} = environment
const { data: services = [], isLoading: isServicesLoading } = useServices({ environmentId })
const { data: deploymentStages } = useListDeploymentStages({ environmentId })
const { data: checkRunningStatusClosed } = useCheckRunningStatusClosed({
clusterId,
environmentId,
})
const [sorting, setSorting] = useState<SortingState>([])
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
const navigate = useNavigate()
Expand Down Expand Up @@ -495,27 +489,6 @@ export function ServiceList({ environment, className, ...props }: ServiceListPro
.with(undefined, () => info.getValue())
.exhaustive()

// TODO [To update once rust-backed will be deployed]: Remove this workaround
if (checkRunningStatusClosed) {
return (
<Tooltip content="See cluster">
<Link
as="button"
to={CLUSTER_URL(organizationId, environment.cluster_id)}
onClick={(e) => e.stopPropagation()}
className="gap-2 whitespace-nowrap text-sm"
size="md"
color="neutral"
variant="outline"
radius="full"
>
<StatusChip status="UNAVAILABLE" />
Status unavailable
</Link>
</Tooltip>
)
}

const serviceStatus = match(service)
.with({ serviceType: 'DATABASE', mode: 'MANAGED' }, (s) => s.deploymentStatus?.state)
.otherwise((s) => s.runningStatus?.state)
Expand Down Expand Up @@ -779,7 +752,7 @@ export function ServiceList({ environment, className, ...props }: ServiceListPro
},
}),
],
[columnHelper, organizationId, projectId, environmentId, navigate, checkRunningStatusClosed, environment]
[columnHelper, organizationId, projectId, environmentId, environment]
)

const table = useReactTable({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import equal from 'fast-deep-equal'
import { type EnvironmentStatus, type EnvironmentStatusesWithStages } from 'qovery-typescript-axios'
import {
type ApplicationStatusDto,
Expand Down Expand Up @@ -89,14 +90,13 @@ export function useStatusWebSockets({
enabled: Boolean(organizationId) && Boolean(clusterId) && Boolean(projectId),
onMessage(queryClient, message: ServiceStatusDto) {
for (const env of message.environments) {
// TODO [To update once rust-backed will be deployed]: check against current value and update it only if it has changed (to avoid too many re-render)
queryClient.setQueryData(queries.environments.runningStatus(env.id).queryKey, () => ({
state: env.state,
}))
// // NOTE: we have to force this reset change because of the way the socket works.
// // You can have information about an service (eg. if it's stopping)
// TODO [To update once rust-backed will be deployed]: Remove reset cache strategy
queryClient.resetQueries([...queries.services.runningStatus._def, env.id])
// Setting the environment status only if it has changed
const currentEnvironmentStatus = queryClient.getQueryData(queries.environments.runningStatus(env.id).queryKey)
const newEnvironmentStatus = { state: env.state }
if (!equal(newEnvironmentStatus, currentEnvironmentStatus)) {
queryClient.setQueryData(queries.environments.runningStatus(env.id).queryKey, () => newEnvironmentStatus)
}

const services: (ApplicationStatusDto | DatabaseStatusDto | TerraformStatusDto)[] = [
...env.applications,
...env.containers,
Expand All @@ -106,30 +106,16 @@ export function useStatusWebSockets({
...env.terraform,
]
for (const serviceRunningStatus of services) {
// TODO [To update once rust-backed will be deployed]: check against current value and update it only if it has changed (to avoid too many re-render)
queryClient.setQueryData(
queries.services.runningStatus(env.id, serviceRunningStatus.id).queryKey,
() => serviceRunningStatus
// Setting the service status only if it has changed
const currentServiceStatus = queryClient.getQueryData(
queries.services.runningStatus(env.id, serviceRunningStatus.id).queryKey
)
}
}
},
onClose(queryClient, event: CloseEvent) {
// NOTE: API returns a string for the reason, which allows us to know if the status is available or not
// clusterId is required everywhere and environmentId is necessary for the service list
const isNotFound = event.reason.includes('NotFound') || event.reason.includes('not found')
if (isNotFound && clusterId) {
if (environmentId) {
queryClient.setQueryData(queries.services.checkRunningStatusClosed(clusterId, environmentId).queryKey, {
clusterId,
environmentId,
reason: event.reason,
})
} else {
queryClient.setQueryData(queries.environments.checkRunningStatusClosed(clusterId).queryKey, {
clusterId,
reason: event.reason,
})
if (!equal(serviceRunningStatus, currentServiceStatus)) {
queryClient.setQueryData(
queries.services.runningStatus(env.id, serviceRunningStatus.id).queryKey,
() => serviceRunningStatus
)
}
}
}
},
Expand Down
Loading