Skip to content

Commit

Permalink
Merge pull request #1774 from isomerpages/release/0.70.0
Browse files Browse the repository at this point in the history
Release/0.70.0
  • Loading branch information
harishv7 authored Jan 11, 2024
2 parents 50ced63 + 5e94ef6 commit cff63f5
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 104 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @isomerpages/iso-engineers
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,23 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.70.0](https://github.com/isomerpages/isomercms-frontend/compare/v0.69.0...v0.70.0)

- IS-846 fix copy for new rte [`#1769`](https://github.com/isomerpages/isomercms-frontend/pull/1769)
- fix: header spacing [`#1772`](https://github.com/isomerpages/isomercms-frontend/pull/1772)
- fix(cards): prevent overflowing of cards by enforcing width [`#1771`](https://github.com/isomerpages/isomercms-frontend/pull/1771)
- Chore/upgrade axios [`#1767`](https://github.com/isomerpages/isomercms-frontend/pull/1767)
- feat(codeowner): make life easier [`#1765`](https://github.com/isomerpages/isomercms-frontend/pull/1765)
- chore: fix styling for review request files [`#1764`](https://github.com/isomerpages/isomercms-frontend/pull/1764)
- chore: reset staging url when privatising site [`#1763`](https://github.com/isomerpages/isomercms-frontend/pull/1763)
- fix(styles): fix overlapping page title issue [`#1762`](https://github.com/isomerpages/isomercms-frontend/pull/1762)
- fix(media): enhance bulk delete for media images [`#1753`](https://github.com/isomerpages/isomercms-frontend/pull/1753)
- release/0.69.0 [`#1759`](https://github.com/isomerpages/isomercms-frontend/pull/1759)

#### [v0.69.0](https://github.com/isomerpages/isomercms-frontend/compare/v0.68.0...v0.69.0)

> 21 December 2023
- fix: limit for get media [`#1758`](https://github.com/isomerpages/isomercms-frontend/pull/1758)
- release/0.68.0 [`#1756`](https://github.com/isomerpages/isomercms-frontend/pull/1756)

Expand Down
46 changes: 38 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "isomercms-frontend",
"version": "0.69.0",
"version": "0.70.0",
"private": true,
"engines": {
"node": ">=16.0.0"
Expand Down Expand Up @@ -48,7 +48,7 @@
"@tiptap/pm": "^2.1.12",
"@tiptap/react": "^2.1.12",
"@tiptap/starter-kit": "^2.1.12",
"axios": "^0.21.3",
"axios": "^1.6.5",
"bluebird": "^3.7.1",
"bootstrap": "^4.6.0",
"cheerio": "^1.0.0-rc.10",
Expand Down
18 changes: 13 additions & 5 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ const Header = ({
bg="white"
h="4rem"
w="100%"
gap="1.5rem"
>
<HStack spacing="1.25rem" flex={1}>
<HStack spacing="1.25rem" flex="0 1 content">
{!showButton ? (
<Box w="180px">
<img
Expand All @@ -120,19 +121,26 @@ const Header = ({
}
onClick={handleBackNav}
/>
<Text color="text.label" textStyle="body-1">
<Text color="text.label" textStyle="body-1" noOfLines={1}>
{backButtonTextFromParams || backButtonText}
</Text>
</>
)}
</HStack>
{/* <Spacer /> */}
{title ? (
<Flex minWidth="-webkit-min-content" alignItems="center">
<Text textStyle="h5">{title}</Text>
<Flex
minWidth="-webkit-min-content"
alignItems="center"
flex={1}
justifyContent="center"
>
<Text textStyle="h5" noOfLines={1}>
{title}
</Text>
</Flex>
) : null}
<HStack flex={1} justifyContent="flex-end">
<HStack flex="0 0 content" justifyContent="flex-end" w="fit-content">
(
{isShowStagingBuildStatusEnabled && (
<Box mr="-0.25rem">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { UseQueryResult, useQuery } from "react-query"

import { GET_CONTACT_US_KEY } from "constants/queryKeys"

import { getAxiosErrorMessage } from "utils/axios"

import { ContactUsService } from "services"
import { ContactUsDto } from "types/contactUs"
import { useErrorToast, DEFAULT_RETRY_MSG } from "utils"
Expand All @@ -18,7 +20,9 @@ export const useGetContactUsHook = (
onError: (err: AxiosError) => {
errorToast({
id: "get-contact-us-error",
description: `Your Contact Us page details could not be retrieved. ${DEFAULT_RETRY_MSG}. Error: ${err.response?.data.error.message}`,
description: `Your Contact Us page details could not be retrieved. ${DEFAULT_RETRY_MSG}. Error: ${getAxiosErrorMessage(
err
)}`,
})
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { UseMutationResult, useQueryClient, useMutation } from "react-query"

import { GET_CONTACT_US_KEY } from "constants/queryKeys"

import { getAxiosErrorMessage } from "utils/axios"

import { ContactUsService } from "services"
import { ContactUsFrontMatter } from "types/contactUs"
import { MiddlewareError } from "types/error"
import { useSuccessToast, useErrorToast, DEFAULT_RETRY_MSG } from "utils"

interface UpdateContactUsParams {
Expand All @@ -15,11 +16,7 @@ interface UpdateContactUsParams {

export const useUpdateContactUsHook = (
siteName: string
): UseMutationResult<
void,
AxiosError<MiddlewareError>,
UpdateContactUsParams
> => {
): UseMutationResult<void, AxiosError, UpdateContactUsParams> => {
const queryClient = useQueryClient()
const successToast = useSuccessToast()
const errorToast = useErrorToast()
Expand All @@ -42,10 +39,12 @@ export const useUpdateContactUsHook = (
description: "Contact Us page updated successfully",
})
},
onError: (err: AxiosError) => {
onError: (err) => {
errorToast({
id: "update-homepage-error",
description: `Could not update Contact Us page. ${DEFAULT_RETRY_MSG}. Error: ${err.response?.data.error.message}`,
description: `Could not update Contact Us page. ${DEFAULT_RETRY_MSG}. Error: ${getAxiosErrorMessage(
err
)}`,
})
},
}
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/homepageHooks/useGetHomepageHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { UseQueryResult, useQuery } from "react-query"

import { GET_HOMEPAGE_KEY } from "constants/queryKeys"

import { getAxiosErrorMessage } from "utils/axios"

import { HomepageService } from "services"
import { HomepageDto } from "types/homepage"
import { useErrorToast, DEFAULT_RETRY_MSG } from "utils"
Expand All @@ -18,7 +20,9 @@ export const useGetHomepageHook = (
onError: (err: AxiosError) => {
errorToast({
id: "get-homepage-error",
description: `Your homepage could not be retrieved. ${DEFAULT_RETRY_MSG}. Error: ${err.response?.data.error.message}`,
description: `Your homepage could not be retrieved. ${DEFAULT_RETRY_MSG}. Error: ${getAxiosErrorMessage(
err
)}`,
})
},
}
Expand Down
12 changes: 8 additions & 4 deletions src/hooks/homepageHooks/useUpdateHomepageHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ import {

import { GET_HOMEPAGE_KEY } from "constants/queryKeys"

import { getAxiosErrorMessage } from "utils/axios"

import { HomepageService } from "services"
import { MiddlewareError } from "types/error"
import { MiddlewareErrorDto } from "types/error"
import { HomepageDto } from "types/homepage"
import { useSuccessToast, useErrorToast, DEFAULT_RETRY_MSG } from "utils"

export const useUpdateHomepageHook = (
siteName: string,
mutationOptions?: Omit<
UseMutationOptions<void, AxiosError<MiddlewareError>, HomepageDto>,
UseMutationOptions<void, AxiosError<MiddlewareErrorDto>, HomepageDto>,
"mutationFn" | "mutationKey"
>
): UseMutationResult<void, AxiosError<MiddlewareError>, HomepageDto> => {
): UseMutationResult<void, AxiosError<MiddlewareErrorDto>, HomepageDto> => {
const queryClient = useQueryClient()
const successToast = useSuccessToast()
const errorToast = useErrorToast()
Expand All @@ -44,7 +46,9 @@ export const useUpdateHomepageHook = (
if (err.response?.status !== 409) {
errorToast({
id: "update-homepage-error",
description: `Could not update homepage. ${DEFAULT_RETRY_MSG}. Error: ${err.response?.data?.message}`,
description: `Could not update homepage. ${DEFAULT_RETRY_MSG}. Error: ${getAxiosErrorMessage(
err
)}`,
})
}
if (mutationOptions?.onError)
Expand Down
55 changes: 27 additions & 28 deletions src/hooks/mediaHooks/useDeleteMultipleMediaHook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,22 @@ const deleteMultipleMedia = async (
) => {
const mediaService = new MediaService({ apiClient: apiService })

await selectedMediaDto
.map((deleteMedia) => {
const pathTokens = deleteMedia.filePath.split("/")

const reqParams = {
siteName,
mediaDirectoryName: pathTokens.slice(0, -1).join("%2F"),
fileName: pathTokens.pop(),
sha: deleteMedia.sha,
await mediaService
.deleteMultiple(
{ siteName },
{
items: selectedMediaDto.map(({ filePath, sha }) => {
return {
filePath,
sha,
}
}),
}

return reqParams
})
.reduce(
(acc, curr) =>
acc
.then(() => {
const { sha, ...rest } = curr
mediaService.delete(rest, { sha }).catch((error) => {
// We want to continue even if some of the media files fail to delete
// because there is no turning back now if we fail (the earlier files
// would have been deleted)
return error
}) as Promise<void>
})
// This wait is necessary to avoid the repo lock
.then(() => new Promise((resolve) => setTimeout(resolve, 500))),
Promise.resolve()
)
// Note: Unfortunately, we have to wait for GitHub to finish deleting the files
// before we can refetch the list of files in the directory. Otherwise, the
// refetch will return the files that were just deleted.
.then(() => new Promise((resolve) => setTimeout(resolve, 1000)))
}

export const useDeleteMultipleMediaHook = (
Expand All @@ -71,7 +58,19 @@ export const useDeleteMultipleMediaHook = (
...mutationOptions,
onSettled: (data, error, variables, context) => {
queryClient.invalidateQueries([LIST_MEDIA_DIRECTORY_FILES_KEY])
queryClient.invalidateQueries([GET_ALL_MEDIA_FILES_KEY])
// Note: We choose to remove here because once the files are deleted,
// refetching will definitely cause a 404 Not Found error, which is what
// we want to avoid
variables.forEach(({ filePath }) => {
const directoryName = encodeURIComponent(
filePath.split("/").slice(0, -1).join("/")
)
const fileName = encodeURIComponent(filePath.split("/").pop() || "")
queryClient.removeQueries([
GET_ALL_MEDIA_FILES_KEY,
{ siteName: params.siteName, directoryName, name: fileName },
])
})
if (mutationOptions?.onSettled)
mutationOptions.onSettled(data, error, variables, context)
},
Expand Down
Loading

0 comments on commit cff63f5

Please sign in to comment.