Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(input-image-name): default option for settings views #1778

Merged
merged 1 commit into from
Dec 5, 2024
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
fix(input-image-name): default option for setting view
  • Loading branch information
RemiBonnet committed Dec 5, 2024
commit d5ace4cfd731cfaa0d9d02ab6787daf83065b144
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function PageSettingsGeneral({
.exhaustive()}
/>
) : (
<GeneralContainerSettings organization={organization} />
<GeneralContainerSettings organization={organization} isSetting />
)}
</Section>
<Section className="gap-4">
Expand Down Expand Up @@ -191,7 +191,7 @@ export function PageSettingsGeneral({
<>
<Section className="gap-4">
<Heading>Source</Heading>
<GeneralContainerSettings organization={organization} />
<GeneralContainerSettings organization={organization} isSetting />
</Section>
<Section className="gap-4">
<Heading>Deploy</Heading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { type Organization } from 'qovery-typescript-axios'
import { Controller, useFormContext } from 'react-hook-form'
import { ContainerRegistryCreateEditModal, useContainerRegistries } from '@qovery/domains/organizations/feature'
import { SETTINGS_CONTAINER_REGISTRIES_URL, SETTINGS_URL } from '@qovery/shared/routes'
import { InputSelect, InputText, Link, useModal } from '@qovery/shared/ui'
import { InputSelect, Link, useModal } from '@qovery/shared/ui'
import ImageName from './image-name'
import { ImageTag } from './image-tag'

export interface GeneralContainerSettingsProps {
organization?: Organization
isSetting?: boolean
}

export interface ContainerFormProps {
Expand All @@ -16,7 +17,7 @@ export interface ContainerFormProps {
image_tag?: string
}

export function GeneralContainerSettings({ organization }: GeneralContainerSettingsProps) {
export function GeneralContainerSettings({ organization, isSetting }: GeneralContainerSettingsProps) {
const { control, watch } = useFormContext<ContainerFormProps>()
const { openModal, closeModal } = useModal()
const watchRegistry = watch('registry')
Expand Down Expand Up @@ -79,7 +80,12 @@ export function GeneralContainerSettings({ organization }: GeneralContainerSetti
</p>
</div>
{organization && watchRegistry && (
<ImageName control={control} organizationId={organization.id} containerRegistryId={watchRegistry} />
<ImageName
control={control}
organizationId={organization.id}
containerRegistryId={watchRegistry}
isSetting={isSetting}
/>
)}
{organization && watchRegistry && watchImageName && (
<ImageTag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@ export function ImageName({
control,
organizationId,
containerRegistryId,
isSetting,
}: {
control: Control<ContainerFormProps>
organizationId: string
containerRegistryId: string
isSetting?: boolean
}) {
const { setValue } = useFormContext()
const { data: containerRegistries = [] } = useContainerRegistries({ organizationId })
const watchImageName = useWatch({ control, name: 'image_name' }) || ''
const [customOptions, setCustomOptions] = useState<Value[]>([])
const [customOptions, setCustomOptions] = useState<Value[]>(
isSetting
? [
{
value: watchImageName,
label: watchImageName,
},
]
: []
)
const [searchParams, setSearchParams] = useState(watchImageName)
const debouncedImageName = useDebounce(searchParams, DEBOUNCE_TIME)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ export function JobGeneralSettings(props: JobGeneralSettingProps) {
(props.isEdition ? (
<div data-testid="container-fields">
<BlockContent title="Container Settings" classNameContent="space-y-4">
<GeneralContainerSettings organization={props.organization} />
<GeneralContainerSettings organization={props.organization} isSetting />
</BlockContent>
</div>
) : (
<div data-testid="container-fields" className="space-y-4">
<GeneralContainerSettings organization={props.organization} />
<GeneralContainerSettings organization={props.organization} isSetting />
</div>
))}
</>
Expand Down
Loading