Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knowledge: test #88

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions knowledge/engineering/test/attribution.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Title of work: title
Link to work: http://redhat.com
Revision: asdfasdf
License of the work: asdfasdf
Creator names: asdfasdf
184 changes: 184 additions & 0 deletions knowledge/engineering/test/qna.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
created_by: vishnoianil
version: 3
domain: ads
document_outline: asdfasdfasdfasdfadsfadsfsadfasdfasdfasdfasdfasdfasdf
seed_examples:
- context: '1'
questions_and_answers:
- question: '11'
answer: '11'
- question: '12'
answer: '12'
- question: '13'
answer: '13'
- context: '2'
questions_and_answers:
- question: >
import React, { useEffect, useState } from 'react';

import { FormFieldGroupExpandable, FormFieldGroupHeader, FormGroup,
FormHelperText } from
'@patternfly/react-core/dist/dynamic/components/Form';

import { TextInput } from
'@patternfly/react-core/dist/dynamic/components/TextInput';

import { HelperText } from
'@patternfly/react-core/dist/dynamic/components/HelperText';

import { HelperTextItem } from
'@patternfly/react-core/dist/dynamic/components/HelperText';

import ExclamationCircleIcon from
'@patternfly/react-icons/dist/dynamic/icons/exclamation-circle-icon';

import { ValidatedOptions } from
'@patternfly/react-core/dist/esm/helpers/constants';

import { KnowledgeFormData } from '..';

import { checkKnowledgeFormCompletion } from '../validation';


interface Props {
reset: boolean;
knowledgeFormData: KnowledgeFormData;
setDisableAction: React.Dispatch<React.SetStateAction<boolean>>;
email: string;
setEmail: React.Dispatch<React.SetStateAction<string>>;
name: string;
setName: React.Dispatch<React.SetStateAction<string>>;
}

const AuthorInformation: React.FC<Props> = ({ reset,
knowledgeFormData, setDisableAction, email, setEmail, name, setName })
=> {
const [validEmail, setValidEmail] = useState<ValidatedOptions>();
const [validName, setValidName] = useState<ValidatedOptions>();

const validateEmail = (email: string) => {
const re = /\S+@\S+\.\S+/;
if (re.test(email)) {
setValidEmail(ValidatedOptions.success);
setDisableAction(!checkKnowledgeFormCompletion(knowledgeFormData));
return;
}
setDisableAction(true);
setValidEmail(ValidatedOptions.error);
return;
};

const validateName = (name: string) => {
if (name.length > 0) {
setValidName(ValidatedOptions.success);
setDisableAction(!checkKnowledgeFormCompletion(knowledgeFormData));
return;
}
setDisableAction(true);
setValidName(ValidatedOptions.error);
return;
};

useEffect(() => {
setValidEmail(ValidatedOptions.default);
setValidName(ValidatedOptions.default);
}, [reset]);

return (
<FormFieldGroupExpandable
isExpanded
toggleAriaLabel="Details"
header={
<FormFieldGroupHeader
titleText={{
text: (
<p>
Author Information <span style={{ color: 'red' }}>*</span>
</p>
),
id: 'author-info-id'
}}
titleDescription="Provide your information required for a GitHub DCO sign-off."
/>
}
>
<FormGroup isRequired key={'author-info-details-id'}>
<TextInput
isRequired
type="email"
aria-label="email"
placeholder="Enter your email address"
value={email}
validated={validEmail}
onChange={(_event, value) => setEmail(value)}
onBlur={() => validateEmail(email)}
/>
{validEmail === ValidatedOptions.error && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validEmail}>
Please enter a valid email address.
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
<TextInput
isRequired
type="text"
aria-label="name"
placeholder="Enter your full name"
value={name}
validated={validName}
onChange={(_event, value) => setName(value)}
onBlur={() => validateName(name)}
/>
{validName === ValidatedOptions.error && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validName}>
Name is required.
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
</FormGroup>
</FormFieldGroupExpandable>
);
};


export default AuthorInformation;
answer: '21'
- question: '22'
answer: '22'
- question: '23'
answer: '23'
- context: '3'
questions_and_answers:
- question: '31'
answer: '31'
- question: '32'
answer: '32'
- question: '33'
answer: '33'
- context: '4'
questions_and_answers:
- question: '41'
answer: '41'
- question: '42'
answer: '42'
- question: '43'
answer: '43'
- context: '5'
questions_and_answers:
- question: '51'
answer: '51'
- question: '52'
answer: '52'
- question: '53'
answer: '53'
document:
repo: https://redhat.com
commit: asdfasdfasdf
patterns:
- asdfasdfasdf