Skip to content

Commit

Permalink
squashme: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
olevski committed Feb 4, 2025
1 parent 10baaf4 commit a5d23a6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,18 +315,6 @@ export function DataConnectorMount({ project }: AddOrEditDataConnectorProps) {
const fields: Partial<typeof field> = { ...field };
delete fields?.ref;
return (
//<DataConnectorNamespaceControl
// {...fields}
// projectId={projectId || ""}
// className={cx(errors.namespace && "is-invalid")}
// data-cy={"data-controller-namespace-input"}
// id="namespace"
// inputId="namespace-input"
// onChange={(e) => {
// field.onChange(e);
// onFieldValueChange("namespace", e?.value || "");
// }}
///>
<ProjectNamespaceControl
{...fields}
className={cx(errors.namespace && "is-invalid")}
Expand All @@ -338,9 +326,6 @@ export function DataConnectorMount({ project }: AddOrEditDataConnectorProps) {
onFieldValueChange("namespace", e?.slug ?? "");
}}
project={project}
value={
project ? `${project.namespace}/${project.slug}` : undefined
}
/>
);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function DataConnectorModalBodyAndFooter({
if (dataConnector == null) {
flattened = {
...flattened,
namespace,
namespace: project ? `${project.namespace}/${project.slug}` : namespace,
visibility: project?.visibility ?? "private",
};
}
Expand All @@ -91,7 +91,7 @@ export function DataConnectorModalBodyAndFooter({
schemata: schemata ?? [],
})
);
}, [dataConnector, dispatch, namespace, project?.visibility, schemata]);
}, [dataConnector, dispatch, namespace, project, schemata]);

// Visual elements
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ export interface AddStorageStepProps {
storageSecrets: CloudStorageSecretGet[];
isV2?: boolean;
validationSucceeded: boolean;
projectId?: string;
}

const mapStepToElement: {
Expand Down Expand Up @@ -1039,7 +1038,6 @@ export function AddStorageMount({
storage,
state,
validationSucceeded,
projectId,
}: AddStorageStepProps) {
const {
control,
Expand Down
44 changes: 21 additions & 23 deletions client/src/features/projectsV2/fields/ProjectNamespaceFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ interface NamespaceSelectorProps {
namespaces: ResponseNamespaces;
onChange?: (newValue: SingleValue<ResponseNamespace>) => void;
onFetchMore?: () => void;
project?: Project;
}

function NamespaceSelector({
Expand All @@ -149,27 +148,10 @@ function NamespaceSelector({
namespaces,
onChange,
onFetchMore,
project,
}: NamespaceSelectorProps) {
const namespaceOptions = useMemo(() => {
if (!project) {
return namespaces;
}
return [
{
id: project.id,
name: project.name,
slug: `${project.namespace}/${project.slug}`,
created_by: project.created_by,
creation_date: project.creation_date,
namespace_kind: "project",
} as NamespaceResponse,
...namespaces,
];
}, [namespaces, project]);
const currentValue = useMemo(
() => namespaceOptions.find(({ slug }) => slug === currentNamespace),
[namespaceOptions, currentNamespace]
() => namespaces.find(({ slug }) => slug === currentNamespace),
[namespaces, currentNamespace]
);

const components = useMemo(
Expand All @@ -183,7 +165,7 @@ function NamespaceSelector({
return (
<Select
inputId={inputId}
options={namespaceOptions}
options={namespaces}
value={currentValue}
unstyled
getOptionValue={(option) => option.id}
Expand Down Expand Up @@ -415,6 +397,23 @@ export function ProjectNamespaceControl({
});
}, [allNamespaces, specificNamespace, specificNamespaceRequestId]);

const allNamespacesWithProject = useMemo(() => {
if (!project) {
return allNamespaces || [];
}
return [
{
id: project.id,
slug: `${project.namespace}/${project.slug}`,
creation_date: project.creation_date,
created_by: project.created_by,
namespace_kind: "project",
name: `${project.namespace}/${project.slug}`,
} as NamespaceResponse,
...(allNamespaces || []),
];
}, [allNamespaces, project]);

if (isFetching) {
return (
<div className={cx(className, "form-control")} id={id}>
Expand All @@ -441,10 +440,9 @@ export function ProjectNamespaceControl({
hasMore={hasMore}
inputId={inputId}
isFetchingMore={namespacesPageResult.isFetching}
namespaces={allNamespaces}
namespaces={allNamespacesWithProject}
onChange={onChange}
onFetchMore={onFetchMore}
project={project}
/>
</div>
);
Expand Down

0 comments on commit a5d23a6

Please sign in to comment.