()
| 109 | } |
| 110 | |
| 111 | render() { |
| 112 | let { getComponent, specSelectors, getConfigs } = this.props |
| 113 | const Button = getComponent("Button") |
| 114 | const Link = getComponent("Link") |
| 115 | const Logo = getComponent("Logo") |
| 116 | const DarkModeToggle = getComponent("DarkModeToggle") |
| 117 | |
| 118 | let isLoading = specSelectors.loadingStatus() === "loading" |
| 119 | let isFailed = specSelectors.loadingStatus() === "failed" |
| 120 | |
| 121 | const classNames = ["download-url-input"] |
| 122 | if (isFailed) classNames.push("failed") |
| 123 | if (isLoading) classNames.push("loading") |
| 124 | |
| 125 | const { urls } = getConfigs() |
| 126 | let control = [] |
| 127 | let formOnSubmit = null |
| 128 | |
| 129 | if(urls) { |
| 130 | let rows = [] |
| 131 | urls.forEach((link, i) => { |
| 132 | rows.push(<option key={i} value={link.url}>{link.name}</option>) |
| 133 | }) |
| 134 | |
| 135 | control.push( |
| 136 | <label className="select-label" htmlFor="select"><span>Select a definition</span> |
| 137 | <select id="select" disabled={isLoading} onChange={ this.onUrlSelect } value={urls[this.state.selectedIndex].url}> |
| 138 | {rows} |
| 139 | </select> |
| 140 | </label> |
| 141 | ) |
| 142 | } |
| 143 | else { |
| 144 | formOnSubmit = this.downloadUrl |
| 145 | control.push( |
| 146 | <input |
| 147 | className={classNames.join(" ")} |
| 148 | type="text" |
| 149 | onChange={this.onUrlChange} |
| 150 | value={this.state.url} |
| 151 | disabled={isLoading} |
| 152 | id="download-url-input" |
| 153 | /> |
| 154 | ) |
| 155 | control.push(<Button className="download-url-button" onClick={ this.downloadUrl }>Explore</Button>) |
| 156 | } |
| 157 | |
| 158 | return ( |
| 159 | <div className="topbar"> |
| 160 | <div className="wrapper"> |
| 161 | <div className="topbar-wrapper"> |
| 162 | <Link> |
| 163 | <Logo/> |
| 164 | </Link> |
| 165 | <form className="download-url-wrapper" onSubmit={formOnSubmit}> |
| 166 | {control.map((el, i) => cloneElement(el, { key: i }))} |
| 167 | </form> |
| 168 | <DarkModeToggle /> |
nothing calls this directly
no test coverage detected