-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js: moved renderViewControls() to js/topbar/ViewControls
- Loading branch information
Showing
2 changed files
with
105 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* Copyright 2017-present, The Visdom Authors | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
import React from 'react'; | ||
|
||
function ViewControls(props) { | ||
const { | ||
connected, | ||
envID, | ||
activeLayout, | ||
layoutList, | ||
readonly, | ||
onViewManageButton, | ||
onRepackButton, | ||
onViewChange, | ||
} = props; | ||
|
||
// rendering | ||
// --------- | ||
let view_options = Array.from(layoutList.keys()).map((view) => { | ||
// add checkmark before currently used layout | ||
let check_space = ''; | ||
if (view == activeLayout) { | ||
check_space = <span> ✓</span>; | ||
} | ||
|
||
return ( | ||
<li key={view}> | ||
<a href={'#' + view} onClick={() => onViewChange(view)}> | ||
{view} | ||
{check_space} | ||
</a> | ||
</li> | ||
); | ||
}); | ||
return ( | ||
<span> | ||
<span>View </span> | ||
<div className="btn-group navbar-btn" role="group" aria-label="View:"> | ||
<div className="btn-group" role="group"> | ||
<button | ||
className="btn btn-default dropdown-toggle" | ||
type="button" | ||
id="viewDropdown" | ||
data-toggle="dropdown" | ||
aria-haspopup="true" | ||
aria-expanded="true" | ||
disabled={!(connected && envID)} | ||
> | ||
{envID == null ? 'compare' : activeLayout} | ||
| ||
<span className="caret" /> | ||
</button> | ||
<ul className="dropdown-menu" aria-labelledby="viewDropdown"> | ||
{view_options} | ||
</ul> | ||
</div> | ||
<button | ||
data-toggle="tooltip" | ||
title="Repack" | ||
data-placement="bottom" | ||
className="btn btn-default" | ||
onClick={onRepackButton} | ||
> | ||
<span className="glyphicon glyphicon-th" /> | ||
</button> | ||
<button | ||
data-toggle="tooltip" | ||
title="Manage Views" | ||
data-placement="bottom" | ||
className="btn btn-default" | ||
disabled={!(connected && envID && !readonly)} | ||
onClick={onViewManageButton} | ||
> | ||
<span className="glyphicon glyphicon-folder-open" /> | ||
</button> | ||
</div> | ||
</span> | ||
); | ||
} | ||
|
||
export default ViewControls; |