Skip to content

Commit

Permalink
fix: container state list name
Browse files Browse the repository at this point in the history
  • Loading branch information
m8vago committed Dec 6, 2024
1 parent 7e5ca1f commit d07b617
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion web/crux-ui/e2e/with-login/resource-copy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ test.describe('Deleting default version', () => {
const settingsButton = await page.waitForSelector(`[src="/concrete_container_config.svg"]:right-of(:text("nginx"))`)
await settingsButton.click()

await page.waitForSelector(`h2:has-text("Container")`)
await page.waitForSelector(`h2:has-text("Instance config")`)
const wsRoute = TEAM_ROUTES.deployment.detailsSocket(defaultDeploymentId)

const internal = '1000'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
containerPrefixNameOf,
ContainersStateListMessage,
DeploymentRoot,
nameOfInstance,
WatchContainerStatusMessage,
WS_TYPE_CONTAINERS_STATE_LIST,
WS_TYPE_WATCH_CONTAINERS_STATE,
Expand All @@ -26,7 +27,7 @@ export type ContainerProgress = {
progress: number
}

interface DeploymentContainerStatusListProps {
type DeploymentContainerStatusListProps = {
className?: string
deployment: DeploymentRoot
progress: Record<string, ContainerProgress>
Expand All @@ -49,7 +50,7 @@ const DeploymentContainerStatusList = (props: DeploymentContainerStatusListProps
configId: it.config.id,
id: {
prefix: deployment.prefix,
name: it.config.name ?? it.image.config.name,
name: nameOfInstance(it),
},
createdAt: null,
state: null,
Expand Down Expand Up @@ -93,9 +94,9 @@ const DeploymentContainerStatusList = (props: DeploymentContainerStatusListProps
})
}

sock.on(WS_TYPE_CONTAINERS_STATE_LIST, (message: ContainersStateListMessage) =>
setContainers(it => merge(it, message.containers)),
)
sock.on(WS_TYPE_CONTAINERS_STATE_LIST, (message: ContainersStateListMessage) => {
setContainers(it => merge(it, message.containers))
})

const formatContainerTime = (container: Container) => {
if (!container.createdAt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import DyoIcon from '@app/elements/dyo-icon'
import DyoLink from '@app/elements/dyo-link'
import DyoTable, { DyoColumn, dyoCheckboxColumn, sortDate, sortString } from '@app/elements/dyo-table'
import useTeamRoutes from '@app/hooks/use-team-routes'
import { Instance, containerNameOfInstance } from '@app/models'
import { Instance, nameOfInstance } from '@app/models'
import { utcDateToLocale } from '@app/utils'
import useTranslation from 'next-translate/useTranslation'
import { DeploymentActions, DeploymentState } from './use-deployment-state'
Expand Down Expand Up @@ -34,9 +34,9 @@ const DeploymentViewList = (props: DeploymentViewListProps) => {
header={t('containerName')}
className="w-4/12"
sortable
sortField={containerNameOfInstance}
sortField={nameOfInstance}
sort={sortString}
body={containerNameOfInstance}
body={nameOfInstance}
/>
<DyoColumn
header={t('common:registry')}
Expand Down
3 changes: 1 addition & 2 deletions web/crux-ui/src/models/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export type Instance = {
config: ConcreteContainerConfig
}

export const containerNameOfInstance = (instance: Instance) =>
instance.config.name ?? containerNameOfImage(instance.image)
export const nameOfInstance = (instance: Instance) => instance.config.name ?? containerNameOfImage(instance.image)
7 changes: 7 additions & 0 deletions web/crux/src/app/node/node.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ export class ContainerPort {
}

export class ContainerDto {
@ValidateNested()
id: ContainerIdentifierDto

@IsString()
command: string

@Type(() => Date)
Expand All @@ -208,14 +210,19 @@ export class ContainerDto {
state: ContainerState

// kubernetes reason (like crashloop backoff) or docker state
@IsString()
reason: string

@IsString()
imageName: string

@IsString()
imageTag: string

@ValidateNested({ each: true })
ports: ContainerPort[]

@IsObject()
labels: Record<string, string>
}

Expand Down

0 comments on commit d07b617

Please sign in to comment.