Sha256: 67252ef80ef89f52bb04b8e412edf08c144006815614bf25620d360fdd653991

Contents?: true

Size: 1.3 KB

Versions: 9

Compression:

Stored size: 1.3 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { useHistory } from 'react-router-dom';
import { Tabs, Tab, TabTitleText } from '@patternfly/react-core';
import { useSelector } from 'react-redux';
import { selectAPIResponse } from 'foremanReact/redux/API/APISelectors';
import SecondaryTabRoutes from './SecondaryTabsRoutes';
import { activeTab } from './helpers';
import SECONDARY_TABS from './constants';

const ContentTab = ({ location: { pathname } }) => {
  const hashHistory = useHistory();
  const hostDetails = useSelector(state => selectAPIResponse(state, 'HOST_DETAILS'));
  const filteredTabs =
    SECONDARY_TABS?.filter(tab => !tab.hideTab?.({ hostDetails })) ?? [];
  return (
    <>
      <Tabs
        className="margin-0-24"
        onSelect={(evt, subTab) => hashHistory.push(subTab)}
        isSecondary
        activeKey={activeTab(pathname)}
      >
        {filteredTabs.map(({ key, title }) => (
          <Tab
            key={key}
            eventKey={key}
            title={<TabTitleText>{title}</TabTitleText>}
          />
        ))}
      </Tabs>
      <SecondaryTabRoutes />
    </>
  );
};

ContentTab.propTypes = {
  location: PropTypes.shape({
    pathname: PropTypes.string,
  }),
};
ContentTab.defaultProps = {
  location: { pathname: '' },
};

export default ContentTab;

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-4.6.2.1 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js
katello-4.6.2 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js
katello-4.6.1 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js
katello-4.5.1 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js
katello-4.6.0 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js
katello-4.6.0.rc2 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js
katello-4.6.0.rc1 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js
katello-4.5.0 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js
katello-4.5.0.rc2 webpack/components/extensions/HostDetails/Tabs/ContentTab/index.js