Skip to content

Commit

Permalink
Updated github knowledge form to wizard based form.
Browse files Browse the repository at this point in the history
Signed-off-by: Anil Vishnoi <[email protected]>
  • Loading branch information
vishnoianil committed Dec 12, 2024
1 parent 1f29e5f commit f5ead4a
Show file tree
Hide file tree
Showing 18 changed files with 301 additions and 340 deletions.
12 changes: 4 additions & 8 deletions src/components/Contribute/EditKnowledge/EditKnowledge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ import { KnowledgeSchemaVersion } from '@/types/const';
import { fetchPullRequest, fetchFileContent, fetchPullRequestFiles } from '@/utils/github';
import yaml from 'js-yaml';
import axios from 'axios';
import KnowledgeFormGithub, {
KnowledgeEditFormData,
KnowledgeFormData,
QuestionAndAnswerPair,
SeedExample
} from '@/components/Contribute/Knowledge/Github';
import { KnowledgeEditFormData, KnowledgeFormData, QuestionAndAnswerPair, KnowledgeSeedExample } from '@/types';
import { ValidatedOptions } from '@patternfly/react-core/dist/esm/helpers/constants';
import { useEffect, useState } from 'react';
import { Modal, ModalVariant } from '@patternfly/react-core/dist/esm/deprecated/components/Modal/Modal';
import { useRouter } from 'next/navigation';
import KnowledgeFormGithub from '../Knowledge/Github';

interface EditKnowledgeClientComponentProps {
prNumber: number;
Expand Down Expand Up @@ -88,10 +84,10 @@ const EditKnowledge: React.FC<EditKnowledgeClientComponentProps> = ({ prNumber }
knowledgeExistingFormData.knowledgeDocumentCommit = yamlData.document.commit;
knowledgeExistingFormData.documentName = yamlData.document.patterns.join(', ');

const seedExamples: SeedExample[] = [];
const seedExamples: KnowledgeSeedExample[] = [];
yamlData.seed_examples.forEach((seed, index) => {
// iterate through questions_and_answers and create a new object for each
const example: SeedExample = {
const example: KnowledgeSeedExample = {
immutable: index < 5 ? true : false,
isExpanded: true,
context: seed.context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { HelperText } from '@patternfly/react-core/dist/dynamic/components/Helpe
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 '../Github';
import { checkKnowledgeFormCompletion } from '../validation';
import { KnowledgeFormData } from '@/types';

interface Props {
reset: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Contribute/Knowledge/AutoFill.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { KnowledgeFormData, QuestionAndAnswerPair, SeedExample } from './Github';
import { KnowledgeFormData, QuestionAndAnswerPair, KnowledgeSeedExample } from './Github';

Check failure on line 1 in src/components/Contribute/Knowledge/AutoFill.ts

View workflow job for this annotation

GitHub Actions / npm-lint

Module '"./Github"' has no exported member 'KnowledgeFormData'. Did you mean to use 'import KnowledgeFormData from "./Github"' instead?

Check failure on line 1 in src/components/Contribute/Knowledge/AutoFill.ts

View workflow job for this annotation

GitHub Actions / npm-lint

Module '"./Github"' has no exported member 'QuestionAndAnswerPair'. Did you mean to use 'import QuestionAndAnswerPair from "./Github"' instead?

Check failure on line 1 in src/components/Contribute/Knowledge/AutoFill.ts

View workflow job for this annotation

GitHub Actions / npm-lint

Module '"./Github"' has no exported member 'KnowledgeSeedExample'. Did you mean to use 'import KnowledgeSeedExample from "./Github"' instead?
import { ValidatedOptions } from '@patternfly/react-core/dist/esm/helpers/constants';

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

const seedExamples: SeedExample[] = [
const seedExamples: KnowledgeSeedExample[] = [
{
immutable: true,
isExpanded: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { KnowledgeFormData } from '../Github';
import { DropdownItem } from '@patternfly/react-core/dist/esm/components/Dropdown/DropdownItem';
import FileIcon from '@patternfly/react-icons/dist/esm/icons/file-icon';
import { KnowledgeFormData } from '@/types';

interface Props {
knowledgeFormData: KnowledgeFormData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { DropdownList } from '@patternfly/react-core/dist/dynamic/components/Dro
import { MenuToggle, MenuToggleElement } from '@patternfly/react-core/dist/dynamic/components/MenuToggle';
import DownloadYaml from '../DownloadYaml/DownloadYaml';
import DownloadAttribution from '../DownloadAttribution/DownloadAttribution';
import { KnowledgeFormData } from '../Github';
import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon';
import { KnowledgeFormData } from '@/types';

interface Props {
knowledgeFormData: KnowledgeFormData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { KnowledgeFormData } from '../Github';
import { KnowledgeYamlData } from '@/types';
import { KnowledgeFormData, KnowledgeYamlData } from '@/types';
import { KnowledgeSchemaVersion } from '@/types/const';
import { dumpYaml } from '@/utils/yamlConfig';
import { DropdownItem } from '@patternfly/react-core/dist/esm/components/Dropdown/DropdownItem';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { HelperText } from '@patternfly/react-core/dist/dynamic/components/Helpe
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';
import { Modal, ModalVariant } from '@patternfly/react-core/dist/esm/deprecated/components/Modal/Modal';
import { KnowledgeFormData } from '@/types';

interface Props {
reset: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Contribute/Knowledge/Github/Submit/Submit.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Button } from '@patternfly/react-core/dist/dynamic/components/Button';
import { ActionGroupAlertContent, KnowledgeFormData } from '..';
import { AttributionData, KnowledgeYamlData } from '@/types';
import { ActionGroupAlertContent } from '..';
import { AttributionData, KnowledgeFormData, KnowledgeYamlData } from '@/types';
import { KnowledgeSchemaVersion } from '@/types/const';
import { dumpYaml } from '@/utils/yamlConfig';
import { validateFields } from '../../validation';
Expand Down
Loading

0 comments on commit f5ead4a

Please sign in to comment.