fix: urls.primaryName functionality regression (via #5097)
* add tests * compute index before triggering URL load * bonus: improve urls topbar label
This commit is contained in:
@@ -74,7 +74,7 @@ export default class Topbar extends React.Component {
|
||||
const urls = configs.urls || []
|
||||
|
||||
if(urls && urls.length) {
|
||||
this.loadSpec(urls[this.state.selectedIndex].url)
|
||||
var targetIndex = this.state.selectedIndex
|
||||
let primaryName = configs["urls.primaryName"]
|
||||
if(primaryName)
|
||||
{
|
||||
@@ -82,9 +82,12 @@ export default class Topbar extends React.Component {
|
||||
if(spec.name === primaryName)
|
||||
{
|
||||
this.setState({selectedIndex: i})
|
||||
targetIndex = i
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.loadSpec(urls[targetIndex].url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +119,7 @@ export default class Topbar extends React.Component {
|
||||
})
|
||||
|
||||
control.push(
|
||||
<label className="select-label" htmlFor="select"><span>Select a spec</span>
|
||||
<label className="select-label" htmlFor="select"><span>Select a definition</span>
|
||||
<select id="select" disabled={isLoading} onChange={ this.onUrlSelect } value={urls[this.state.selectedIndex].url}>
|
||||
{rows}
|
||||
</select>
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
margin: 0;
|
||||
color: #f0f0f0;
|
||||
span
|
||||
{
|
||||
font-size: 16px;
|
||||
|
||||
Reference in New Issue
Block a user