Skip to content

Commit

Permalink
Use null rather than empty string for unspecified namespace
Browse files Browse the repository at this point in the history
It's possible for (arguably misformed) package metadata to have the
empty string as the namespace. This can happen for example when
ingesting an OCI image that does not have the correct repository URL
specified.

Currently guac-visualiser does not let you pick beyond a namespace
that is the empty string: it would not make the "package name"
dropdown sensitive (although it would correctly populate the options
from the GraphQL response).

This commit updates the "empty" state for the package name option from
the empty string to null (like is used for version). Then update the
`disabled` param to be determined on whether the namespace is null
(rather than the empty string).

Signed-off-by: Ed Baunton <[email protected]>
  • Loading branch information
edbaunton committed Dec 14, 2023
1 parent 297f44c commit 418bd12
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions components/packages/packageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function PackageSelector({
resetTypeFunc?: () => void;
}) {
const [packageType, setPackageType] = useState("");
const [packageNamespace, setPackageNamespace] = useState("");
const [packageNamespace, setPackageNamespace] = useState(null);
const [packageName, setPackageName] = useState("");
const [packageNamespaces, setPackageNamespaces] = useState(
INITIAL_PACKAGE_NAMESPACES
Expand All @@ -43,7 +43,7 @@ export default function PackageSelector({

const resetType = () => {
setPackageNamespaces(INITIAL_PACKAGE_NAMESPACES);
setPackageNamespace("");
setPackageNamespace(null);
resetNamespace();
resetTypeFunc();
};
Expand Down Expand Up @@ -82,7 +82,7 @@ export default function PackageSelector({
setPackageNameFunc={setPackageName}
setPackageVersionsFunc={setPackageVersions}
resetNameFunc={resetName}
disabled={!packageNamespace}
disabled={packageNamespace === null}
/>
</div>
<div className="left-0 flex w-full items-end justify-center bg-gradient-to-t lg:static lg:h-auto lg:w-auto lg:bg-none">
Expand Down

0 comments on commit 418bd12

Please sign in to comment.