diff --git a/webpack/assets/javascripts/react_app/components/ColumnSelector/ColumnSelector.js b/webpack/assets/javascripts/react_app/components/ColumnSelector/ColumnSelector.js
index ea18b0bf9c1..3fa87496f63 100644
--- a/webpack/assets/javascripts/react_app/components/ColumnSelector/ColumnSelector.js
+++ b/webpack/assets/javascripts/react_app/components/ColumnSelector/ColumnSelector.js
@@ -152,7 +152,7 @@ const ColumnSelector = props => {
icon={}
iconPosition="left"
className="columns-selector"
- onClick={() => toggleModal()}
+ onClick={toggleModal}
title={__('Manage columns')}
>
{__('Manage columns')}
diff --git a/webpack/assets/javascripts/react_app/components/HostsIndex/index.js b/webpack/assets/javascripts/react_app/components/HostsIndex/index.js
index afff6a49867..ca806bfc8d4 100644
--- a/webpack/assets/javascripts/react_app/components/HostsIndex/index.js
+++ b/webpack/assets/javascripts/react_app/components/HostsIndex/index.js
@@ -58,6 +58,10 @@ export const ForemanHostsIndexActionsBarContext = forceSingleton(
);
const HostsIndex = () => {
+ const [allColumns, setAllColumns] = useState(
+ getColumnData({ tableName: 'hosts' })
+ );
+ const [allJsLoaded, setAllJsLoaded] = useState(false);
const {
searchParam: urlSearchQuery = '',
page: urlPage,
@@ -92,7 +96,16 @@ const HostsIndex = () => {
setAPIOptions: response.setAPIOptions,
});
- const allColumns = getColumnData({ tableName: 'hosts' });
+ useEffect(() => {
+ const handleLoadJS = () => {
+ setAllColumns(getColumnData({ tableName: 'hosts' }));
+ setAllJsLoaded(true);
+ };
+ document.addEventListener('loadJS', handleLoadJS);
+ return () => {
+ document.removeEventListener('loadJS', handleLoadJS);
+ };
+ }, [setAllColumns]);
const {
hasPreference,
columns: userColumns,
@@ -200,12 +213,12 @@ const HostsIndex = () => {
];
const registeredItems = useSelector(selectKebabItems, shallowEqual);
- const pluginToolbarItems = (
+ const pluginToolbarItems = jsReady => (
-
+ {jsReady && }
);
@@ -305,7 +318,7 @@ const HostsIndex = () => {
controller="hosts"
creatable={false}
replacementResponse={response}
- customToolbarItems={pluginToolbarItems}
+ customToolbarItems={pluginToolbarItems(allJsLoaded)}
selectionToolbar={selectionToolbar}
updateSearchQuery={updateSearchQuery}
>