Skip to content

Commit

Permalink
Rename latestVersion to isStale and use boolean
Browse files Browse the repository at this point in the history
Co-Authored-By: Austin Ziegler <austin@zieglers.ca>
  • Loading branch information
alisinabh and halostatue committed Jan 8, 2025
1 parent 66129df commit 8ef47f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions assets/js/handlebars/templates/versions-dropdown.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<label>
<span class="sidebar-projectVersionsDropdownCaret" aria-hidden="true">&#x25bc;</span>
<span class="sr-only">Project version</span>
{{#if latestVersion}}
{{#if isStale}}
<i class="ri-alert-line sidebar-staleIcon" aria-hidden="true"></i>
{{/if}}
<select class="sidebar-projectVersionsDropdown{{#if latestVersion}} sidebar-staleVersion{{/if}}"{{#if latestVersion}} title="This version is not the latest version of the package."{{/if}}>
<select class="sidebar-projectVersionsDropdown{{#if isStale}} sidebar-staleVersion{{/if}}"{{#if isStale}} title="This version is not the latest version of the package."{{/if}}>
{{#each nodes}}
<option translate="no" value="{{url}}"{{#if isCurrentVersion}} selected disabled{{/if}}>
{{version}}
Expand Down
8 changes: 4 additions & 4 deletions assets/js/sidebar/sidebar-version-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export function initialize () {
const currentVersion = versionsContainer.textContent.trim()

const latestVersionNode = versionNodes.find(node => node.latest)
const latestVersion = latestVersionNode?.version !== currentVersion ? latestVersionNode?.version : null
const isStale = latestVersionNode?.version !== currentVersion

const nodes = decorateVersionNodes(versionNodes, currentVersion)

renderVersionsDropdown({ nodes, latestVersion })
renderVersionsDropdown({ nodes, isStale })
}
}

function renderVersionsDropdown ({ nodes, latestVersion }) {
function renderVersionsDropdown ({ nodes, isStale }) {
const versionsContainer = qs(VERSIONS_CONTAINER_SELECTOR)
const versionsDropdownHtml = versionsDropdownTemplate({ nodes, latestVersion })
const versionsDropdownHtml = versionsDropdownTemplate({ nodes, isStale })
versionsContainer.innerHTML = versionsDropdownHtml

qs(VERSIONS_DROPDOWN_SELECTOR).addEventListener('change', handleVersionSelected)
Expand Down

0 comments on commit 8ef47f0

Please sign in to comment.