8000 Updates to native Skill contribution wizard - unify wizards by jeff-phillips-18 · Pull Request #625 · instructlab/ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updates to native Skill contribution wizard - unify wizards #625

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

Merged
Merged
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
2 changes: 1 addition & 1 deletion src/app/login/githublogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const GithubLogin: React.FC = () => {
setErrorMsg(errorMessage);
setShowError(true);
}
}, []);
}, [searchParams]);

const handleGitHubLogin = () => {
signIn('github', { callbackUrl: '/' }); // Redirect to home page after login
Expand Down
8 changes: 3 additions & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import { AppLayout } from '../components/AppLayout';
const HomePage: React.FC = () => {
const [isWarningConditionAccepted, setIsWarningConditionAccepted] = useState<boolean>(false);

const handleWarningConditionAccepted = () => {
if (!isWarningConditionAccepted) {
setIsWarningConditionAccepted(true);
}
};
const handleWarningConditionAccepted = React.useCallback(() => {
setIsWarningConditionAccepted(true);
}, []);

return (
<AppLayout>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
import React, { useEffect } from 'react';
import { KnowledgeFormData } from '@/types';
import {
ValidatedOptions,
FormGroup,
TextInput,
FormHelperText,
HelperText,
HelperTextItem,
FlexItem,
Content,
Flex,
Form
} from '@patternfly/react-core';
import { ContributionFormData } from '@/types';
import { ValidatedOptions, FormGroup, TextInput, FormHelperText, HelperText, HelperTextItem, FlexItem, Flex, Form } from '@patternfly/react-core';
import { ExclamationCircleIcon } from '@patternfly/react-icons';
import PageHeader from '@/components/Contribute/PageHeader';

interface Props {
isEditForm?: boolean;
knowledgeFormData: KnowledgeFormData;
contributionFormData: ContributionFormData;
titleWork: string;
setTitleWork: (val: string) => void;
linkWork: string;
setLinkWork: (val: string) => void;
revision: string;
setRevision: (val: string) => void;
linkWork?: string;
setLinkWork?: (val: string) => void;
revision?: string;
setRevision?: (val: string) => void;
licenseWork: string;
setLicenseWork: (val: string) => void;
creators: string;
Expand All @@ -33,9 +23,9 @@ const AttributionInformation: React.FC<Props> = ({
isEditForm,
titleWork,
setTitleWork,
linkWork,
linkWork = '',
setLinkWork,
revision,
revision = '',
setRevision,
licenseWork,
setLicenseWork,
Expand Down Expand Up @@ -101,41 +91,42 @@ const AttributionInformation: React.FC<Props> = ({
return (
<Flex gap={{ default: 'gapMd' }} direction={{ default: 'column' }}>
<FlexItem>
<Content component="h4">Attribution Information</Content>
<Content component="p">Provide attribution information.</Content>
<PageHeader title="Attribution Information" description="Provide attribution information." />
</FlexItem>
<FlexItem>
<Form>
<FormGroup isRequired key={'attribution-info-details-work_link'} label="Work link or URL">
<TextInput
isRequired
type="url"
aria-label="link_work"
placeholder="Enter link to work"
validated={validLink}
value={linkWork}
value) => setLinkWork(value)}
=> validateLink(linkWork)}
/>
{validLink === ValidatedOptions.error && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validLink}>
Required field
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
{validLink === ValidatedOptions.warning && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validLink}>
Please enter a valid URL.
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
</FormGroup>
{setLinkWork ? (
<FormGroup isRequired key={'attribution-info-details-work_link'} label="Work link or URL">
<TextInput
isRequired
type="url"
aria-label="link_work"
placeholder="Enter link to work"
validated={validLink}
value={linkWork}
value) => setLinkWork(value)}
=> validateLink(linkWork)}
/>
{validLink === ValidatedOptions.error && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validLink}>
Required field
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
{validLink === ValidatedOptions.warning && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validLink}>
Please enter a valid URL.
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
</FormGroup>
) : null}
<FormGroup isRequired key={'attribution-info-details-title_work'} label="Work title">
<TextInput
isRequired
Expand All @@ -157,27 +148,29 @@ const AttributionInformation: React.FC<Props> = ({
</FormHelperText>
)}
</FormGroup>
<FormGroup isRequired key={'attribution-info-details-document_revision'} label="Document revision">
<TextInput
isRequired
type="text"
aria-label="revision"
placeholder="Enter document revision information"
validated={validRevision}
value={revision}
value) => setRevision(value)}
=> validateRevision(revision)}
/>
{validRevision === ValidatedOptions.error && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validRevision}>
Required field
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
</FormGroup>
{setRevision ? (
<FormGroup isRequired key={'attribution-info-details-document_revision'} label="Document revision">
<TextInput
isRequired
type="text"
aria-label="revision"
placeholder="Enter document revision information"
validated={validRevision}
value={revision}
value) => setRevision(value)}
=> validateRevision(revision)}
/>
{validRevision === ValidatedOptions.error && (
<FormHelperText>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={validRevision}>
Required field
</HelperTextItem>
</HelperText>
</FormHelperText>
)}
</FormGroup>
) : null}
<FormGroup isRequired key={'attribution-info-details-license'} label="License">
<TextInput
isRequired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import React from 'react';
import {
ValidatedOptions,
FormGroup,
TextInput,
FormHelperText,
HelperText,
HelperTextItem,
Form,
Flex,
FlexItem,
Content
} from '@patternfly/react-core';
import { ValidatedOptions, FormGroup, TextInput, FormHelperText, HelperText, HelperTextItem, Form, Flex, FlexItem } from '@patternfly/react-core';
import { ExclamationCircleIcon } from '@patternfly/react-icons';
import { isEmailValid } from '@/components/Contribute/Utils/validationUtils';
import PageHeader from '@/components/Contribute/PageHeader';

interface Props {
email: string;
Expand All @@ -27,8 +18,7 @@ const AuthorInformation: React.FC<Props> = ({ email, setEmail, name, setName })

const validateEmail = (emailStr: string) => {
const email = emailStr.trim();
const re = /\S+@\S+\.\S+/;
if (re.test(email)) {
if (isEmailValid(email)) {
setValidEmail(ValidatedOptions.success);
setValidEmailError('');
return;
Expand All @@ -46,8 +36,7 @@ const AuthorInformation: React.FC<Props> = ({ email, setEmail, name, setName })
return (
<Flex gap={{ default: 'gapMd' }} direction={{ default: 'column' }}>
<FlexItem>
<Content component="h4">Author Information</Content>
<Content component="p">Provide your information required for a GitHub DCO sign-off.</Content>
<PageHeader title="Author Information" description="Provide your information required for a GitHub DCO sign-off." />
</FlexItem>
<FlexItem>
<Form>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KnowledgeFormData, KnowledgeSeedExample, QuestionAndAnswerPair } from '@/types';
import { KnowledgeFormData, KnowledgeSeedExample, QuestionAndAnswerPair, SkillFormData, SkillSeedExample } from '@/types';
import { ValidatedOptions } from '@patternfly/react-core';

const questionAndAnswerPairs1: QuestionAndAnswerPair[] = [
Expand Down Expand Up @@ -127,7 +127,7 @@ const questionAndAnswerPairs5: QuestionAndAnswerPair[] = [
}
];

const seedExamples: KnowledgeSeedExample[] = [
const knowledgeSeedExamples: KnowledgeSeedExample[] = [
{
immutable: true,
isExpanded: true,
Expand Down Expand Up @@ -258,8 +258,8 @@ export const autoFillKnowledgeFields: KnowledgeFormData = {
documentOutline:
'Information about the Phoenix Constellation including the history, characteristics, and features of the stars in the constellation.',
filePath: 'science/physics/astrophysics/stars',
seedExamples: seedExamples,
knowledgeDocumentRepositoryUrl: 'https://github.com/juliadenham/Summit_knowledge',
seedExamples: knowledgeSeedExamples,
knowledgeDocumentRepositoryUrl: '~/.instructlab-ui/taxonomy-knowledge-docs',
knowledgeDocumentCommit: '0a1f2672b9b90582e6115333e3ed62fd628f1c0f',
documentName: 'phoenix_constellation.md',
titleWork: 'Phoenix (constellation)',
Expand All @@ -268,3 +268,98 @@ export const autoFillKnowledgeFields: KnowledgeFormData = {
licenseWork: 'CC-BY-SA-4.0',
creators: 'Wikipedia Authors'
};

const skillsSeedExamples: SkillSeedExample[] = [
{
immutable: false,
isExpanded: false,
context: undefined,
isContextValid: ValidatedOptions.success,
validationError: undefined,
questionAndAnswer: {
immutable: false,
question: 'What are 5 words that rhyme with horn?',
isQuestionValid: ValidatedOptions.success,
questionValidationError: undefined,
answer: 'warn, torn, born, thorn, and corn.',
isAnswerValid: ValidatedOptions.success,
answerValidationError: undefined
}
},
{
immutable: false,
isExpanded: false,
context: undefined,
isContextValid: ValidatedOptions.success,
validationError: undefined,
questionAndAnswer: {
immutable: false,
question: 'What are 5 words that rhyme with cat?',
isQuestionValid: ValidatedOptions.success,
questionValidationError: undefined,
answer: 'bat, gnat, rat, vat, and mat.',
isAnswerValid: ValidatedOptions.success,
answerValidationError: undefined
}
},
{
immutable: false,
isExpanded: false,
context: undefined,
isContextValid: ValidatedOptions.success,
validationError: undefined,
questionAndAnswer: {
immutable: false,
question: 'What are 5 words that rhyme with poor?',
isQuestionValid: ValidatedOptions.success,
questionValidationError: undefined,
answer: 'door, shore, core, bore, and tore.',
isAnswerValid: ValidatedOptions.success,
answerValidationError: undefined
}
},
{
immutable: false,
isExpanded: false,
context: undefined,
isContextValid: ValidatedOptions.success,
validationError: undefined,
questionAndAnswer: {
immutable: false,
question: 'What are 5 words that rhyme with bank?',
isQuestionValid: ValidatedOptions.success,
questionValidationError: undefined,
answer: 'tank, rank, prank, sank, and drank.',
isAnswerValid: ValidatedOptions.success,
answerValidationError: undefined
}
},
{
immutable: false,
isExpanded: false,
context: undefined,
isContextValid: ValidatedOptions.success,
validationError: undefined,
questionAndAnswer: {
immutable: false,
question: 'What are 5 words that rhyme with bake?',
isQuestionValid: ValidatedOptions.success,
questionValidationError: undefined,
answer: 'wake, lake, steak, make, and quake.',
isAnswerValid: ValidatedOptions.success,
answerValidationError: undefined
}
}
];

export const autoFillSkillsFields: SkillFormData = {
email: 'helloworld@instructlab.com',
name: 'juliadenham',
submissionSummary: 'Teaching a model to rhyme.',
documentOutline: 'These provided examples demonstrate how to rhyme.',
filePath: 'science/physics/astrophysics/stars',
seedExamples: skillsSeedExamples,
titleWork: 'Teaching a model to rhyme.',
licenseWork: 'CC-BY-SA-4.0',
creators: 'juliadenham'
};
Loading
0