Sha256: b81ab166feef4236d46fcfbf11625456d06011fb0b7a05123b3e45d003d583c2

Contents?: true

Size: 1.82 KB

Versions: 56

Compression:

Stored size: 1.82 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import { translate as __ } from 'foremanReact/common/I18n';

import { useQuery } from '@apollo/client';
import variableOverrides from '../../../../graphql/queries/hostVariableOverrides.gql';
import AnsibleVariableOverridesTable from './AnsibleVariableOverridesTable';
import {
  useParamsToVars,
  useCurrentPagination,
} from '../../../../helpers/pageParamsHelper';

import { encodeId } from '../../../../globalIdHelper';
import './AnsibleVariableOverrides.scss';

const AnsibleVariableOverrides = ({ hostId, hostAttrs, history }) => {
  const hostGlobalId = encodeId('Host', hostId);
  const pagination = useCurrentPagination(history);

  const useFetchFn = () =>
    useQuery(variableOverrides, {
      variables: {
        id: hostGlobalId,
        match: `fqdn=${hostAttrs.name}`,
        ...useParamsToVars(history),
      },
      fetchPolicy: 'network-only',
      nextFetchPolicy: 'cache-first',
    });

  const renameData = data => ({
    variables: data.host.ansibleVariablesWithOverrides.nodes,
    totalCount: data.host.ansibleVariablesWithOverrides.totalCount,
  });

  return (
    <AnsibleVariableOverridesTable
      hostId={hostId}
      hostAttrs={hostAttrs}
      hostGlobalId={hostGlobalId}
      renameData={renameData}
      fetchFn={useFetchFn}
      renamedDataPath="variables"
      emptyStateProps={{
        header: __('No Ansible variables found for Host'),
        description: __('Only variables marked to Override are shown here.'),
      }}
      permissions={['view_ansible_variables']}
      pagination={pagination}
      history={history}
    />
  );
};

AnsibleVariableOverrides.propTypes = {
  hostId: PropTypes.number.isRequired,
  hostAttrs: PropTypes.object.isRequired,
  history: PropTypes.object.isRequired,
};

export default AnsibleVariableOverrides;

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
foreman_ansible-10.2.0 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-10.1.0 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-10.0.1 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-10.0.0 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-7.1.4 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-9.0.1 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-7.1.3 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-9.0.0 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-7.1.2 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-7.1.1 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-8.0.1 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-8.0.0 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-7.0.4 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-7.1.0 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-7.0.3 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js
foreman_ansible-7.0.2 webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/index.js