Skip to content

Commit

Permalink
Bug fix: Terraform version dropdown on /install (#2228)
Browse files Browse the repository at this point in the history
* Moved terraform versions filter to lib; added test to make sure versions are always in the correct order

* Clean up console.log; type casting versions in test; added versions fixture
  • Loading branch information
heatlikeheatwave authored Nov 11, 2023
1 parent 3d4c341 commit 7598c25
Show file tree
Hide file tree
Showing 5 changed files with 33,680 additions and 79 deletions.
21 changes: 2 additions & 19 deletions src/components/version-context-switcher/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,8 @@ const VersionContextSwitcher = ({
options,
}: VersionContextSwitcherProps): ReactElement => {
const currentProduct = useCurrentProduct()
let latestVersion = options[0].value
/** Update `latestVersion` to the latest version of the product
* that has been released if it can be determined. This is needed
* because not all products have `latest` listed as the first item
* in the sorted array. E.g. `vault-enterprise` lists `+ent.hsm.fips1402`
* variants first.
*/
for (let i = 0; i < options.length; i++) {
const versionLabel = options[i].label
const versionValue = options[i].value
if (versionLabel.indexOf('(latest)') >= 0) {
latestVersion = versionValue
break
}
}

const [selectedVersion, setSelectedVersion] = useState<
ContextSwitcherOption['value']
>(initialValue || latestVersion)
const [selectedVersion, setSelectedVersion] =
useState<ContextSwitcherOption['value']>(initialValue)

/**
* Handle change event for switcher, invoking the `onChange` function last if
Expand Down
Loading

1 comment on commit 7598c25

@vercel
Copy link

@vercel vercel bot commented on 7598c25 Nov 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.