Skip to content

Commit

Permalink
Merge pull request instructlab#351 from nerdalert/knowledge-submissio…
Browse files Browse the repository at this point in the history
…n-wiz

Convert standalone knowledge submissions to the new stepped style
  • Loading branch information
vishnoianil authored Nov 27, 2024
2 parents 68fa485 + 559102b commit bd7f46e
Show file tree
Hide file tree
Showing 13 changed files with 464 additions and 324 deletions.
7 changes: 7 additions & 0 deletions src/app/api/local/git/branches/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ export async function POST(req: NextRequest) {
},
{ status: 500 }
);
} finally {
// Ensure switching back to 'main' branch after any operation
try {
await git.checkout({ fs, dir: REPO_DIR, ref: 'main' });
} catch (checkoutError) {
console.error('Failed to switch back to main branch:', checkoutError);
}
}
}

Expand Down
26 changes: 7 additions & 19 deletions src/components/Contribute/AuthorInformation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { FormFieldGroupExpandable, FormFieldGroupHeader, FormGroup, FormHelperText } from '@patternfly/react-core/dist/dynamic/components/Form';
import { 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';
Expand Down Expand Up @@ -70,23 +70,11 @@ const AuthorInformation: React.FC<Props> = ({ formType, reset, formData, setDisa
}, [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."
/>
}
>
<>
<h2>
Author Information <span style={{ color: 'red' }}>*</span>
</h2>
<p>Provide your information required for a GitHub DCO sign-off.</p>
<FormGroup isRequired key={'author-info-details-email'} label="Email address">
<TextInput
isRequired
Expand Down Expand Up @@ -129,7 +117,7 @@ const AuthorInformation: React.FC<Props> = ({ formType, reset, formData, setDisa
</FormHelperText>
)}
</FormGroup>
</FormFieldGroupExpandable>
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import { FormFieldGroupExpandable, FormFieldGroupHeader, FormGroup, FormHelperText } from '@patternfly/react-core/dist/dynamic/components/Form';
import { 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';
Expand Down Expand Up @@ -134,22 +134,18 @@ const AttributionInformation: React.FC<Props> = ({
};

return (
<FormFieldGroupExpandable
toggleAriaLabel="Details"
header={
<FormFieldGroupHeader
titleText={{
text: (
<p>
Attribution Information <span style={{ color: 'red' }}>*</span>
</p>
),
id: 'attribution-info-id'
}}
titleDescription="Provide attribution information."
/>
}
>
<div>
<FormFieldGroupHeader
titleText={{
text: (
<p>
Attribution Information <span style={{ color: 'red' }}>*</span>
</p>
),
id: 'attribution-info-id'
}}
titleDescription="Provide attribution information."
/>
<FormGroup isRequired key={'attribution-info-details-work_link'} label="Work link or URL">
<TextInput
isRequired
Expand Down Expand Up @@ -264,7 +260,7 @@ const AttributionInformation: React.FC<Props> = ({
</FormHelperText>
)}
</FormGroup>
</FormFieldGroupExpandable>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { FormFieldGroupExpandable, FormFieldGroupHeader, FormGroup, FormHelperText } from '@patternfly/react-core/dist/dynamic/components/Form';
import { FormFieldGroupHeader, FormGroup, FormHelperText } from '@patternfly/react-core/dist/dynamic/components/Form';
import { Button } from '@patternfly/react-core/dist/dynamic/components/Button';
import { TextInput } from '@patternfly/react-core/dist/dynamic/components/TextInput';
import { UploadFile } from './../UploadFile';
Expand Down Expand Up @@ -208,22 +208,18 @@ const DocumentInformation: React.FC<Props> = ({
};

return (
<FormFieldGroupExpandable
toggleAriaLabel="Details"
header={
<FormFieldGroupHeader
titleText={{
text: (
<p>
Document Information <span style={{ color: 'red' }}>*</span>
</p>
),
id: 'doc-info-id'
}}
titleDescription="Add the relevant document's information"
/>
}
>
<div>
<FormFieldGroupHeader
titleText={{
text: (
<p>
Document Information <span style={{ color: 'red' }}>*</span>
</p>
),
id: 'doc-info-id'
}}
titleDescription="Add the relevant document's information"
/>
<FormGroup>
<div style={{ display: 'flex', gap: '10px' }}>
<Button
Expand Down Expand Up @@ -365,7 +361,7 @@ const DocumentInformation: React.FC<Props> = ({
{failureAlertMessage}
</Alert>
)}
</FormFieldGroupExpandable>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { FormFieldGroupExpandable, FormFieldGroupHeader, FormGroup } from '@patternfly/react-core/dist/dynamic/components/Form';
import { FormFieldGroupHeader, FormGroup } from '@patternfly/react-core/dist/dynamic/components/Form';
import PathService from '@/components/PathService/PathService';

interface Props {
Expand All @@ -10,27 +10,22 @@ interface Props {

const FilePathInformation: React.FC<Props> = ({ reset, path, setFilePath }) => {
return (
<FormFieldGroupExpandable
isExpanded
toggleAriaLabel="Details"
header={
<FormFieldGroupHeader
titleText={{
text: (
<p>
Taxonomy Directory Path <span style={{ color: 'red' }}>*</span>
</p>
),
id: 'file-path-info-id'
}}
titleDescription="Specify the file path for the QnA and Attribution files. Once path is selected, please add your leaf directory name for your contribution."
/>
}
>
<div>
<FormFieldGroupHeader
titleText={{
text: (
<p>
Taxonomy Directory Path <span style={{ color: 'red' }}>*</span>
</p>
),
id: 'file-path-info-id'
}}
titleDescription="Specify the file path for the QnA and Attribution files. Once path is selected, please add your leaf directory name for your contribution."
/>
<FormGroup isRequired key={'file-path-service-id'}>
<PathService reset={reset} rootPath="knowledge" path={path} handlePathChange={setFilePath} />
</FormGroup>
</FormFieldGroupExpandable>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import { FormFieldGroupExpandable, FormFieldGroupHeader, FormGroup } from '@patternfly/react-core/dist/dynamic/components/Form';
import { FormGroup } from '@patternfly/react-core/dist/dynamic/components/Form';
import { TextInput } from '@patternfly/react-core/dist/dynamic/components/TextInput';
import { TextArea } from '@patternfly/react-core/dist/dynamic/components/TextArea';
import { HelperText } from '@patternfly/react-core/dist/dynamic/components/HelperText';
Expand Down Expand Up @@ -89,23 +89,11 @@ const KnowledgeInformation: React.FC<Props> = ({
};

return (
<FormFieldGroupExpandable
isExpanded
toggleAriaLabel="Details"
header={
<FormFieldGroupHeader
titleText={{
text: (
<p>
Knowledge Information <span style={{ color: 'red' }}>*</span>
</p>
),
id: 'knowledge-info-id'
}}
titleDescription="Provide brief information about the knowledge."
/>
}
>
<>
<h2>
Knowledge Information <span style={{ color: 'red' }}>*</span>
</h2>
<p>Provide brief information about the knowledge.</p>
<FormGroup key={'knowledge-info-details-submission_summary'} label="Submission summary">
<TextInput
isRequired
Expand Down Expand Up @@ -166,7 +154,7 @@ const KnowledgeInformation: React.FC<Props> = ({
</HelperText>
)}
</FormGroup>
</FormFieldGroupExpandable>
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { FormFieldGroupExpandable, FormFieldGroupHeader, FormGroup, FormHelperText } from '@patternfly/react-core/dist/dynamic/components/Form';
import { FormFieldGroupHeader, FormGroup, FormHelperText } from '@patternfly/react-core/dist/dynamic/components/Form';
import { TextArea } from '@patternfly/react-core/dist/dynamic/components/TextArea';
import { ExclamationCircleIcon } from '@patternfly/react-icons/dist/dynamic/icons/';
import { QuestionAndAnswerPair, SeedExample } from '..';
Expand Down Expand Up @@ -46,30 +46,24 @@ const KnowledgeQuestionAnswerPairs: React.FC<Props> = ({
<FormHelperText key={seedExampleIndex * 10 + 2}>
<HelperText>
<HelperTextItem icon={<ExclamationCircleIcon />} variant={seedExample.isContextValid}>
{seedExample.validationError ? seedExample.validationError : 'Required field. It must be non empty and less than 500 words.'}
{seedExample.validationError || 'Required field. It must be non-empty and less than 500 words.'}
</HelperTextItem>
</HelperText>
</FormHelperText>
)}

{seedExample.questionAndAnswers.map((questionAndAnswerPair: QuestionAndAnswerPair, questionAnswerIndex) => (
<FormFieldGroupExpandable
isExpanded
toggleAriaLabel="ContextDetails"
key={seedExampleIndex * 100 + questionAnswerIndex * 10 + 0}
header={
<FormFieldGroupHeader
titleText={{
text: (
<p>
Q&A Pair {questionAnswerIndex + 1} {questionAndAnswerPair.immutable && <span style={{ color: 'red' }}>*</span>}
</p>
),
id: 'nested-field-group1-titleText-id'
}}
/>
}
>
<div key={seedExampleIndex * 100 + questionAnswerIndex * 10 + 0}>
<FormFieldGroupHeader
titleText={{
text: (
<p>
Q&A Pair {questionAnswerIndex + 1} {questionAndAnswerPair.immutable && <span style={{ color: 'red' }}>*</span>}
</p>
),
id: 'nested-field-group1-titleText-id'
}}
/>
<React.Fragment key={questionAnswerIndex}>
<TextArea
key={seedExampleIndex * 100 + questionAnswerIndex * 10 + 1}
Expand Down Expand Up @@ -116,7 +110,7 @@ const KnowledgeQuestionAnswerPairs: React.FC<Props> = ({
</FormHelperText>
)}
</React.Fragment>
</FormFieldGroupExpandable>
</div>
))}
</FormGroup>
);
Expand Down
Loading

0 comments on commit bd7f46e

Please sign in to comment.