diff --git a/apps/console-v5/src/routes/_authenticated/organization/$organizationId/project/$projectId/environment/$environmentId/service/$serviceId/settings/terraform-arguments.tsx b/apps/console-v5/src/routes/_authenticated/organization/$organizationId/project/$projectId/environment/$environmentId/service/$serviceId/settings/terraform-arguments.tsx
index 7a0d564518f..5869d3592a9 100644
--- a/apps/console-v5/src/routes/_authenticated/organization/$organizationId/project/$projectId/environment/$environmentId/service/$serviceId/settings/terraform-arguments.tsx
+++ b/apps/console-v5/src/routes/_authenticated/organization/$organizationId/project/$projectId/environment/$environmentId/service/$serviceId/settings/terraform-arguments.tsx
@@ -1,4 +1,5 @@
import { createFileRoute } from '@tanstack/react-router'
+import { TerraformArgumentsSettings } from '@qovery/domains/service-settings/feature'
export const Route = createFileRoute(
'/_authenticated/organization/$organizationId/project/$projectId/environment/$environmentId/service/$serviceId/settings/terraform-arguments'
@@ -7,5 +8,5 @@ export const Route = createFileRoute(
})
function RouteComponent() {
- return
Terraform arguments
+ return
}
diff --git a/libs/domains/service-settings/feature/src/index.ts b/libs/domains/service-settings/feature/src/index.ts
index 7ad02a8214f..9bef3cb849a 100644
--- a/libs/domains/service-settings/feature/src/index.ts
+++ b/libs/domains/service-settings/feature/src/index.ts
@@ -8,3 +8,4 @@ export * from './lib/application-container-storage-settings/application-containe
export * from './lib/service-domain-settings/service-domain-settings/service-domain-settings'
export * from './lib/service-deployment-restrictions-settings/service-deployment-restrictions-settings/service-deployment-restrictions-settings'
export * from './lib/terraform-configuration-settings/terraform-configuration-settings'
+export * from './lib/terraform-arguments-settings/terraform-arguments-settings'
diff --git a/libs/pages/application/src/lib/feature/page-settings-terraform-arguments-feature/page-settings-terraform-arguments-feature.spec.tsx b/libs/domains/service-settings/feature/src/lib/terraform-arguments-settings/terraform-arguments-settings.spec.tsx
similarity index 88%
rename from libs/pages/application/src/lib/feature/page-settings-terraform-arguments-feature/page-settings-terraform-arguments-feature.spec.tsx
rename to libs/domains/service-settings/feature/src/lib/terraform-arguments-settings/terraform-arguments-settings.spec.tsx
index e02c700a2cd..a030a7392b6 100644
--- a/libs/pages/application/src/lib/feature/page-settings-terraform-arguments-feature/page-settings-terraform-arguments-feature.spec.tsx
+++ b/libs/domains/service-settings/feature/src/lib/terraform-arguments-settings/terraform-arguments-settings.spec.tsx
@@ -1,12 +1,28 @@
import { wrapWithReactHookForm } from '__tests__/utils/wrap-with-react-hook-form'
+import { type ReactNode } from 'react'
import * as servicesDomain from '@qovery/domains/services/feature'
import { terraformFactoryMock } from '@qovery/shared/factories'
import { renderWithProviders, screen } from '@qovery/shared/util-tests'
-import { PageSettingsTerraformArgumentsFeature } from './page-settings-terraform-arguments-feature'
+import { TerraformArgumentsSettings } from './terraform-arguments-settings'
const useServiceSpy = jest.spyOn(servicesDomain, 'useService') as jest.Mock
const useEditServiceSpy = jest.spyOn(servicesDomain, 'useEditService') as jest.Mock
+jest.mock('@tanstack/react-router', () => ({
+ ...jest.requireActual('@tanstack/react-router'),
+ useParams: () => ({ organizationId: '1' }),
+ useNavigate: () => jest.fn(),
+ useLocation: () => ({ pathname: '/', search: '' }),
+ useRouter: () => ({
+ buildLocation: () => ({ href: '/' }),
+ }),
+ Link: ({ children, ...props }: { children?: ReactNode; [key: string]: unknown }) => (
+
+ {children}
+
+ ),
+}))
+
jest.mock('@qovery/domains/variables/feature', () => ({
...jest.requireActual('@qovery/domains/variables/feature'),
DropdownVariable: ({ children, onChange }: { children: React.ReactNode; onChange: (value: string) => void }) => (
@@ -41,12 +57,12 @@ describe('PageSettingsTerraformArgumentsFeature', () => {
})
it('should render', () => {
- const { baseElement } = renderWithProviders(wrapWithReactHookForm())
+ const { baseElement } = renderWithProviders(wrapWithReactHookForm())
expect(baseElement).toBeTruthy()
})
it('should correctly submit the form', async () => {
- const { userEvent } = renderWithProviders(wrapWithReactHookForm())
+ const { userEvent } = renderWithProviders(wrapWithReactHookForm())
const submitButton = screen.getByText('Save')
const inputLabelForApply = screen.getByText('Arguments for apply')
const inputLabelForDestroy = screen.getByText('Arguments for destroy')
@@ -89,7 +105,7 @@ describe('PageSettingsTerraformArgumentsFeature', () => {
})
it('should render variable interpolation wand button for each command', () => {
- renderWithProviders(wrapWithReactHookForm())
+ renderWithProviders(wrapWithReactHookForm())
// Check that the wand button appears for each terraform command
const wandButtons = screen.getAllByTestId('dropdown-variable')
@@ -97,7 +113,7 @@ describe('PageSettingsTerraformArgumentsFeature', () => {
})
it('should add variable interpolation to empty input when wand is clicked', async () => {
- const { userEvent } = renderWithProviders(wrapWithReactHookForm())
+ const { userEvent } = renderWithProviders(wrapWithReactHookForm())
const inputLabelForPlan = screen.getByText('Arguments for plan')
const inputForPlan = inputLabelForPlan.closest('div')?.querySelector('input')
@@ -114,7 +130,7 @@ describe('PageSettingsTerraformArgumentsFeature', () => {
})
it('should append variable interpolation to existing input when wand is clicked', async () => {
- const { userEvent } = renderWithProviders(wrapWithReactHookForm())
+ const { userEvent } = renderWithProviders(wrapWithReactHookForm())
// Get the input for init command (which has default value '-auto-approve')
const inputLabelForInit = screen.getByText('Arguments for init')
@@ -133,7 +149,7 @@ describe('PageSettingsTerraformArgumentsFeature', () => {
})
it('should correctly submit form with variable interpolation', async () => {
- const { userEvent } = renderWithProviders(wrapWithReactHookForm())
+ const { userEvent } = renderWithProviders(wrapWithReactHookForm())
// Get the apply input and add a variable using the wand
const inputLabelForApply = screen.getByText('Arguments for apply')
diff --git a/libs/pages/application/src/lib/feature/page-settings-terraform-arguments-feature/page-settings-terraform-arguments-feature.tsx b/libs/domains/service-settings/feature/src/lib/terraform-arguments-settings/terraform-arguments-settings.tsx
similarity index 59%
rename from libs/pages/application/src/lib/feature/page-settings-terraform-arguments-feature/page-settings-terraform-arguments-feature.tsx
rename to libs/domains/service-settings/feature/src/lib/terraform-arguments-settings/terraform-arguments-settings.tsx
index a71c90966b7..fc238d757b0 100644
--- a/libs/pages/application/src/lib/feature/page-settings-terraform-arguments-feature/page-settings-terraform-arguments-feature.tsx
+++ b/libs/domains/service-settings/feature/src/lib/terraform-arguments-settings/terraform-arguments-settings.tsx
@@ -1,8 +1,9 @@
+import { useParams } from '@tanstack/react-router'
import { Controller, FormProvider, useForm } from 'react-hook-form'
-import { useParams } from 'react-router-dom'
+import { type Terraform } from '@qovery/domains/services/data-access'
import { useEditService, useService } from '@qovery/domains/services/feature'
import { DropdownVariable } from '@qovery/domains/variables/feature'
-import { NeedHelp } from '@qovery/shared/assistant/feature'
+import { SettingsHeading } from '@qovery/shared/console-shared'
import { Button, Heading, Icon, InputText, Section } from '@qovery/shared/ui'
import { twMerge } from '@qovery/shared/util-js'
import { buildEditServicePayload } from '@qovery/shared/util-services'
@@ -15,8 +16,10 @@ const commands = [
hint: (
Example:{' '}
- -lock=false -upgrade.
- Arguments are separated by a space.
+
+ -lock=false -upgrade
+
+ . Arguments are separated by a space.
),
},
@@ -25,9 +28,10 @@ const commands = [
description: 'Check whether the configuration is valid.',
hint: (
- Example: -json or{' '}
- -no-color. Arguments are
- separated by a space.
+ Example:{' '}
+ -json or{' '}
+ -no-color
+ . Arguments are separated by a space.
),
},
@@ -36,8 +40,11 @@ const commands = [
description: 'Show changes required by the current configuration.',
hint: (
- Example: -refresh=false.
- Arguments are separated by a space.
+ Example:{' '}
+
+ -refresh=false
+
+ . Arguments are separated by a space.
),
},
@@ -46,8 +53,11 @@ const commands = [
description: 'Create or update infrastructure.',
hint: (
- Example: -auto-approve.
- Arguments are separated by a space.
+ Example:{' '}
+
+ -auto-approve
+
+ . Arguments are separated by a space.
),
},
@@ -56,16 +66,16 @@ const commands = [
description: 'Destroy previously-created infrastructure.',
hint: (
- Example: -target.
+ Example:{' '}
+ -target.
Arguments are separated by a space.
),
},
]
-export function PageSettingsTerraformArgumentsFeature() {
- const { organizationId = '', projectId = '', environmentId = '', applicationId = '' } = useParams()
- const { data: service } = useService({ serviceId: applicationId })
+const TerraformArgumentsSettingsContent = ({ service }: { service: Terraform }) => {
+ const { organizationId = '', projectId = '', environmentId = '' } = useParams({ strict: false })
const { mutate: editService, isLoading: isLoadingEditService } = useEditService({
organizationId,
projectId,
@@ -85,50 +95,46 @@ export function PageSettingsTerraformArgumentsFeature() {
})
const onSubmit = methods.handleSubmit((data) => {
- if (!service || !data) return
+ if (!data) return
- if (service.serviceType === 'TERRAFORM') {
- const payload = buildEditServicePayload({
- service,
- request: {
- action_extra_arguments: {
- init: data['init'] ?? [],
- validate: data['validate'] ?? [],
- plan: data['plan'] ?? [],
- apply: data['apply'] ?? [],
- destroy: data['destroy'] ?? [],
- },
+ const payload = buildEditServicePayload({
+ service,
+ request: {
+ action_extra_arguments: {
+ init: data['init'] ?? [],
+ validate: data['validate'] ?? [],
+ plan: data['plan'] ?? [],
+ apply: data['apply'] ?? [],
+ destroy: data['destroy'] ?? [],
},
- })
+ },
+ })
- editService({
- serviceId: service.id,
- payload,
- })
- }
+ editService({
+ serviceId: service.id,
+ payload,
+ })
})
return (
-
-
-
-
- Terraform arguments
- Configure the arguments passed to each Terraform command.
-
-
-
+
+
+
+
Commands
-
Specify additional arguments for each Terraform command.
+
Specify additional arguments for each Terraform command.
{commands.map((command) => (
-
+
-
{command.name}
-
{command.description}
+
{command.name}
+
{command.description}
-
-
+
+
)
}
+
+export function TerraformArgumentsSettings() {
+ const { serviceId = '' } = useParams({ strict: false })
+ const { data: service } = useService({ serviceId, suspense: true })
+
+ if (service?.serviceType !== 'TERRAFORM') return null
+
+ return
+}