diff --git a/cheathub.und/id.txt b/cheathub.und/id.txt
new file mode 100644
index 0000000..f57c6fa
--- /dev/null
+++ b/cheathub.und/id.txt
@@ -0,0 +1 @@
+{257e2b4c-73dd-46ad-ac9a-f0a1ab5c2ffa}
\ No newline at end of file
diff --git a/cheathub.und/settings.xml b/cheathub.und/settings.xml
new file mode 100644
index 0000000..a4eb7eb
--- /dev/null
+++ b/cheathub.und/settings.xml
@@ -0,0 +1,289 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components_smells.csv b/components_smells.csv
new file mode 100644
index 0000000..e969556
--- /dev/null
+++ b/components_smells.csv
@@ -0,0 +1,27 @@
+id,file,Component,Smell,Details,"Em uma escala de 1 a 5, como você avalia a relevância desse smell?
+1 = smell não é importante e, provavelmente, não será refatorado
+5 = smell é muito importante e, provavelmente, será refatorado em breve.",Observação
+1,C:\Program Files\projects\cheathub\frontend\src\components\collections\collection\index.tsx,CollectionItem,Large Component,LOC: 142; Number of props: 18; Number of attributes: 0; Number of methods: 0,,
+2,C:\Program Files\projects\cheathub\frontend\src\components\collections\collection\index.tsx,CollectionItem,Too many props,"Number of props: 18; Props: collection,id,index,setId,expanded,setExpanded,setSelections,selectedSnippetId,setSelectedSnippetId,setExpandedSnippet,setHeading,readonly,bg,open,collapsed,duration,ease,borderRadius",,
+3,C:\Program Files\projects\cheathub\frontend\src\components\collections\crud\index.tsx,CollectionCrud,Large Component,LOC: 246; Number of props: 21; Number of attributes: 0; Number of methods: 0,,
+4,C:\Program Files\projects\cheathub\frontend\src\components\collections\crud\index.tsx,CollectionCrud,Too many props,"Number of props: 21; Props: name,setName,handleSubmit,handleDelete,snippets,setSnippets,handleCancel,setAlert,editing,deleting,submitting,snippetsOptions,open,collapsed,duration,ease,menu,borderRadius,borderColor,spacing,colors",,
+5,C:\Program Files\projects\cheathub\frontend\src\components\collections\snippets\index.tsx,SnippetItem,Large Component,LOC: 160; Number of props: 17; Number of attributes: 0; Number of methods: 0,,
+6,C:\Program Files\projects\cheathub\frontend\src\components\collections\snippets\index.tsx,SnippetItem,Too many props,"Number of props: 17; Props: snippet,index,selectedSnippetId,setSelectedSnippetId,expandedSnippet,setExpandedSnippet,editing,username,setTags,faveSnippet,handleFave,faving,border,open,collapsed,duration,ease",,
+7,C:\Program Files\projects\cheathub\frontend\src\components\navigation\actions\index.tsx,Actions,Large Component,LOC: 206; Number of props: 13; Number of attributes: 0; Number of methods: 0,,
+8,C:\Program Files\projects\cheathub\frontend\src\components\search\search-bar.tsx,SearchBar,Large Component,LOC: 137; Number of props: 18; Number of attributes: 0; Number of methods: 0,,
+9,C:\Program Files\projects\cheathub\frontend\src\components\search\search-bar.tsx,SearchBar,Too many props,"Number of props: 18; Props: searchText,onSearchTextChange,language,onLanguageChange,tags,onTagsChange,allTags,resetAll,heading,children,value,label,base,lg,open,collapsed,duration,ease",,
+10,C:\Program Files\projects\cheathub\frontend\src\containers\default.container.tsx,Page,Large Component,LOC: 120; Number of props: 22; Number of attributes: 0; Number of methods: 0,,
+11,C:\Program Files\projects\cheathub\frontend\src\containers\default.container.tsx,Page,Too many props,"Number of props: 22; Props: primary,primaryHeading,primaryChildren,primaryFooterHeading,primaryFooterSubheading,secondary,secondaryHeading,secondaryChildren,secondaryFooterHeading,secondaryFooterSubheading,preSecondaryChildren,postSecondaryChildren,modals,drawers,pagination,search,icon,width,background,borderRadius,base,lg",,
+12,C:\Program Files\projects\cheathub\frontend\src\context\appdata.context.tsx,AppDataProvider,Large Component,LOC: 135; Number of props: 24; Number of attributes: 0; Number of methods: 6,,
+13,C:\Program Files\projects\cheathub\frontend\src\context\appdata.context.tsx,AppDataProvider,Too many props,"Number of props: 24; Props: children,label,value,target,loadInitialData,loadResultsData,loadAllTags,data,setData,searchText,setSearchText,onSearchTextChange,language,setLanguage,onLanguageChange,tags,setTags,onTagChange,page,setPage,loading,setLoading,allTags,setAllTags",,
+14,C:\Program Files\projects\cheathub\frontend\src\context\collectionhandler.tsx,CollectionHandlerProvider,Large Component,LOC: 244; Number of props: 35; Number of attributes: 0; Number of methods: 4,,
+15,C:\Program Files\projects\cheathub\frontend\src\context\collectionhandler.tsx,CollectionHandlerProvider,Too many props,"Number of props: 35; Props: children,accessToken,loadCollectionsData,loadSnippetsOptions,label,value,duration,isClosable,render,selected,setSelected,selections,setSelections,loadingSelected,setLoadingSelected,selectedId,setSelectedId,handleSubmit,handleDelete,handleCancel,id,setId,name,setName,snippets,setSnippets,submitting,setSubmitting,deleting,setDeleting,editing,setEditing,alert,setAlert,clearValues",,
+16,C:\Program Files\projects\cheathub\frontend\src\context\datahandler.context.tsx,DataHandlerProvider,Large Component,LOC: 315; Number of props: 46; Number of attributes: 0; Number of methods: 5,,
+17,C:\Program Files\projects\cheathub\frontend\src\context\datahandler.context.tsx,DataHandlerProvider,Too many props,"Number of props: 46; Props: children,username,accessToken,loadInitialData,loadSnippetsData,loadFaveSnippets,loadCollectionsOptions,loadCollectionsData,loadSnippetsOptions,duration,isClosable,render,title,setTitle,value,setValue,description,setDescription,language,setLanguage,tags,setTags,source,setSource,privatize,setPrivatize,id,setId,submitting,setSubmitting,deleting,setDeleting,editing,setEditing,alert,setAlert,heading,setHeading,clearValues,faving,faveSnippet,setFaveSnippet,handleFave,handleDelete,handleCancel,handleSubmit",,
+18,C:\Program Files\projects\cheathub\frontend\src\context\profiledata.context.tsx,ProfileDataProvider,Large Component,LOC: 121; Number of props: 26; Number of attributes: 0; Number of methods: 5,,
+19,C:\Program Files\projects\cheathub\frontend\src\context\profiledata.context.tsx,ProfileDataProvider,Too many props,"Number of props: 26; Props: children,username,loggedIn,label,value,loadSnippetsData,loadCollectionsData,collectionsProfile,setCollectionsProfile,loadingCollections,setLoadingCollections,snippetsProfile,setSnippetsProfile,loadingSnippets,setLoadingSnippets,loadFaveSnippets,setFaveSnippets,faveSnippets,loadingFaves,setLoadingFaves,snippetsOptions,setSnippetsOptions,loadSnippetsOptions,collectionsOptions,setCollectionsOptions,loadCollectionsOptions",,
+20,C:\Program Files\projects\cheathub\frontend\src\pages\about.tsx,ProfileCard,Large Component,LOC: 135; Number of props: 8; Number of attributes: 0; Number of methods: 0,,
+21,C:\Program Files\projects\cheathub\frontend\src\pages\home.tsx,Home,Large Component,LOC: 89; Number of props: 16; Number of attributes: 0; Number of methods: 0,,
+22,C:\Program Files\projects\cheathub\frontend\src\pages\home.tsx,Home,Too many props,"Number of props: 16; Props: match,username,setUsername,email,setEmail,password,setPassword,returning,setReturning,loading,handleSignIn,data,setTags,handleFave,faveSnippet,faving",,
+23,C:\Program Files\projects\cheathub\frontend\src\pages\snippets.tsx,Snippets,Large Component,LOC: 166; Number of props: 20; Number of attributes: 0; Number of methods: 1,,
+24,C:\Program Files\projects\cheathub\frontend\src\pages\snippets.tsx,Snippets,Too many props,"Number of props: 20; Props: data,loading,searchText,setSearchText,onSearchTextChange,language,setLanguage,onLanguageChange,tags,setTags,onTagChange,page,setPage,allTags,loadInitialData,faveSnippet,handleFave,faving,username,accessToken",,
diff --git a/files_smells.csv b/files_smells.csv
new file mode 100644
index 0000000..bd5e911
--- /dev/null
+++ b/files_smells.csv
@@ -0,0 +1,13 @@
+id,Large File,File URL,LOC,N_Components,N_Functions,N_Imports,"Em uma escala de 1 a 5, como você avalia a relevância desse smell?
+1 = smell não é importante e, provavelmente, não será refatorado
+5 = smell é muito importante e, provavelmente, será refatorado em breve.",Observação
+1,C:\Program Files\projects\cheathub\frontend\src\components\collections\crud\index.tsx,C:\Program Files\projects\cheathub\frontend\src\components\collections\crud\index.tsx,294,1,0,15,,
+2,C:\Program Files\projects\cheathub\frontend\src\components\collections\snippets\index.tsx,C:\Program Files\projects\cheathub\frontend\src\components\collections\snippets\index.tsx,214,1,0,22,,
+3,C:\Program Files\projects\cheathub\frontend\src\components\modals\auth-prompt.tsx,C:\Program Files\projects\cheathub\frontend\src\components\modals\auth-prompt.tsx,104,1,0,21,,
+4,C:\Program Files\projects\cheathub\frontend\src\components\navigation\account\index.tsx,C:\Program Files\projects\cheathub\frontend\src\components\navigation\account\index.tsx,117,1,0,21,,
+5,C:\Program Files\projects\cheathub\frontend\src\components\navigation\actions\index.tsx,C:\Program Files\projects\cheathub\frontend\src\components\navigation\actions\index.tsx,248,1,0,23,,
+6,C:\Program Files\projects\cheathub\frontend\src\components\shared\brand-button.tsx,C:\Program Files\projects\cheathub\frontend\src\components\shared\brand-button.tsx,80,4,0,5,,
+7,C:\Program Files\projects\cheathub\frontend\src\components\snippet\body\elements.tsx,C:\Program Files\projects\cheathub\frontend\src\components\snippet\body\elements.tsx,469,8,0,37,,
+8,C:\Program Files\projects\cheathub\frontend\src\context\collectionhandler.tsx,C:\Program Files\projects\cheathub\frontend\src\context\collectionhandler.tsx,306,1,1,10,,
+9,C:\Program Files\projects\cheathub\frontend\src\context\datahandler.context.tsx,C:\Program Files\projects\cheathub\frontend\src\context\datahandler.context.tsx,388,1,1,11,,
+10,C:\Program Files\projects\cheathub\frontend\src\pages\about.tsx,C:\Program Files\projects\cheathub\frontend\src\pages\about.tsx,542,7,0,35,,
diff --git a/frontend/frontend.und/id.txt b/frontend/frontend.und/id.txt
new file mode 100644
index 0000000..a0512e5
--- /dev/null
+++ b/frontend/frontend.und/id.txt
@@ -0,0 +1 @@
+{ff246c4e-8ebb-4fe5-bd91-27cec3a04bac}
\ No newline at end of file
diff --git a/frontend/frontend.und/settings.xml b/frontend/frontend.und/settings.xml
new file mode 100644
index 0000000..b006994
--- /dev/null
+++ b/frontend/frontend.und/settings.xml
@@ -0,0 +1,274 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/package.json b/frontend/package.json
index fc4b975..348d691 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -17,7 +17,6 @@
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.37",
- "@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"@types/react-router-dom": "^5.1.7",
"@types/react-select": "^4.0.15",
@@ -71,6 +70,7 @@
"styled-components": "^5"
},
"devDependencies": {
+ "@types/react": "^18.3.12",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"babel-eslint": "^10.1.0",
diff --git a/frontend/src/components/collections/crud/index.tsx b/frontend/src/components/collections/crud/index.tsx
index c953c49..536a036 100644
--- a/frontend/src/components/collections/crud/index.tsx
+++ b/frontend/src/components/collections/crud/index.tsx
@@ -1,37 +1,10 @@
-/* eslint-disable @typescript-eslint/no-shadow */
-/* eslint-disable @typescript-eslint/no-explicit-any */
-
import React from 'react';
-import {
- FormControl,
- FormHelperText,
- Box,
- Input,
- Flex,
- useMediaQuery,
- useColorModeValue as mode,
-} from '@chakra-ui/react';
-import Select from 'react-select';
-
+import { Box, useMediaQuery, useColorModeValue as mode } from '@chakra-ui/react';
import { AnimatePresence } from 'framer-motion';
+import { MotionBar } from '../../shared/motion';
+import CollectionForm from './CollectionForm';
+import CollectionFooter from './CollectionFooter';
-import { BrandButton } from '../../shared/brand-button';
-import { StyledLabel } from '../../snippet/crud/form-label';
-import { MotionForm, MotionBar } from '../../shared/motion';
-import { SecondaryFooter } from '../../shared/particulars';
-import './styles.css';
-import { useProfileData } from '../../../context/profiledata.context';
-
-/**
- * Component for CRUD operations of a collection.
- *
- * A form counterpart of CollectionItem
- * Relies on State and setState props passed by Collection page.
- * TODO Update default value of MultiSelect
- * @see CollectionItem
- * @file defines Collection form.
- * @date 2021-05-03
- */
const CollectionCrud: React.FC<{
name: string;
setName: React.Dispatch>;
@@ -57,14 +30,7 @@ const CollectionCrud: React.FC<{
deleting,
submitting,
}) => {
- const { snippetsOptions } = useProfileData();
- const color = mode('light', 'dark');
const [baseLg] = useMediaQuery('(min-width: 62em)');
- // React.useEffect(() => {
- // if (snippets.length < 1) {
- // setSnippets([]);
- // }
- // }, [snippets]);
return (
<>
@@ -90,204 +56,26 @@ const CollectionCrud: React.FC<{
}}
positionTransition
>
- <>
-
-
-
- setName(e.target.value)}
- />
- Name.
-
-
-
-
-
- >
+
-
-
- {editing && (
-
- setAlert(true)}
- >
- Delete
-
-
- )}
-
-
- Cancel
-
-
-
- {editing ? 'Update' : 'Add'}
-
-
-
+
>
);
};
-export default CollectionCrud;
+
+export default CollectionCrud;
\ No newline at end of file
diff --git a/frontend/src/components/collections/ui/footer.tsx b/frontend/src/components/collections/ui/footer.tsx
new file mode 100644
index 0000000..a8c8e1e
--- /dev/null
+++ b/frontend/src/components/collections/ui/footer.tsx
@@ -0,0 +1,88 @@
+import React from 'react';
+import { Box } from '@chakra-ui/react';
+import { BrandButton } from '../../shared/brand-button';
+import { MotionForm } from '../../shared/motion';
+import { SecondaryFooter } from '../../shared/particulars';
+
+interface CollectionFooterProps {
+ editing: boolean;
+ deleting: boolean | undefined;
+ submitting: boolean;
+ handleDelete: React.FormEventHandler;
+ handleCancel: React.MouseEventHandler;
+ setAlert: React.Dispatch>;
+}
+
+const CollectionFooter: React.FC = ({
+ editing,
+ deleting,
+ submitting,
+ handleDelete,
+ handleCancel,
+ setAlert,
+}) => {
+ const [baseLg] = useMediaQuery('(min-width: 62em)');
+
+ return (
+
+
+ {editing && (
+
+ setAlert(true)}
+ >
+ Delete
+
+
+ )}
+
+
+ Cancel
+
+
+
+ {editing ? 'Update' : 'Add'}
+
+
+
+ );
+};
+
+export default CollectionFooter;
+import { useState, useEffect } from 'react';
+
+function useMediaQuery(query: string): [boolean] {
+ const [matches, setMatches] = useState(false);
+
+ useEffect(() => {
+ const mediaQueryList = window.matchMedia(query);
+ const documentChangeHandler = () => setMatches(mediaQueryList.matches);
+
+ mediaQueryList.addEventListener('change', documentChangeHandler);
+ documentChangeHandler(); // Set the initial state
+
+ return () => {
+ mediaQueryList.removeEventListener('change', documentChangeHandler);
+ };
+ }, [query]);
+
+ return [matches];
+}
+
diff --git a/frontend/src/components/collections/ui/form.tsx b/frontend/src/components/collections/ui/form.tsx
new file mode 100644
index 0000000..cfba478
--- /dev/null
+++ b/frontend/src/components/collections/ui/form.tsx
@@ -0,0 +1,169 @@
+import React from 'react';
+import {
+ FormControl,
+ FormHelperText,
+ Input,
+} from '@chakra-ui/react';
+import Select from 'react-select';
+import { StyledLabel } from '../../snippet/crud/form-label';
+import { MotionForm } from '../../shared/motion';
+import { useProfileData } from '../../../context/profiledata.context';
+
+interface CollectionFormProps {
+ name: string;
+ setName: React.Dispatch>;
+ snippets: Options[];
+ setSnippets: (snippetz: Options[]) => void;
+ handleSubmit: React.FormEventHandler;
+}
+
+const CollectionForm: React.FC = ({
+ name,
+ setName,
+ snippets,
+ setSnippets,
+ handleSubmit,
+}) => {
+ const { snippetsOptions } = useProfileData();
+ const color = mode('light', 'dark');
+
+ const mode = (light: string, dark: string) => {
+ return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? dark : light;
+ };
+
+ return (
+
+
+
+ setName(e.target.value)}
+ />
+ Name.
+
+
+
+
+
+ );
+};
+
+export default CollectionForm;
\ No newline at end of file
diff --git a/frontend/src/pages/snippet.tsx b/frontend/src/pages/snippet.tsx
index bc5830c..ffd707e 100644
--- a/frontend/src/pages/snippet.tsx
+++ b/frontend/src/pages/snippet.tsx
@@ -1,34 +1,18 @@
import * as React from 'react';
-
import { RouteComponentProps } from 'react-router';
import { useMediaQuery, Box } from '@chakra-ui/react';
-
import SnippetCard from '../components/snippet/card';
import SnippetCrud from '../components/snippet/crud';
import { DeleteModal } from '../components/modals/delete-modal';
-
import { getRequest } from '../services/crud.service';
-
import { useDataHandler } from '../context/datahandler.context';
import { useUserContext } from '../context/user.context';
-
import Page from '../containers/default.container';
import { GoBackButton } from '../components/shared/brand-button';
import LoadSpinner from '../components/shared/spinner';
-interface SnippetPageProps
- extends RouteComponentProps<{ id: string }> {}
+interface SnippetPageProps extends RouteComponentProps<{ id: string }> {}
-/**
- * Frontend private endpoint that represents a single code snippet post.
- * Selected by `_id`.
- * CRUD operations begin from this component tree.
- * @file defines route for one unique Snippet.
- * @date 2021-04-21
- * @param {any} match
- * @param {any} history
- * @return {=>}
- */
const Snippet: React.FC = ({ match }) => {
const {
title,
@@ -104,30 +88,48 @@ const Snippet: React.FC = ({ match }) => {
}
}, [snippet]);
+ const snippetProps = {
+ title,
+ setTitle,
+ value,
+ setValue,
+ description,
+ setDescription,
+ language,
+ setLanguage,
+ tags,
+ setTags,
+ source,
+ setSource,
+ privatize,
+ setPrivatize,
+ id,
+ setId,
+ };
+
+ const editingProps = {
+ editing,
+ setEditing,
+ submitting,
+ deleting,
+ alert,
+ setAlert,
+ heading,
+ setHeading,
+ clearValues,
+ faving,
+ faveSnippet,
+ handleFave,
+ handleDelete,
+ handleCancel,
+ handleSubmit,
+ };
+
const secondary = (
);
@@ -137,17 +139,10 @@ const Snippet: React.FC = ({ match }) => {
) : (
= ({ match }) => {
const secondaryHeading = heading;
const primaryHeading = heading;
const primaryChildren = Go Back;
+
return (
<>
= ({ match }) => {
);
};
-export default Snippet;
+export default Snippet;
\ No newline at end of file