From b841d76ec1711e6f39cb7c8e48adddfd2cc7c51d Mon Sep 17 00:00:00 2001 From: Ash Evans Date: Wed, 9 Oct 2024 10:34:41 +0100 Subject: [PATCH 1/6] allowing knowledge attribution and yaml viewing Signed-off-by: Ash Evans --- .../Contribute/Knowledge/ViewDropdown/ViewDropdown.tsx | 7 +++---- src/components/Contribute/Knowledge/index.tsx | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/Contribute/Knowledge/ViewDropdown/ViewDropdown.tsx b/src/components/Contribute/Knowledge/ViewDropdown/ViewDropdown.tsx index 31338306..8dd1d0af 100644 --- a/src/components/Contribute/Knowledge/ViewDropdown/ViewDropdown.tsx +++ b/src/components/Contribute/Knowledge/ViewDropdown/ViewDropdown.tsx @@ -13,12 +13,11 @@ import FileIcon from '@patternfly/react-icons/dist/dynamic/icons/file-icon'; import EyeIcon from '@patternfly/react-icons/dist/esm/icons/eye-icon'; interface Props { - disableAction: boolean; knowledgeFormData: KnowledgeFormData; githubUsername: string | undefined; } -export const ViewDropdown: React.FunctionComponent = ({ disableAction, knowledgeFormData, githubUsername }) => { +export const ViewDropdown: React.FunctionComponent = ({ knowledgeFormData, githubUsername }) => { const [isOpen, setIsOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false); const [modalContent, setModalContent] = useState(''); @@ -86,10 +85,10 @@ export const ViewDropdown: React.FunctionComponent = ({ disableAction, kn shouldFocusToggleOnSelect > - + YAML Content - + Attribution Content diff --git a/src/components/Contribute/Knowledge/index.tsx b/src/components/Contribute/Knowledge/index.tsx index 881866f8..1592b66b 100644 --- a/src/components/Contribute/Knowledge/index.tsx +++ b/src/components/Contribute/Knowledge/index.tsx @@ -588,12 +588,11 @@ export const KnowledgeForm: React.FunctionComponent = ({ kno /> )} - + From f85ab60af7a530b31eac31fa8dcc7357d1a7d8f1 Mon Sep 17 00:00:00 2001 From: Ash Evans Date: Wed, 9 Oct 2024 10:37:29 +0100 Subject: [PATCH 2/6] enabling the download of partially completed knowedge attribution and yaml Signed-off-by: Ash Evans --- .../DownloadAttribution.tsx | 10 +++------ .../DownloadDropdown/DownloadDropdown.tsx | 21 +++---------------- .../Knowledge/DownloadYaml/DownloadYaml.tsx | 11 +++------- 3 files changed, 9 insertions(+), 33 deletions(-) diff --git a/src/components/Contribute/Knowledge/DownloadAttribution/DownloadAttribution.tsx b/src/components/Contribute/Knowledge/DownloadAttribution/DownloadAttribution.tsx index 55eb4073..3f0fe267 100644 --- a/src/components/Contribute/Knowledge/DownloadAttribution/DownloadAttribution.tsx +++ b/src/components/Contribute/Knowledge/DownloadAttribution/DownloadAttribution.tsx @@ -1,19 +1,15 @@ import React from 'react'; -import { validateFields } from '../validation'; -import { ActionGroupAlertContent, KnowledgeFormData } from '..'; +import { KnowledgeFormData } from '..'; import { DropdownItem } from '@patternfly/react-core/dist/esm/components/Dropdown/DropdownItem'; import FileIcon from '@patternfly/react-icons/dist/esm/icons/file-icon'; interface Props { - disableAction: boolean; knowledgeFormData: KnowledgeFormData; - setActionGroupAlertContent: React.Dispatch>; } -const DownloadAttribution: React.FC = ({ disableAction, knowledgeFormData, setActionGroupAlertContent }) => { +const DownloadAttribution: React.FC = ({ knowledgeFormData }) => { const handleDownloadAttribution = () => { // Because I have overly complicated the validatedFields function all fields are being checked and not just the attribution ones here. Not ideal. - if (!validateFields(knowledgeFormData, setActionGroupAlertContent)) return; const attributionContent = `Title of work: ${knowledgeFormData.titleWork} Link to work: ${knowledgeFormData.linkWork} @@ -33,7 +29,7 @@ const DownloadAttribution: React.FC = ({ disableAction, knowledgeFormData }; return ( - + Attribution File ); diff --git a/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx b/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx index 918a1596..e18c7a0f 100644 --- a/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx +++ b/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx @@ -8,18 +8,12 @@ import { ActionGroupAlertContent, KnowledgeFormData } from '..'; import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon'; interface Props { - disableAction: boolean; knowledgeFormData: KnowledgeFormData; setActionGroupAlertContent: React.Dispatch>; githubUsername: string | undefined; } -export const DownloadDropdown: React.FunctionComponent = ({ - disableAction, - knowledgeFormData, - setActionGroupAlertContent, - githubUsername -}) => { +export const DownloadDropdown: React.FunctionComponent = ({ knowledgeFormData, setActionGroupAlertContent, githubUsername }) => { const [isOpen, setIsOpen] = React.useState(false); const onToggleClick = () => { @@ -45,17 +39,8 @@ export const DownloadDropdown: React.FunctionComponent = ({ shouldFocusToggleOnSelect > - - + + ); diff --git a/src/components/Contribute/Knowledge/DownloadYaml/DownloadYaml.tsx b/src/components/Contribute/Knowledge/DownloadYaml/DownloadYaml.tsx index c1fe5d01..c5990b9e 100644 --- a/src/components/Contribute/Knowledge/DownloadYaml/DownloadYaml.tsx +++ b/src/components/Contribute/Knowledge/DownloadYaml/DownloadYaml.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import { validateFields } from '../validation'; -import { ActionGroupAlertContent, KnowledgeFormData } from '..'; +import { KnowledgeFormData } from '..'; import { KnowledgeYamlData } from '@/types'; import { KnowledgeSchemaVersion } from '@/types/const'; import { dumpYaml } from '@/utils/yamlConfig'; @@ -8,16 +7,12 @@ import { DropdownItem } from '@patternfly/react-core/dist/esm/components/Dropdow import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; interface Props { - disableAction: boolean; knowledgeFormData: KnowledgeFormData; - setActionGroupAlertContent: React.Dispatch>; githubUsername: string | undefined; } -const DownloadYaml: React.FC = ({ disableAction, knowledgeFormData, setActionGroupAlertContent, githubUsername }) => { +const DownloadYaml: React.FC = ({ knowledgeFormData, githubUsername }) => { const handleDownloadYaml = () => { - if (!validateFields(knowledgeFormData, setActionGroupAlertContent)) return; - const yamlData: KnowledgeYamlData = { created_by: githubUsername!, version: KnowledgeSchemaVersion, @@ -48,7 +43,7 @@ const DownloadYaml: React.FC = ({ disableAction, knowledgeFormData, setAc document.body.removeChild(a); }; return ( - + Yaml File ); From da9d3ef19493c1261363da020ba6331bbc1fb855 Mon Sep 17 00:00:00 2001 From: Ash Evans Date: Wed, 9 Oct 2024 10:38:14 +0100 Subject: [PATCH 3/6] allowing skills attribution and yaml viewing Signed-off-by: Ash Evans --- .../Contribute/Skill/ViewDropdown/ViewDropdown.tsx | 7 +++---- src/components/Contribute/Skill/index.tsx | 9 ++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/Contribute/Skill/ViewDropdown/ViewDropdown.tsx b/src/components/Contribute/Skill/ViewDropdown/ViewDropdown.tsx index 8c532b21..29c81e07 100644 --- a/src/components/Contribute/Skill/ViewDropdown/ViewDropdown.tsx +++ b/src/components/Contribute/Skill/ViewDropdown/ViewDropdown.tsx @@ -13,12 +13,11 @@ import FileIcon from '@patternfly/react-icons/dist/dynamic/icons/file-icon'; import EyeIcon from '@patternfly/react-icons/dist/esm/icons/eye-icon'; interface Props { - disableAction: boolean; skillFormData: SkillFormData; githubUsername: string | undefined; } -export const ViewDropdown: React.FunctionComponent = ({ disableAction, skillFormData, githubUsername }) => { +export const ViewDropdown: React.FunctionComponent = ({ skillFormData, githubUsername }) => { const [isOpen, setIsOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false); const [modalContent, setModalContent] = useState(''); @@ -77,10 +76,10 @@ export const ViewDropdown: React.FunctionComponent = ({ disableAction, sk shouldFocusToggleOnSelect > - + YAML Content - + Attribution Content diff --git a/src/components/Contribute/Skill/index.tsx b/src/components/Contribute/Skill/index.tsx index 469cfc32..cb6f08c0 100644 --- a/src/components/Contribute/Skill/index.tsx +++ b/src/components/Contribute/Skill/index.tsx @@ -460,13 +460,8 @@ export const SkillForm: React.FunctionComponent = ({ skillEditFo resetForm={resetForm} /> )} - - + + From 8411aa8ccf27be31613339adf6de9148fdaf6a11 Mon Sep 17 00:00:00 2001 From: Ash Evans Date: Wed, 9 Oct 2024 10:38:58 +0100 Subject: [PATCH 4/6] enabling the download of partially completed skills attribution and yaml Signed-off-by: Ash Evans --- .../DownloadAttribution/DownloadAttribution.tsx | 10 +++------- .../Skill/DownloadDropdown/DownloadDropdown.tsx | 12 +++--------- .../Contribute/Skill/DownloadYaml/DownloadYaml.tsx | 11 +++-------- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/src/components/Contribute/Skill/DownloadAttribution/DownloadAttribution.tsx b/src/components/Contribute/Skill/DownloadAttribution/DownloadAttribution.tsx index 122ca227..1cfb3d67 100644 --- a/src/components/Contribute/Skill/DownloadAttribution/DownloadAttribution.tsx +++ b/src/components/Contribute/Skill/DownloadAttribution/DownloadAttribution.tsx @@ -1,19 +1,15 @@ import React from 'react'; -import { validateFields } from '../validation'; -import { ActionGroupAlertContent, SkillFormData } from '..'; +import { SkillFormData } from '..'; import { DropdownItem } from '@patternfly/react-core/dist/esm/components/Dropdown/DropdownItem'; import FileIcon from '@patternfly/react-icons/dist/esm/icons/file-icon'; interface Props { - disableAction: boolean; skillFormData: SkillFormData; - setActionGroupAlertContent: React.Dispatch>; } -const DownloadAttribution: React.FC = ({ disableAction, skillFormData, setActionGroupAlertContent }) => { +const DownloadAttribution: React.FC = ({ skillFormData }) => { const handleDownloadAttribution = () => { // Because I have overly complicated the validatedFields function all fields are being checked and not just the attribution ones here. Not ideal. - if (!validateFields(skillFormData, setActionGroupAlertContent)) return; const attributionContent = `Title of work: ${skillFormData.titleWork} License of the work: ${skillFormData.licenseWork} @@ -31,7 +27,7 @@ const DownloadAttribution: React.FC = ({ disableAction, skillFormData, se }; return ( - + Attribution File ); diff --git a/src/components/Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx b/src/components/Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx index 0398b00e..7702a849 100644 --- a/src/components/Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx +++ b/src/components/Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx @@ -8,13 +8,12 @@ import { ActionGroupAlertContent, SkillFormData } from '..'; import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon'; interface Props { - disableAction: boolean; skillFormData: SkillFormData; setActionGroupAlertContent: React.Dispatch>; githubUsername: string | undefined; } -export const DownloadDropdown: React.FunctionComponent = ({ disableAction, skillFormData, setActionGroupAlertContent, githubUsername }) => { +export const DownloadDropdown: React.FunctionComponent = ({ skillFormData, setActionGroupAlertContent, githubUsername }) => { const [isOpen, setIsOpen] = React.useState(false); const onToggleClick = () => { @@ -40,13 +39,8 @@ export const DownloadDropdown: React.FunctionComponent = ({ disableAction shouldFocusToggleOnSelect > - - + + ); diff --git a/src/components/Contribute/Skill/DownloadYaml/DownloadYaml.tsx b/src/components/Contribute/Skill/DownloadYaml/DownloadYaml.tsx index 5b1900fb..321fd207 100644 --- a/src/components/Contribute/Skill/DownloadYaml/DownloadYaml.tsx +++ b/src/components/Contribute/Skill/DownloadYaml/DownloadYaml.tsx @@ -1,6 +1,5 @@ import React from 'react'; -import { validateFields } from '../validation'; -import { ActionGroupAlertContent, SkillFormData } from '..'; +import { SkillFormData } from '..'; import { SkillYamlData } from '@/types'; import { dumpYaml } from '@/utils/yamlConfig'; import { DropdownItem } from '@patternfly/react-core/dist/esm/components/Dropdown/DropdownItem'; @@ -8,16 +7,12 @@ import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; import { SkillSchemaVersion } from '@/types/const'; interface Props { - disableAction: boolean; skillFormData: SkillFormData; - setActionGroupAlertContent: React.Dispatch>; githubUsername: string | undefined; } -const DownloadYaml: React.FC = ({ disableAction, skillFormData, setActionGroupAlertContent, githubUsername }) => { +const DownloadYaml: React.FC = ({ skillFormData, githubUsername }) => { const handleDownloadYaml = () => { - if (!validateFields(skillFormData, setActionGroupAlertContent)) return; - const yamlData: SkillYamlData = { created_by: githubUsername!, version: SkillSchemaVersion, @@ -40,7 +35,7 @@ const DownloadYaml: React.FC = ({ disableAction, skillFormData, setAction document.body.removeChild(a); }; return ( - + Yaml File ); From 2fccd6879094433c39d00ebdcf9f5afb072ebbab Mon Sep 17 00:00:00 2001 From: Ash Evans Date: Wed, 9 Oct 2024 10:47:01 +0100 Subject: [PATCH 5/6] removing the unused setActionGroupAlertContent setter function Signed-off-by: Ash Evans --- .../Knowledge/DownloadDropdown/DownloadDropdown.tsx | 4 ++-- .../Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx b/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx index e18c7a0f..78c2aeeb 100644 --- a/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx +++ b/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx @@ -39,8 +39,8 @@ export const DownloadDropdown: React.FunctionComponent = ({ knowledgeForm shouldFocusToggleOnSelect > - - + + ); diff --git a/src/components/Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx b/src/components/Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx index 7702a849..60fb9909 100644 --- a/src/components/Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx +++ b/src/components/Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx @@ -39,8 +39,8 @@ export const DownloadDropdown: React.FunctionComponent = ({ skillFormData shouldFocusToggleOnSelect > - - + + ); From 044054f882bf4b45bbb889bbfe20f813f1931b88 Mon Sep 17 00:00:00 2001 From: Ash Evans Date: Wed, 9 Oct 2024 10:55:08 +0100 Subject: [PATCH 6/6] removing redundant setActionGroupAlertContent setter functions Signed-off-by: Ash Evans --- .../Knowledge/DownloadDropdown/DownloadDropdown.tsx | 5 ++--- src/components/Contribute/Knowledge/index.tsx | 6 +----- .../Contribute/Skill/DownloadDropdown/DownloadDropdown.tsx | 5 ++--- src/components/Contribute/Skill/index.tsx | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx b/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx index 78c2aeeb..c7aa0dca 100644 --- a/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx +++ b/src/components/Contribute/Knowledge/DownloadDropdown/DownloadDropdown.tsx @@ -4,16 +4,15 @@ 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 { ActionGroupAlertContent, KnowledgeFormData } from '..'; +import { KnowledgeFormData } from '..'; import DownloadIcon from '@patternfly/react-icons/dist/esm/icons/download-icon'; interface Props { knowledgeFormData: KnowledgeFormData; - setActionGroupAlertContent: React.Dispatch>; githubUsername: string | undefined; } -export const DownloadDropdown: React.FunctionComponent = ({ knowledgeFormData, setActionGroupAlertContent, githubUsername }) => { +export const DownloadDropdown: React.FunctionComponent = ({ knowledgeFormData, githubUsername }) => { const [isOpen, setIsOpen] = React.useState(false); const onToggleClick = () => { diff --git a/src/components/Contribute/Knowledge/index.tsx b/src/components/Contribute/Knowledge/index.tsx index 1592b66b..5ec3ed16 100644 --- a/src/components/Contribute/Knowledge/index.tsx +++ b/src/components/Contribute/Knowledge/index.tsx @@ -587,11 +587,7 @@ export const KnowledgeForm: React.FunctionComponent = ({ kno resetForm={resetForm} /> )} - +