Skip to content

Commit

Permalink
fix: various misspellings in code and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pomegranited committed Oct 11, 2024
1 parent 43783a0 commit 8554cd5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/content-tags-drawer/ContentTagsCollapsible.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ describe('<ContentTagsCollapsible />', () => {
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);
Expand Down
6 changes: 3 additions & 3 deletions src/content-tags-drawer/ContentTagsCollapsibleHelper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
});
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/content-tags-drawer/ContentTagsDrawer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ describe('<ContentTagsDrawer />', () => {
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();

Expand Down Expand Up @@ -458,7 +458,7 @@ describe('<ContentTagsDrawer />', () => {
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();

Expand Down
4 changes: 2 additions & 2 deletions src/content-tags-drawer/ContentTagsDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const TaxonomyList = ({ contentId }: TaxonomyListProps) => {
return <Loading />;
};

const ContentTagsDrawerTittle = () => {
const ContentTagsDrawerTitle = () => {
const intl = useIntl();
const {
isContentDataLoaded,
Expand Down Expand Up @@ -338,7 +338,7 @@ const ContentTagsDrawer = ({
)}
>
{variant === 'drawer' && (
<ContentTagsDrawerTittle />
<ContentTagsDrawerTitle />
)}
<Container
className={classNames(
Expand Down
46 changes: 23 additions & 23 deletions src/content-tags-drawer/ContentTagsDrawerHelper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => {
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[] */ ([]));
Expand All @@ -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,
Expand Down Expand Up @@ -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]);

Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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 }
), {});

Expand All @@ -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],
];
}
Expand All @@ -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));
Expand Down Expand Up @@ -410,8 +410,8 @@ const useContentTagsDrawerContext = (contentId, canTagObject) => {
}
}
}, [
fechedTaxonomies,
fechedOtherTaxonomies,
fetchedTaxonomies,
fetchedOtherTaxonomies,
globalStagedContentTags,
globalStagedRemovedContentTags,
]);
Expand Down

0 comments on commit 8554cd5

Please sign in to comment.