import React from 'react';
import componentTypes from '@data-driven-forms/react-form-renderer/component-types';
import validatorTypes from '@data-driven-forms/react-form-renderer/validator-types';
import { HelpIcon } from '@patternfly/react-icons';
import nextStepMapper from './imageOutputStepMapper';
import { Title, Text, Popover, TextContent, TextList, TextListItem, Button } from '@patternfly/react-core';
import PropTypes from 'prop-types';
export const googleAccType = {
googleAccount: 'Google account',
serviceAccount: 'Service account',
googleGroup: 'Google group',
domain: 'Domain'
};
const PopoverInfo = ({ appendTo }) => {
return The following account types can have an image shared with them:Google account: A Google account represents a developer, an administrator,
or any other person who interacts with Google Cloud. e.g., `alice@gmail.com`.
Service account: A service account is an account for an application instead
of an individual end user. e.g., `myapp@appspot.gserviceaccount.com`.
Google group: A Google group is a named collection of Google accounts and
service accounts. e.g., `admins@example.com`.
Google Workspace domain/Cloud Identity domain: A Google workspace or cloud identity
domain represents a virtual group of all the Google accounts in an organization. These domains
represent your organization's internet domain name. e.g., `mycompany.com`.
}>
;
};
PopoverInfo.propTypes = {
appendTo: PropTypes.any
};
export default {
title: 'Google Cloud Platform',
customTitle:
Target environment - Google Cloud Platform,
name: 'google-cloud-target-env',
substepOf: 'Target environment',
nextStep: ({ values }) => nextStepMapper(values, { skipGoogle: true, skipAws: true }),
fields: [
{
component: componentTypes.PLAIN_TEXT,
name: 'google-cloud-text-component',
label:
Your image will be uploaded to Google Cloud Platform and shared with the email you provide below.
The image should be copied to your account within 14 days.
},
{
component: 'radio-popover',
label: 'Type',
Popover: PopoverInfo,
name: 'google-account-type',
initialValue: 'googleAccount',
options: Object.entries(googleAccType).map(([ value, label ]) => ({
label: value === 'domain' ? 'Google Workspace domain or Cloud Identity domain' : label,
value
})),
isRequired: true,
validate: [
{
type: validatorTypes.REQUIRED,
},
],
},
{
component: componentTypes.TEXT_FIELD,
name: 'google-email',
'data-testid': 'input-google-email',
type: 'text',
label: 'Email address',
condition: {
or: [
{ when: 'google-account-type', is: 'googleAccount' },
{ when: 'google-account-type', is: 'serviceAccount' },
{ when: 'google-account-type', is: 'googleGroup' },
{ when: 'google-account-type', is: null },
]
},
isRequired: true,
validate: [
{
type: validatorTypes.REQUIRED,
},
{
type: validatorTypes.PATTERN,
pattern: '[a-z0-9._%+-]+@[a-z0-9.-]+.[a-z]{2,}$',
message: 'Please enter a valid email address'
}
],
},
{
component: componentTypes.TEXT_FIELD,
name: 'google-domain',
type: 'text',
label: 'Domain',
condition: {
when: 'google-account-type',
is: 'domain'
},
isRequired: true,
validate: [
{
type: validatorTypes.REQUIRED,
},
],
}
]
};