Sha256: bc80fe8edfbdc9f0b863f343cff22a15b8265dba8b117cfb3cf792ac01b04a08

Contents?: true

Size: 1.14 KB

Versions: 44

Compression:

Stored size: 1.14 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { Row, Label } from 'patternfly-react';
import { noop } from 'foremanReact/common/helpers';
import { translate as __ } from 'foremanReact/common/I18n';

import './TargetingHostsLabelsRow.scss';

const TargetingHostsLabelsRow = ({ query, updateQuery }) => {
  const onDeleteClick = keyToDelete => {
    const { [keyToDelete]: deleted, ...queryWithoutDeleted } = query;
    updateQuery(queryWithoutDeleted);
  };

  const queryEntries = Object.entries(query);

  return (
    queryEntries.length > 0 && (
      <Row className="tasks-labels-row">
        <span className="title">{__('Active Filters:')}</span>
        {queryEntries.map(([key, value]) => (
          <Label
            bsStyle="info"
            key={key}
            onRemoveClick={() => onDeleteClick(key)}
          >
            {`${key} = ${value}`}
          </Label>
        ))}
      </Row>
    )
  );
};

TargetingHostsLabelsRow.propTypes = {
  query: PropTypes.object,
  updateQuery: PropTypes.func,
};

TargetingHostsLabelsRow.defaultProps = {
  query: {},
  updateQuery: noop,
};

export default TargetingHostsLabelsRow;

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
foreman_remote_execution-14.1.1 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-14.1.0 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-14.0.2 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-14.0.1 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-13.2.6 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-14.0.0 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-13.2.5 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-13.2.4 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-13.2.3 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-13.2.2 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-12.0.7 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-13.2.1 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-13.2.0 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-10.1.3 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-13.0.0 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-12.0.5 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-12.0.4 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-12.0.1 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-12.0.2 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-11.1.3 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js