mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 11:25:08 -02:30
set default values on prompts
This commit is contained in:
@@ -145,7 +145,7 @@ class LaunchButton extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { launchError, showLaunchPrompt, launchConfig } = this.state;
|
const { launchError, showLaunchPrompt, launchConfig } = this.state;
|
||||||
const { i18n, children } = this.props;
|
const { resource, i18n, children } = this.props;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{children({
|
{children({
|
||||||
@@ -166,6 +166,7 @@ class LaunchButton extends React.Component {
|
|||||||
{showLaunchPrompt && (
|
{showLaunchPrompt && (
|
||||||
<LaunchPrompt
|
<LaunchPrompt
|
||||||
config={launchConfig}
|
config={launchConfig}
|
||||||
|
resource={resource}
|
||||||
onCancel={() => this.setState({ showLaunchPrompt: false })}
|
onCancel={() => this.setState({ showLaunchPrompt: false })}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
function InventoryStep() {
|
function CredentialsStep() {
|
||||||
return <div />;
|
return <div />;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default InventoryStep;
|
export default CredentialsStep;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const QS_CONFIG = getQSConfig('inventory', {
|
|||||||
|
|
||||||
function InventoryStep({ i18n }) {
|
function InventoryStep({ i18n }) {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [field, meta, helpers] = useField('inventory');
|
const [field, , helpers] = useField('inventory');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isLoading,
|
isLoading,
|
||||||
@@ -29,9 +29,6 @@ function InventoryStep({ i18n }) {
|
|||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const params = parseQueryString(QS_CONFIG, history.location.search);
|
const params = parseQueryString(QS_CONFIG, history.location.search);
|
||||||
const { data } = await InventoriesAPI.read(params);
|
const { data } = await InventoriesAPI.read(params);
|
||||||
if (!field.value && data.results.length) {
|
|
||||||
helpers.setValue(data.results[0]);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
inventories: data.results,
|
inventories: data.results,
|
||||||
count: data.count,
|
count: data.count,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import OtherPromptsStep from './OtherPromptsStep';
|
|||||||
import SurveyStep from './SurveyStep';
|
import SurveyStep from './SurveyStep';
|
||||||
import PreviewStep from './PreviewStep';
|
import PreviewStep from './PreviewStep';
|
||||||
|
|
||||||
function LaunchPrompt({ config, onCancel, i18n }) {
|
function LaunchPrompt({ config, resource, onCancel, i18n }) {
|
||||||
// CONFIG
|
// CONFIG
|
||||||
// can_start_without_user_input: false
|
// can_start_without_user_input: false
|
||||||
// passwords_needed_to_start: []
|
// passwords_needed_to_start: []
|
||||||
@@ -28,11 +28,12 @@ function LaunchPrompt({ config, onCancel, i18n }) {
|
|||||||
// credential_needed_to_start: false
|
// credential_needed_to_start: false
|
||||||
// inventory_needed_to_start: false
|
// inventory_needed_to_start: false
|
||||||
// job_template_data: {name: "JT with prompts", id: 25, description: ""
|
// job_template_data: {name: "JT with prompts", id: 25, description: ""
|
||||||
|
// defaults: {} ??
|
||||||
|
|
||||||
const steps = [];
|
const steps = [];
|
||||||
const initialValues = {};
|
const initialValues = {};
|
||||||
if (config.ask_inventory_on_launch) {
|
if (config.ask_inventory_on_launch) {
|
||||||
initialValues.inventory = null;
|
initialValues.inventory = resource?.summary_fields?.inventory || null;
|
||||||
steps.push({
|
steps.push({
|
||||||
name: i18n._(t`Inventory`),
|
name: i18n._(t`Inventory`),
|
||||||
component: <InventoryStep />,
|
component: <InventoryStep />,
|
||||||
@@ -47,7 +48,7 @@ function LaunchPrompt({ config, onCancel, i18n }) {
|
|||||||
// _.has(vm, 'promptDataClone.prompts.credentials.passwords.ssh_password')
|
// _.has(vm, 'promptDataClone.prompts.credentials.passwords.ssh_password')
|
||||||
// ) {
|
// ) {
|
||||||
if (config.ask_credential_on_launch) {
|
if (config.ask_credential_on_launch) {
|
||||||
initialValues.credentials = [];
|
initialValues.credentials = resource?.summary_fields?.credentials || [];
|
||||||
steps.push({
|
steps.push({
|
||||||
name: i18n._(t`Credential`),
|
name: i18n._(t`Credential`),
|
||||||
component: <CredentialsStep />,
|
component: <CredentialsStep />,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
function InventoryStep() {
|
function PreviewStep() {
|
||||||
return <div />;
|
return <div>Preview of selected values will appear here</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default InventoryStep;
|
export default PreviewStep;
|
||||||
|
|||||||
Reference in New Issue
Block a user