Sha256: bc80fe8edfbdc9f0b863f343cff22a15b8265dba8b117cfb3cf792ac01b04a08

Contents?: true

Size: 1.14 KB

Versions: 45

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

45 entries across 45 versions & 1 rubygems

Version Path
foreman_remote_execution-9.1.0 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-8.2.1 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-8.2.0 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-9.0.1 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js
foreman_remote_execution-9.0.0 webpack/react_app/components/TargetingHosts/TargetingHostsLabelsRow.js