Add registration key

Fully implement registration step with conditional text fields
This commit is contained in:
Karel Hala 2021-06-01 13:23:34 +02:00 committed by Sanne Raymaekers
parent fb1c949a97
commit 2d777bd30d
3 changed files with 46 additions and 7 deletions

View file

@ -1,15 +1,22 @@
import React from 'react';
import React, { useState, useEffect } from 'react';
import ImageCreator from './ImageCreator';
import { useHistory } from 'react-router-dom';
import componentTypes from '@data-driven-forms/react-form-renderer/component-types';
import { Button } from '@patternfly/react-core';
import { Button, Spinner } from '@patternfly/react-core';
import { ExternalLinkAltIcon } from '@patternfly/react-icons';
import { review, awsTarget, registration, googleCloudTarger, msAzureTarget, packages, imageOutput } from './steps';
import './CreateImageWizard.scss';
const CreateImage = () => {
const history = useHistory();
return <ImageCreator
const [ user, setUser ] = useState();
useEffect(() => {
(async () => {
const userData = await insights.chrome.auth.getUser();
setUser(() => userData);
})();
}, []);
return user ? <ImageCreator
onClose={ () => history.push('/landing') }
onSubmit={ (values) => console.log(values) }
defaultArch="x86_64"
@ -43,13 +50,13 @@ https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/up
awsTarget,
msAzureTarget,
googleCloudTarger,
registration,
registration(user),
packages,
review,
]
}
]
} } />;
} } /> : <Spinner />;
};
export default CreateImage;

View file

@ -82,5 +82,6 @@ export default {
},
],
}
// TODO check oauth2 thing too here?
]
};

View file

@ -1,11 +1,12 @@
import componentTypes from '@data-driven-forms/react-form-renderer/component-types';
import validatorTypes from '@data-driven-forms/react-form-renderer/validator-types';
export const registerValues = {
'subscribe-now-radio': 'Embed an activation key and register systems on first boot',
'register-later-radio-button': 'Register the system later'
};
export default {
export default (user) => ({
title: 'Registration',
name: 'registration',
nextStep: 'packages',
@ -19,6 +20,36 @@ export default {
label: title,
value: key
}))
},
{
component: componentTypes.TEXT_FIELD,
name: 'subscription-organization',
type: 'text',
label: 'Organization ID',
initialValue: Number(user?.identity?.internal?.org_id),
isDisabled: true,
condition: {
or: [
{ when: 'register-system', is: 'subscribe-now-radio' },
]
}
},
{
component: componentTypes.TEXT_FIELD,
name: 'subscription-activation',
type: 'text',
label: 'Activation key',
condition: {
or: [
{ when: 'register-system', is: 'subscribe-now-radio' },
]
},
isRequired: true,
validate: [
{
type: validatorTypes.REQUIRED,
},
],
}
]
};
});