From 8554cd5206f2464764345b6f1770c428d1052bba Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Fri, 11 Oct 2024 16:19:24 +1030 Subject: [PATCH] fix: various misspellings in code and comments --- .../ContentTagsCollapsible.test.jsx | 2 +- .../ContentTagsCollapsibleHelper.jsx | 6 +-- .../ContentTagsDrawer.test.jsx | 4 +- src/content-tags-drawer/ContentTagsDrawer.tsx | 4 +- .../ContentTagsDrawerHelper.jsx | 46 +++++++++---------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/content-tags-drawer/ContentTagsCollapsible.test.jsx b/src/content-tags-drawer/ContentTagsCollapsible.test.jsx index 0c36c8a49f..a5e6fbe37c 100644 --- a/src/content-tags-drawer/ContentTagsCollapsible.test.jsx +++ b/src/content-tags-drawer/ContentTagsCollapsible.test.jsx @@ -420,7 +420,7 @@ describe('', () => { expect(data.removeGlobalStagedContentTag).toHaveBeenCalledWith(taxonomyId, 'Tag 3'); }); - it('should call `addRemovedContentTag` when a feched tag is deleted', async () => { + it('should call `addRemovedContentTag` when a fetched tag is deleted', async () => { await getComponent(); const tag = screen.getByText(/tag 2/i); diff --git a/src/content-tags-drawer/ContentTagsCollapsibleHelper.jsx b/src/content-tags-drawer/ContentTagsCollapsibleHelper.jsx index b1d7a09e15..dcc016ab8a 100644 --- a/src/content-tags-drawer/ContentTagsCollapsibleHelper.jsx +++ b/src/content-tags-drawer/ContentTagsCollapsibleHelper.jsx @@ -116,7 +116,7 @@ const useContentTagsCollapsibleHelper = ( // State to keep track of the staged tags (and along with ancestors) that should be removed const [stagedTagsToRemove, setStagedTagsToRemove] = React.useState(/** @type string[] */([])); - // State to keep track of the global tags (stagged and feched) that should be removed + // State to keep track of the global tags (staged and fetched) that should be removed const [globalTagsToRemove, setGlobalTagsToRemove] = React.useState(/** @type string[] */([])); // Handles the removal of staged content tags based on what was removed @@ -140,7 +140,7 @@ const useContentTagsCollapsibleHelper = ( // A new tag has been removed removeGlobalStagedContentTag(id, tag); } else if (contentTags.some(t => t.value === tag)) { - // A feched tag has been removed + // A fetched tag has been removed addRemovedContentTag(id, tag); } }); @@ -157,7 +157,7 @@ const useContentTagsCollapsibleHelper = ( explicitStaged.forEach((tag) => { if (globalStagedRemovedContentTags[id] && globalStagedRemovedContentTags[id].includes(tag.value)) { - // A feched tag that has been removed has been added again + // A fetched tag that has been removed has been added again deleteRemovedContentTag(id, tag.value); } else { // New tag added diff --git a/src/content-tags-drawer/ContentTagsDrawer.test.jsx b/src/content-tags-drawer/ContentTagsDrawer.test.jsx index 83679c1aaa..91ad97d8fc 100644 --- a/src/content-tags-drawer/ContentTagsDrawer.test.jsx +++ b/src/content-tags-drawer/ContentTagsDrawer.test.jsx @@ -391,7 +391,7 @@ describe('', () => { expect(screen.queryByText(/tag 3/i)).not.toBeInTheDocument(); }); - it('should test delete feched tags and cancel', async () => { + it('should test delete fetched tags and cancel', async () => { renderDrawer(stagedTagsId); expect(await screen.findByText('Taxonomy 1')).toBeInTheDocument(); @@ -458,7 +458,7 @@ describe('', () => { expect(screen.queryByText(/tag 3/i)).not.toBeInTheDocument(); }); - it('should test add removed feched tags and cancel', async () => { + it('should test add removed fetched tags and cancel', async () => { renderDrawer(stagedTagsId); expect(await screen.findByText('Taxonomy 1')).toBeInTheDocument(); diff --git a/src/content-tags-drawer/ContentTagsDrawer.tsx b/src/content-tags-drawer/ContentTagsDrawer.tsx index 49b9df4e25..040cce196b 100644 --- a/src/content-tags-drawer/ContentTagsDrawer.tsx +++ b/src/content-tags-drawer/ContentTagsDrawer.tsx @@ -73,7 +73,7 @@ const TaxonomyList = ({ contentId }: TaxonomyListProps) => { return ; }; -const ContentTagsDrawerTittle = () => { +const ContentTagsDrawerTitle = () => { const intl = useIntl(); const { isContentDataLoaded, @@ -338,7 +338,7 @@ const ContentTagsDrawer = ({ )} > {variant === 'drawer' && ( - + )} { const [stagedContentTags, setStagedContentTags] = React.useState({}); // When a staged tags on a taxonomy is commitet then is saved on this map. const [globalStagedContentTags, setGlobalStagedContentTags] = React.useState({}); - // This stores feched tags deleted by the user. + // This stores fetched tags deleted by the user. const [globalStagedRemovedContentTags, setGlobalStagedRemovedContentTags] = React.useState({}); - // Merges feched tags, global staged tags and global removed staged tags + // Merges fetched tags, global staged tags and global removed staged tags const [tagsByTaxonomy, setTagsByTaxonomy] = React.useState(/** @type TagsInTaxonomy[] */ ([])); // Other taxonomies that the user doesn't have permissions const [otherTaxonomies, setOtherTaxonomies] = React.useState(/** @type TagsInTaxonomy[] */ ([])); @@ -80,8 +80,8 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => { } = useContentTaxonomyTagsData(contentId); const { data: taxonomyListData, isSuccess: isTaxonomyListLoaded } = useTaxonomyList(org); - // Tags feched from database - const { fechedTaxonomies, fechedOtherTaxonomies } = React.useMemo(() => { + // Tags fetched from database + const { fetchedTaxonomies, fetchedOtherTaxonomies } = React.useMemo(() => { const sortTaxonomies = (taxonomiesList) => { const taxonomiesWithData = taxonomiesList.filter( (t) => t.contentTags.length !== 0, @@ -151,13 +151,13 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => { ); return { - fechedTaxonomies: sortTaxonomies(filteredTaxonomies), - fechedOtherTaxonomies: otherTaxonomiesList, + fetchedTaxonomies: sortTaxonomies(filteredTaxonomies), + fetchedOtherTaxonomies: otherTaxonomiesList, }; } return { - fechedTaxonomies: [], - fechedOtherTaxonomies: [], + fetchedTaxonomies: [], + fetchedOtherTaxonomies: [], }; }, [taxonomyListData, contentTaxonomyTagsData]); @@ -232,28 +232,28 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => { const openAllCollapsible = React.useCallback(() => { const updatedState = {}; - fechedTaxonomies.forEach((taxonomy) => { + fetchedTaxonomies.forEach((taxonomy) => { updatedState[taxonomy.id] = true; }); - fechedOtherTaxonomies.forEach((taxonomy) => { + fetchedOtherTaxonomies.forEach((taxonomy) => { updatedState[taxonomy.id] = true; }); setColapsibleStates(updatedState); - }, [fechedTaxonomies, setColapsibleStates]); + }, [fetchedTaxonomies, setColapsibleStates]); // Set initial state of collapsible based on content tags const setCollapsibleToInitalState = React.useCallback(() => { const updatedState = {}; - fechedTaxonomies.forEach((taxonomy) => { + fetchedTaxonomies.forEach((taxonomy) => { // Taxonomy with content tags must be open updatedState[taxonomy.id] = taxonomy.contentTags.length !== 0; }); - fechedOtherTaxonomies.forEach((taxonomy) => { + fetchedOtherTaxonomies.forEach((taxonomy) => { // Taxonomy with content tags must be open updatedState[taxonomy.id] = taxonomy.contentTags.length !== 0; }); setColapsibleStates(updatedState); - }, [fechedTaxonomies, setColapsibleStates]); + }, [fetchedTaxonomies, setColapsibleStates]); // Changes the drawer mode to edit const toEditMode = React.useCallback(() => { @@ -341,14 +341,14 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => { } } - // Updates `tagsByTaxonomy` merged feched tags, global staged tags + // Updates `tagsByTaxonomy` merged fetched tags, global staged tags // and global removed staged tags. React.useEffect(() => { - const mergedTags = cloneDeep(fechedTaxonomies).reduce((acc, obj) => ( + const mergedTags = cloneDeep(fetchedTaxonomies).reduce((acc, obj) => ( { ...acc, [obj.id]: obj } ), {}); - const mergedOtherTaxonomies = cloneDeep(fechedOtherTaxonomies).reduce((acc, obj) => ( + const mergedOtherTaxonomies = cloneDeep(fetchedOtherTaxonomies).reduce((acc, obj) => ( { ...acc, [obj.id]: obj } ), {}); @@ -357,10 +357,10 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => { // TODO test this // Filter out applied tags that should become implicit because a child tag was committed const stagedLineages = globalStagedContentTags[taxonomyId].map((t) => t.lineage.slice(0, -1)).flat(); - const fechedTags = mergedTags[taxonomyId].contentTags.filter((t) => !stagedLineages.includes(t.value)); + const fetchedTags = mergedTags[taxonomyId].contentTags.filter((t) => !stagedLineages.includes(t.value)); mergedTags[taxonomyId].contentTags = [ - ...fechedTags, + ...fetchedTags, ...globalStagedContentTags[taxonomyId], ]; } @@ -379,8 +379,8 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => { }); // It is constructed this way to maintain the order - // of the list `fechedTaxonomies` - const mergedTagsArray = fechedTaxonomies.map(obj => mergedTags[obj.id]); + // of the list `fetchedTaxonomies` + const mergedTagsArray = fetchedTaxonomies.map(obj => mergedTags[obj.id]); setTagsByTaxonomy(mergedTagsArray); setOtherTaxonomies(Object.values(mergedOtherTaxonomies)); @@ -410,8 +410,8 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => { } } }, [ - fechedTaxonomies, - fechedOtherTaxonomies, + fetchedTaxonomies, + fetchedOtherTaxonomies, globalStagedContentTags, globalStagedRemovedContentTags, ]);