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