-
Notifications
You must be signed in to change notification settings - Fork 993
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #35287 - Create column selector on host index page
- Loading branch information
Showing
5 changed files
with
75 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module ColumnSelectorHelper | ||
def get_table_columns | ||
User.current.table_preferences.select { |table| /#{auto_complete_controller_name}/.match?(table.name) }.first.columns | ||
end | ||
|
||
def mount_column_selector | ||
url = send("api_users_path") + "/#{User.current[:id]}/table_preferences/#{auto_complete_controller_name}" | ||
react_component("ColumnSelector", data: { | ||
url: url, | ||
controller: auto_complete_controller_name, | ||
columns: get_table_columns | ||
}) | ||
end | ||
end |
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
52 changes: 52 additions & 0 deletions
52
webpack/assets/javascripts/react_app/components/ColumnSelector/ColumnSelector.js
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,52 @@ | ||
import React from 'react'; | ||
import { PropTypes } from 'prop-types'; | ||
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core'; | ||
|
||
const ColumnSelector = props => { | ||
const { | ||
data: { url, controller, columns }, | ||
} = props; | ||
const [isOpen, setIsOpen] = useState(false); | ||
return ( | ||
<div className="pf-c-select"> | ||
<p>columns</p> | ||
<div className="pf-c-select-group"> | ||
<Select | ||
variant={SelectVariant.checkbox} | ||
aria-label="Select Input" | ||
onToggle={setIsOpen} | ||
isOpen={isOpen} | ||
placeholderText="Filter columns" | ||
controller={controller} | ||
url={url} | ||
> | ||
<SelectOption key={columns.name} value="Name" />, | ||
<SelectOption key={columns.os_title} value="Operating system" />, | ||
<SelectOption key={columns.model} value="Model" />, | ||
<SelectOption key={columns.owner} value="Owner" /> | ||
<SelectOption key={columns.hostgroup} value="Host group" /> | ||
<SelectOption key={columns.last_report} value="Last report" /> | ||
<SelectOption key={columns.comment} value="Comment" /> | ||
</Select> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
ColumnSelector.propTypes = { | ||
data: PropTypes.shape({ | ||
controller: PropTypes.string, | ||
url: PropTypes.string, | ||
columns: PropTypes.arrayOf(PropTypes.string) | ||
}) | ||
}; | ||
|
||
ColumnSelector.defaultProps = { | ||
data: { | ||
controller: null, | ||
url: null, | ||
columns: [] | ||
} | ||
}; | ||
|
||
export default ColumnSelector; |
1 change: 1 addition & 0 deletions
1
webpack/assets/javascripts/react_app/components/ColumnSelector/index.js
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 @@ | ||
import ColumnSelector from './ColumnSelector'; |
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