Skip to content

Commit

Permalink
optimise component
Browse files Browse the repository at this point in the history
Signed-off-by: Faeka Ansari <faeka6@gmail.com>
  • Loading branch information
fykaa committed Jan 14, 2025
1 parent a12d49d commit f489cc5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/src/components/VersionDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';

const CACHE_KEY = 'kargo-docs-versions';
const CACHE_DURATION = 1000 * 60 * 30; // 30 minutes
const githubApiUrl = 'https://api.github.com/repos/akuity/kargo/branches';
const githubApiUrl = 'https://api.github.com/repos/akuity/kargo/branches?protected=true';

function VersionDropdown() {
console.log("Navbar dropdown initialized");
Expand Down Expand Up @@ -35,17 +35,17 @@ function VersionDropdown() {
.map(branch => branch.name)
.filter(name => /^release-(1[.]\d+|[2-9]\d*[.]\d+)$/.test(name))
.map(name => {
const [major, minor] = name.split('.');
const [major, minor] = name.replace('release-', '').split('.');
return {
version: `v${major}.${minor}`,
url: `https://${major}-${minor}.docs.kargo.io${window.location.pathname}`
url: `https://${name.replace('.', '-')}.docs.kargo.io`
};
});
console.log("These are release branches before unshifting: ", releaseBranches)
// Add current version
releaseBranches.unshift({
version: 'current',
url: `https://docs.kargo.io${window.location.pathname}`
version: 'Latest Version',
url: `https://docs.kargo.io`
});
console.log("These are release branches: ", releaseBranches)

Expand Down Expand Up @@ -86,7 +86,7 @@ function VersionDropdown() {
>
{versions.map(version => (
<option key={version.version} value={version.version}>
{version.version === 'current' ? 'Other Versions' : `${version.version}`}
{version.version}
</option>
))}
</select>
Expand Down

0 comments on commit f489cc5

Please sign in to comment.