Skip to content
Merged
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
5 changes: 3 additions & 2 deletions .github/workflows/test-build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
yarn nx start-ci-run \
--distribute-on="3 console-ci" \
--require-explicit-completion \
--stop-agents-on-failure=false \
--stop-agents-on-failure=true \
--with-env-vars="NX_PUBLIC_GIT_SHA,NX_PUBLIC_GTM,NX_PUBLIC_INTERCOM,NX_PUBLIC_OAUTH_AUDIENCE,NX_PUBLIC_OAUTH_DOMAIN,NX_PUBLIC_OAUTH_KEY,NX_PUBLIC_POSTHOG,NX_PUBLIC_POSTHOG_APIHOST,NX_PUBLIC_QOVERY_API,NX_PUBLIC_QOVERY_WS,NX_PUBLIC_CHARGEBEE_PUBLISHABLE_KEY,NX_PUBLIC_INSTATUS_APP_ID,NX_PUBLIC_MINTLIFY_API_KEY,NX_PUBLIC_CARGO_API_TOKEN,NX_PUBLIC_PYLON_APP_ID,NX_PUBLIC_DEVOPS_COPILOT_API_BASE_URL"

- name: Check formatting
Expand All @@ -157,7 +157,8 @@ jobs:
--ci \
--coverage \
--coverageReporters=lcov \
--silent
--maxWorkers=2 \
--forceExit

yarn nx run console:build \
--parallel=3 \
Expand Down
11 changes: 11 additions & 0 deletions apps/console/src/app/components/header/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ export function Breadcrumbs() {
}

if (currentCluster) {
breadcrumbData.push({
item: {
id: 'clusters',
label: 'Clusters',
path: buildLocation({
to: '/organization/$organizationId/clusters',
params: { organizationId },
}).href,
},
items: [],
})
breadcrumbData.push({
item: {
...currentCluster,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ function ServiceNewContent() {

return (
<Section className="flex w-full flex-1 flex-col pb-24 pt-8">
<Link
color="brand"
to="/organization/$organizationId/project/$projectId/environment/$environmentId/overview"
params={{ organizationId, projectId, environmentId }}
className="mb-8 gap-1 text-sm"
>
<Icon iconName="arrow-left" />
Back to services list
</Link>
<div className="mb-4 flex flex-col text-center">
<Heading className="mb-2 text-2xl text-neutral">Create new service</Heading>
<p className="text-sm text-neutral-subtle">
Step into the Qovery service and embrace the power of collaboration to kickstart your next project.
</p>
<div className="mx-auto flex w-full max-w-[1240px] flex-col gap-8">
<div className="flex flex-col gap-2 border-b border-neutral pb-6">
<Link
color="brand"
size="xs"
to="/organization/$organizationId/project/$projectId/environment/$environmentId/overview"
params={{ organizationId, projectId, environmentId }}
className="gap-1"
>
<Icon iconName="arrow-left" className="text-2xs" />
Back to services list
</Link>
<Heading className="text-2xl leading-8 text-neutral">Create new service</Heading>
</div>
<ServiceNew
organizationId={organizationId}
projectId={projectId}
environmentId={environmentId}
cloudProvider={cloudProvider}
availableTemplates={availableTemplates}
/>
</div>
<ServiceNew
organizationId={organizationId}
projectId={projectId}
environmentId={environmentId}
cloudProvider={cloudProvider}
availableTemplates={availableTemplates}
/>
</Section>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ interface EditGitRepositorySettingsProps {
gitRepository?: ApplicationGitRepository
rootPathLabel?: string
rootPathHint?: string
showEditAction?: boolean
}

export function EditGitRepositorySettings({
organizationId,
gitRepository,
rootPathHint,
rootPathLabel,
showEditAction = true,
}: EditGitRepositorySettingsProps) {
const { setValue } = useFormContext<{
provider: GitProviderEnum | undefined
Expand Down Expand Up @@ -52,7 +54,7 @@ export function EditGitRepositorySettings({
return (
<GitRepositorySettings
gitDisabled={gitDisabled}
editGitSettings={editGitSettings}
editGitSettings={showEditAction ? editGitSettings : undefined}
currentProvider={gitRepository?.provider}
currentRepository={gitRepository?.name}
urlRepository={gitRepository?.url}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import { organizationFactoryMock, terraformFactoryMock } from '@qovery/shared/fa
import { renderWithProviders, screen } from '@qovery/shared/util-tests'
import { TerraformGeneralSettings } from './terraform-general-settings'

const mockEditGitRepositorySettings = jest.fn()

jest.mock('@qovery/domains/organizations/feature', () => ({
EditGitRepositorySettings: () => null,
EditGitRepositorySettings: (props: unknown) => {
mockEditGitRepositorySettings(props)
return null
},
}))

jest.mock('@qovery/domains/services/feature', () => ({
Expand All @@ -31,4 +36,20 @@ describe('TerraformGeneralSettings', () => {
expect(screen.getByText('Source')).toBeInTheDocument()
expect(screen.getByText('Build and deploy')).toBeInTheDocument()
})

it('hides the source edit action for blueprint services', () => {
renderWithProviders(
wrapWithReactHookForm(
<TerraformGeneralSettings service={{ ...service, blueprint_id: 'blueprint-id' }} organization={organization} />,
{
defaultValues: {
name: service.name,
terraform_action: TerraformAutoDeployConfigTerraformActionEnum.DEFAULT,
},
}
)
)

expect(mockEditGitRepositorySettings).toHaveBeenLastCalledWith(expect.objectContaining({ showEditAction: false }))
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function TerraformGeneralSettings({ service, organization }: TerraformGen
gitRepository={service.terraform_files_source?.git?.git_repository}
rootPathLabel="Terraform root folder path"
rootPathHint="Provide the folder path where the Terraform code is located in the repository."
showEditAction={!service.blueprint_id}
/>
</Section>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ export type ArgoCd = _ArgoCd & {
serviceType: ArgoCdType
}
export type AnyService = Application | Database | Container | Job | Helm | Terraform | ArgoCd
export type BlueprintService = AnyService & {
blueprint_id: string
tag?: string
}
export type ReadOnlyService = ArgoCd
export type EditableService = Exclude<AnyService, ReadOnlyService>
export type EditableServiceType = Exclude<ServiceType, ArgoCdType>
Expand Down Expand Up @@ -225,6 +229,10 @@ export function isHelm(service: AnyService): service is Helm {
return service.service_type === 'HELM'
}

export function isBlueprintService(service: AnyService): service is BlueprintService {
return 'blueprint_id' in service && Boolean(service.blueprint_id)
}

export function isArgoCd(service?: AnyService): service is ArgoCd {
return service?.service_type === 'ARGOCD_APP'
}
Expand Down Expand Up @@ -780,6 +788,10 @@ type UpdateBlueprintRequest = {
payload: BlueprintUpdateRequest
}

type DeployBlueprintRequest = {
blueprintId: string
}

type EditServiceRequest = {
serviceId: string
payload:
Expand Down Expand Up @@ -1061,6 +1073,10 @@ export const mutations = {
const response = await blueprintApi.updateBlueprint(blueprintId, payload)
return response.data
},
async deployBlueprint({ blueprintId }: DeployBlueprintRequest) {
const response = await blueprintApi.deployBlueprint(blueprintId)
return response.data
},
async editService({ serviceId, payload }: EditServiceRequest) {
const { mutation } = match(payload)
.with({ serviceType: 'APPLICATION' }, ({ serviceType, ...payload }) => ({
Expand Down
2 changes: 1 addition & 1 deletion libs/domains/services/feature/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export * from './lib/service-creation-flow/database/step-resources/step-resource
export * from './lib/service-creation-flow/database/database-summary-view/database-summary-view'
export * from './lib/service-creation-flow/database/step-summary/step-summary'
export * from './lib/service-creation-flow/blueprint/blueprint-creation-flow'
export * from './lib/service-update-flow/blueprint/blueprint-update-flow'
export * from './lib/service-blueprint-update-flow/blueprint-update-flow'
export * from './lib/application-container-healthchecks/application-container-healthchecks-form/application-container-healthchecks-form'
export * from './lib/application-container-healthchecks/healthchecks-utils'
export * from './lib/application-container-healthchecks/step-healthchecks/step-healthchecks'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('BlueprintDetailsPanel', () => {
expect(within(dialog).getByText('Object storage with server-side encryption.')).toBeInTheDocument()
expect(within(dialog).getByText('AWS')).toBeInTheDocument()
expect(within(dialog).getByText('v1')).toBeInTheDocument()
expect(within(dialog).getAllByText('AWS S3 Bucket')).toHaveLength(1)
expect(dialog).toHaveTextContent('Blueprint documentation')
expect(dialog).toHaveTextContent('Versioning')
expect(within(dialog).getByRole('link', { name: /qovery-blueprints\/s3/i })).toHaveAttribute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { type BlueprintItem, type BlueprintReadmeResponse } from 'qovery-typescr
import Markdown from 'react-markdown'
import remarkGfm from 'remark-gfm'
import { formatCloudProvider } from '@qovery/domains/clusters/data-access'
import { Badge, Button, ExternalLink, Icon, Link, Sheet } from '@qovery/shared/ui'
import { Badge, Button, ExternalLink, Heading, Icon, Link, Sheet } from '@qovery/shared/ui'
import { twMerge } from '@qovery/shared/util-js'
import { BlueprintQueryBoundary } from '../blueprint-query-boundary/blueprint-query-boundary'
import { formatBlueprintName } from '../blueprint-utils/blueprint-utils'
import { useBlueprintCatalogServiceReadme } from '../hooks/use-blueprint-catalog-service-readme/use-blueprint-catalog-service-readme'
import { ServiceAvatar } from '../service-avatar/service-avatar'

Expand All @@ -19,24 +20,26 @@ interface BlueprintReadmeContentProps {
}

function BlueprintReadmeContent({ content }: BlueprintReadmeContentProps) {
const contentWithoutTitle = content.replace(/^#\s+[^\r\n]+(?:\r?\n)*/, '')

return (
<Markdown
remarkPlugins={[remarkGfm]}
components={{
h1: ({ node, children, ...props }) => (
<h1 className="mb-4 text-2xl font-medium leading-8 text-neutral" {...props}>
<Heading level={1} {...props}>
{children}
</h1>
</Heading>
),
h2: ({ node, children, ...props }) => (
<h2 className="mb-3 mt-6 text-lg font-medium leading-7 text-neutral" {...props}>
<Heading level={2} {...props}>
{children}
</h2>
</Heading>
),
h3: ({ node, children, ...props }) => (
<h3 className="mb-2 mt-5 text-base font-medium leading-6 text-neutral" {...props}>
<Heading level={3} {...props}>
{children}
</h3>
</Heading>
),
p: ({ node, ...props }) => <p className="my-3 text-sm leading-6 text-neutral" {...props} />,
a: ({ node, children, ...props }) => (
Expand Down Expand Up @@ -64,12 +67,14 @@ function BlueprintReadmeContent({ content }: BlueprintReadmeContentProps) {
</div>
),
th: ({ node, ...props }) => (
<th className="border-b border-r border-neutral px-3 py-2 text-left font-medium" {...props} />
<th className="border-r border-neutral px-3 py-2 text-left font-medium last:border-r-0" {...props} />
),
td: ({ node, ...props }) => (
<td className="border-r border-t border-neutral px-3 py-2 last:border-r-0" {...props} />
),
td: ({ node, ...props }) => <td className="border-b border-r border-neutral px-3 py-2" {...props} />,
}}
>
{content}
{contentWithoutTitle}
</Markdown>
)
}
Expand Down Expand Up @@ -156,6 +161,7 @@ function BlueprintDetailsPanelContent({
const canDeploy = footerMode === 'deploy' && Boolean(blueprint.serviceFamily)

const provider = formatCloudProvider(blueprint.provider)
const blueprintName = formatBlueprintName(blueprint.name)

return (
<Dialog.Root open={open} onOpenChange={onOpenChange}>
Expand All @@ -171,7 +177,7 @@ function BlueprintDetailsPanelContent({
<div className="mb-8 flex flex-col gap-5">
<div className="flex flex-col gap-2">
<Dialog.Title
aria-label={blueprint.name}
aria-label={blueprintName}
className="flex items-center gap-3 pr-8 text-2xl font-medium leading-8 text-neutral"
>
<ServiceAvatar
Expand All @@ -181,7 +187,7 @@ function BlueprintDetailsPanelContent({
serviceAvatarRadius="sm"
size="custom"
/>
<span>{blueprint.name}</span>
<span>{blueprintName}</span>
</Dialog.Title>
<Dialog.Description className="text-sm leading-5 text-neutral-subtle">
{blueprint.description}
Expand All @@ -200,14 +206,12 @@ function BlueprintDetailsPanelContent({
</div>
</div>

<div className="rounded border border-neutral bg-surface-neutral p-5">
<BlueprintQueryBoundary
resetKeys={[organizationId, blueprint.provider, blueprint.serviceFamily, serviceVersion]}
title="blueprint details"
>
<BlueprintReadme blueprint={blueprint} serviceVersion={serviceVersion} />
</BlueprintQueryBoundary>
</div>
<BlueprintQueryBoundary
resetKeys={[organizationId, blueprint.provider, blueprint.serviceFamily, serviceVersion]}
title="blueprint details"
>
<BlueprintReadme blueprint={blueprint} serviceVersion={serviceVersion} />
</BlueprintQueryBoundary>
</div>

<Dialog.Close asChild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getDefaultContextFieldValue,
getDefaultFieldValue,
getFieldLengthValidationError,
getFieldNumberValidationError,
getFieldValidationError,
getStringFieldValue,
getSummaryFieldValue,
Expand Down Expand Up @@ -166,6 +167,20 @@ describe('field validation', () => {
expect(getFieldLengthValidationError(rangeField, false)).toBeUndefined()
})

it('validates numeric minimum and maximum values', () => {
const rangeField = createVariableField({ type: { type: 'number', min: 20, max: 65536 } })
const minField = createVariableField({ type: { type: 'number', min: 20 } })
const maxField = createVariableField({ type: { type: 'number', max: 65536 } })

expect(getFieldNumberValidationError(rangeField, '19')).toBe('Value must be between 20 and 65536.')
expect(getFieldNumberValidationError(rangeField, '65537')).toBe('Value must be between 20 and 65536.')
expect(getFieldNumberValidationError(rangeField, '20')).toBeUndefined()
expect(getFieldNumberValidationError(rangeField, '65536')).toBeUndefined()
expect(getFieldNumberValidationError(minField, '19')).toBe('Value must be at least 20.')
expect(getFieldNumberValidationError(maxField, '65537')).toBe('Value must be at most 65536.')
expect(getFieldNumberValidationError(rangeField, 'not-a-number')).toBe('Value must be a number.')
})

it('prioritizes length errors before pattern errors', () => {
const field = createVariableField({ type: { type: 'string', min_length: 2, pattern: '^value$' } })

Expand All @@ -174,6 +189,12 @@ describe('field validation', () => {
expect(getFieldValidationError(field, 'value')).toBeUndefined()
})

it('returns numeric validation errors', () => {
const field = createVariableField({ type: { type: 'number', min: 20, max: 65536 } })

expect(getFieldValidationError(field, '19')).toBe('Value must be between 20 and 65536.')
})

it('requires a fulfilled value only for required fields', () => {
const requiredField = createVariableField({ required: true })
const optionalField = createVariableField({ required: false })
Expand Down
Loading
Loading