diff --git a/app/graphql/mutations/ansible_variable_overrides/update.rb b/app/graphql/mutations/ansible_variable_overrides/update.rb
index fe3122ae7..be59f3c4d 100644
--- a/app/graphql/mutations/ansible_variable_overrides/update.rb
+++ b/app/graphql/mutations/ansible_variable_overrides/update.rb
@@ -11,9 +11,10 @@ class Update < ::Mutations::UpdateMutation
argument :omit, Boolean, required: false
argument :host_id, Int, required: true
argument :ansible_variable_id, Int, required: true
+ argument :hidden_value, Boolean, required: true
field :overriden_ansible_variable, ::Types::OverridenAnsibleVariable, :null => true
-
+
def resolve(host_id:, ansible_variable_id:, **kwargs)
result = super kwargs
host = Host.find host_id
diff --git a/app/graphql/presenters/overriden_ansible_variable_presenter.rb b/app/graphql/presenters/overriden_ansible_variable_presenter.rb
index ae4003a76..ed1beefd9 100644
--- a/app/graphql/presenters/overriden_ansible_variable_presenter.rb
+++ b/app/graphql/presenters/overriden_ansible_variable_presenter.rb
@@ -3,11 +3,11 @@ class OverridenAnsibleVariablePresenter
attr_reader :ansible_variable
delegate :id, :key, :description, :override?,
- :parameter_type, :hidden_value?, :omit, :required,
+ :parameter_type, :hidden_value, :omit, :required,
:validator_type, :validator_rule, :default_value,
:ansible_role, :current_value, :to => :ansible_variable
- def initialize(ansible_variable, override_resolver)
+ def initialize(ansible_variable, override_resolver)
@ansible_variable = ansible_variable
@override_resolver = override_resolver
end
diff --git a/app/models/ansible_variable.rb b/app/models/ansible_variable.rb
index fd8518fd6..6c1d320a7 100644
--- a/app/models/ansible_variable.rb
+++ b/app/models/ansible_variable.rb
@@ -15,6 +15,10 @@ def ansible?
true
end
+ def hidden_value
+ self.hidden_value?
+ end
+
def self.humanize_class_name(options = nil)
if options.present?
super
diff --git a/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTable.js b/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTable.js
index a0389561f..17e193248 100644
--- a/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTable.js
+++ b/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTable.js
@@ -13,7 +13,7 @@ import {
Th,
Td,
} from '@patternfly/react-table';
-import { Flex, FlexItem } from '@patternfly/react-core';
+import { Flex, FlexItem, Checkbox } from '@patternfly/react-core';
import Pagination from 'foremanReact/components/Pagination';
import deleteAnsibleVariableOverride from '../../../../graphql/mutations/deleteAnsibleVariableOverride.gql';
@@ -26,6 +26,7 @@ import {
validateValue,
onCompleted,
onError,
+ formatValue,
} from './AnsibleVariableOverridesTableHelper';
import withLoading from '../../../withLoading';
@@ -44,6 +45,7 @@ const initState = vars =>
value: variable.currentValue
? variable.currentValue.value
: variable.defaultValue,
+ hiddenValue: variable.hiddenValue,
validation: { key: 'noval', msg: '' },
working: false,
}));
@@ -77,6 +79,10 @@ const AnsibleVariableOverridesTable = ({
innerDispatch({ idx, payload: { open: flag } });
};
+ const setHiddenValue = idx => isHide => {
+ innerDispatch({ idx, payload: { hiddenValue: isHide } });
+ };
+
const onValueChange = (idx, variable) => value => {
const payload = {
value,
@@ -174,14 +180,31 @@ const AnsibleVariableOverridesTable = ({
{variable.ansibleRoleName} |
{variable.parameterType} |
-
+ {!editableState[idx].open ? (
+ formatValue(variable)
+ ) : (
+ <>
+
+
+ >
+ )}
|
{formatSourceAttr(variable)} |
diff --git a/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTableHelper.js b/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTableHelper.js
index 4864c2601..27c9aef2f 100644
--- a/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTableHelper.js
+++ b/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/AnsibleVariableOverridesTableHelper.js
@@ -12,6 +12,7 @@ function formatSourceLink(currentValue) {
return `${__(element)}: ${currentValue.elementName}`;
}
+//here we can add the condition for hidden value to "*****"
export const formatSourceAttr = variable =>
variable.currentValue
? formatSourceLink(variable.currentValue)
@@ -21,7 +22,9 @@ export const formatValue = variable => {
const value = variable.currentValue
? variable.currentValue.value
: variable.defaultValue;
-
+ if (variable.hiddenValue) {
+ return '••••••••';
+ }
switch (variable.parameterType) {
case 'boolean':
return value ? : ;
diff --git a/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableAction.js b/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableAction.js
index b59a18e94..b2df2db1e 100644
--- a/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableAction.js
+++ b/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableAction.js
@@ -73,6 +73,7 @@ const EditableAction = ({
variables: {
id: lookupValue.id,
value: state.value,
+ hiddenValue: state.hiddenValue,
hostId,
ansibleVariableId: decodeModelId(variable),
match,
diff --git a/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableValue.js b/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableValue.js
index e4d03b7e0..ef36a85de 100644
--- a/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableValue.js
+++ b/webpack/components/AnsibleHostDetail/components/AnsibleVariableOverrides/EditableValue.js
@@ -1,9 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { translate as __ } from 'foremanReact/common/I18n';
-
-import { formatValue } from './AnsibleVariableOverridesTableHelper';
-
import {
TextAreaField,
TextInputField,
@@ -11,10 +8,6 @@ import {
} from './EditableValueHelper';
const EditableValue = props => {
- if (!props.editing) {
- return formatValue(props.variable);
- }
-
const type = props.variable.parameterType;
if (['json', 'yaml', 'array', 'hash'].includes(type)) {
@@ -61,7 +54,6 @@ const EditableValue = props => {
};
EditableValue.propTypes = {
- editing: PropTypes.bool.isRequired,
variable: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired,
value: PropTypes.any,
diff --git a/webpack/graphql/mutations/updateAnsibleVariableOverride.gql b/webpack/graphql/mutations/updateAnsibleVariableOverride.gql
index 069b2614f..02e8c132e 100644
--- a/webpack/graphql/mutations/updateAnsibleVariableOverride.gql
+++ b/webpack/graphql/mutations/updateAnsibleVariableOverride.gql
@@ -3,8 +3,9 @@ mutation UpdateAnsibleVariableOverride(
$hostId: Int!,
$ansibleVariableId: Int!,
$value: RawJson!
- $match: String!) {
- updateAnsibleVariableOverride(input: { id: $id, hostId: $hostId, value: $value, ansibleVariableId: $ansibleVariableId }) {
+ $match: String!
+ $hiddenValue: Boolean!) {
+ updateAnsibleVariableOverride(input: { id: $id, hostId: $hostId, value: $value, ansibleVariableId: $ansibleVariableId, hiddenValue: $hiddenValue }) {
overridenAnsibleVariable {
id
lookupValues(match: $match) {
@@ -15,6 +16,7 @@ mutation UpdateAnsibleVariableOverride(
omit
}
}
+ hiddenValue
currentValue {
element
value
diff --git a/webpack/graphql/queries/hostVariableOverrides.gql b/webpack/graphql/queries/hostVariableOverrides.gql
index 69039008c..938d6265f 100644
--- a/webpack/graphql/queries/hostVariableOverrides.gql
+++ b/webpack/graphql/queries/hostVariableOverrides.gql
@@ -13,6 +13,7 @@ query($id: String!, $match: String, $first: Int, $last: Int) {
canEdit
}
defaultValue
+ hiddenValue
parameterType
ansibleRoleName
validatorType
|