Skip to content

Commit 1620e1c

Browse files
authored
feat/addBrokenLinksReporter (#1810)
## Problem Adding broken link checker to front end ## Solution Adds in the main UI for the broken link checkers. This is not design approved, the alignment with @sehyunidaaa at the moment is that we will use this to experiment how quickly users are able to repair their sites on their own before polishing the UI and removing the feature flag as a whole. Note: the introduction of the feature flag is done in a downstream pr. Main user page: https://github.com/isomerpages/isomercms-frontend/assets/42832651/f38e6e77-de50-4a75-88e1-c75df19009b7 Only entry point: https://github.com/isomerpages/isomercms-frontend/assets/42832651/7574a34c-41f4-4a21-bcdb-95a935ffce56 **Breaking Changes** <!-- Does this PR contain any backward incompatible changes? If so, what are they and should there be special considerations for release? --> - [ ] Yes - this PR contains breaking changes - Details ... - [X] No - this PR is backwards compatible with ALL of the following feature flags in this [doc](https://www.notion.so/opengov/Existing-feature-flags-518ad2cdc325420893a105e88c432be5) ## Tests <!-- What tests should be run to confirm functionality? --> - [ ] Log in to staging via github - [ ] Access the page `/sites/<site-name>/linkCheckerReport` for any site [here](https://github.com/isomerpages/isomer-site-checker/) - [ ] Verify that the content is loading, and you are able to access the page in staging + you are able to go into a valid edit page - [ ] Verify that when you click on the breadcrumbs on the side, it leads to the correct table (ie what was done in the video above) ## Deploy Notes Need to clone site-link checker into both prod and staging
2 parents 5f751c4 + 8837e07 commit 1620e1c

File tree

11 files changed

+1231
-0
lines changed

11 files changed

+1231
-0
lines changed

src/assets/images/NoBrokenLinksImage.tsx

Lines changed: 698 additions & 0 deletions
Large diffs are not rendered by default.

src/assets/images/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ export * from "./EditorAccordionImage"
3030
export * from "./EditorCardsImage"
3131
export * from "./EditorDividerImage"
3232
export * from "./EditorCardsPlaceholderImage"
33+
export * from "./NoBrokenLinksImage"

src/constants/queryKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const SITE_DASHBOARD_INFO_KEY = "site-dashboard-info"
2222
export const SITE_DASHBOARD_REVIEW_REQUEST_KEY = "site-dashboard-review-request"
2323
export const SITE_DASHBOARD_COLLABORATORS_KEY = "site-dashboard-collaborators"
2424
export const SITE_DASHBOARD_LAUNCH_STATUS_KEY = "site-dashboard-launch-status"
25+
export const SITE_LINK_CHECKER_STATUS_KEY = "site-link-checker-status"
2526
export const NOTIFICATIONS_KEY = "notifications-content"
2627
export const ALL_NOTIFICATIONS_KEY = "all-notifications"
2728
export const LIST_COLLABORATORS_KEY = "list-collaborators"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { UseQueryResult, useQuery } from "react-query"
2+
3+
import { SITE_LINK_CHECKER_STATUS_KEY } from "constants/queryKeys"
4+
5+
import * as LinkCheckerService from "services/LinkCheckerService"
6+
7+
import { RepoErrorDto } from "types/linkReport"
8+
9+
export const useGetBrokenLinks = (
10+
siteName: string
11+
): UseQueryResult<RepoErrorDto> => {
12+
return useQuery<RepoErrorDto>(
13+
[SITE_LINK_CHECKER_STATUS_KEY, siteName],
14+
() => {
15+
return LinkCheckerService.getLinkCheckerStatus({ siteName })
16+
},
17+
{
18+
retry: false,
19+
refetchInterval: 1000 * 10,
20+
}
21+
)
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { AxiosError } from "axios"
2+
import { useMutation, UseMutationResult, useQueryClient } from "react-query"
3+
4+
import { SITE_LINK_CHECKER_STATUS_KEY } from "constants/queryKeys"
5+
6+
import * as LinkCheckerService from "services/LinkCheckerService"
7+
8+
export const useRefreshLinkChecker = (
9+
siteName: string
10+
): UseMutationResult<void, AxiosError, string> => {
11+
const queryClient = useQueryClient()
12+
return useMutation<void, AxiosError, string>(
13+
async () => {
14+
await LinkCheckerService.refreshLinkChecker({ siteName })
15+
},
16+
{
17+
onSettled: () => {
18+
queryClient.invalidateQueries([SITE_LINK_CHECKER_STATUS_KEY, siteName])
19+
},
20+
}
21+
)
22+
}

0 commit comments

Comments
 (0)