Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 80 additions & 80 deletions .yarn/releases/yarn-4.5.2.cjs → .yarn/releases/yarn-4.5.3.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.2.cjs
yarnPath: .yarn/releases/yarn-4.5.3.cjs

# https://github.com/vitejs/vite-plugin-react-swc/issues/74#issuecomment-1520484130
# https://github.com/swc-project/swc/issues/5616#issuecomment-1265639797
Expand Down
16 changes: 16 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
Release Notes
=============

Version 0.26.1
--------------

- Update Yarn to v4.5.3 (#1865)
- fix certification type none display (#1873)
- fix card line clamping (#1871)
- Update dependency eslint-plugin-react-hooks to v5 (#1817)
- Update dependency eslint-plugin-testing-library to v7 (#1856)
- v2 drawer qa adjustments (#1850)
- Fixes issue with learning path membership being called for non-admins (#1864)
- Consolidate qdrant functionality into its own app (#1860)
- Revert "Server rendering for homepage, units and topics listing pages (#1847)" (#1866)
- Filter out content type on similar resources endpoint (#1863)
- Select random hero image index on server (#1859)
- returnning all resource types for similar (#1849)

Version 0.26.0 (Released November 26, 2024)
--------------

Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/generated/v0/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,7 @@ export interface LearningResourceTopic {
channel_url: string | null
}
/**
*
* Response serializer for vector based search
* @export
* @interface LearningResourcesVectorSearchResponse
*/
Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/channels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ export {
useChannelsList,
useChannelPartialUpdate,
useChannelCounts,
channels,
channels as channelsKeyFactory,
}
8 changes: 5 additions & 3 deletions frontends/api/src/hooks/learningPaths/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
} from "../../generated/v1"
import { learningPathsApi } from "../../clients"
import learningPaths from "./keyFactory"
import { useUserIsAuthenticated } from "api/hooks/user"
import { useUserHasPermission, Permission } from "api/hooks/user"

const useLearningPathsList = (
params: ListRequest = {},
Expand Down Expand Up @@ -121,7 +121,8 @@ const useIsLearningPathMember = (resourceId?: number) => {
select: (data) => {
return !!data.find((relationship) => relationship.child === resourceId)
},
enabled: useUserIsAuthenticated() && !!resourceId,
enabled:
useUserHasPermission(Permission.LearningPathEditor) && !!resourceId,
})
}

Expand All @@ -134,7 +135,8 @@ const useLearningPathMemberList = (resourceId?: number) => {
.filter((relationship) => relationship.child === resourceId)
.map((relationship) => relationship.parent.toString())
},
enabled: useUserIsAuthenticated() && !!resourceId,
enabled:
useUserHasPermission(Permission.LearningPathEditor) && !!resourceId,
})
}

Expand Down
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/learningResources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ export {
useSchoolsList,
useSimilarLearningResources,
useVectorSimilarLearningResources,
learningResources,
learningResources as learningResourcesKeyFactory,
}
2 changes: 1 addition & 1 deletion frontends/api/src/hooks/newsEvents/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export {
useNewsEventsList,
useNewsEventsDetail,
NewsEventsListFeedTypeEnum,
newsEvents,
newsEvents as newsEventsKeyFactory,
}
6 changes: 5 additions & 1 deletion frontends/api/src/hooks/testimonials/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ const useTestimonialDetail = (id: number | undefined) => {
})
}

export { useTestimonialDetail, useTestimonialList, testimonials }
export {
useTestimonialDetail,
useTestimonialList,
testimonials as testimonialsKeyFactory,
}
13 changes: 12 additions & 1 deletion frontends/api/src/hooks/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { useQuery } from "@tanstack/react-query"
import { usersApi } from "../../clients"
import type { User as UserApi } from "../../generated/v0/api"

enum Permission {
ArticleEditor = "is_article_editor",
Authenticated = "is_authenticated",
LearningPathEditor = "is_learning_path_editor",
}

interface User extends Partial<UserApi> {
is_authenticated: boolean
}
Expand Down Expand Up @@ -33,5 +39,10 @@ const useUserIsAuthenticated = () => {
return !!user?.is_authenticated
}

export { useUserMe, useUserIsAuthenticated }
const useUserHasPermission = (permission: Permission) => {
const { data: user } = useUserMe()
return !!user?.[permission]
}

export { useUserMe, useUserIsAuthenticated, useUserHasPermission, Permission }
export type { User }
14 changes: 4 additions & 10 deletions frontends/api/src/ssr/prefetch.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { QueryClient, dehydrate } from "@tanstack/react-query"
import type { Query } from "@tanstack/react-query"

/* Utility to avoid repetition in server components
* Optionally pass the queryClient returned from a previous prefetch
* where queries are dependent on previous results
*/
export const prefetch = async (
queries: (Query | unknown)[],
queryClient?: QueryClient,
) => {
queryClient = queryClient || new QueryClient()
// Utility to avoid repetition in server components
export const prefetch = async (queries: (Query | unknown)[]) => {
const queryClient = new QueryClient()

await Promise.all(
queries.map((query) => queryClient.prefetchQuery(query as Query)),
)

return { dehydratedState: dehydrate(queryClient), queryClient }
return dehydrate(queryClient)
}
12 changes: 6 additions & 6 deletions frontends/api/src/ssr/usePrefetchWarnings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { usePrefetchWarnings } from "./usePrefetchWarnings"
import { setupReactQueryTest } from "../hooks/test-utils"
import { urls, factories, setMockResponse } from "../test-utils"
import {
learningResources,
learningResourcesKeyFactory,
useLearningResourcesDetail,
} from "../hooks/learningResources"

Expand Down Expand Up @@ -45,7 +45,7 @@ describe("SSR prefetch warnings", () => {
expect.objectContaining({
disabled: false,
initialStatus: "loading",
key: learningResources.detail(1).queryKey,
key: learningResourcesKeyFactory.detail(1).queryKey,
observerCount: 1,
}),
],
Expand All @@ -65,7 +65,7 @@ describe("SSR prefetch warnings", () => {
wrapper,
initialProps: {
queryClient,
exemptions: [learningResources.detail(1).queryKey],
exemptions: [learningResourcesKeyFactory.detail(1).queryKey],
},
})

Expand All @@ -83,7 +83,7 @@ describe("SSR prefetch warnings", () => {
const { unmount } = renderHook(
() =>
useQuery({
...learningResources.detail(1),
...learningResourcesKeyFactory.detail(1),
initialData: data,
}),
{ wrapper },
Expand All @@ -105,9 +105,9 @@ describe("SSR prefetch warnings", () => {
[
{
disabled: false,
hash: JSON.stringify(learningResources.detail(1).queryKey),
hash: JSON.stringify(learningResourcesKeyFactory.detail(1).queryKey),
initialStatus: "success",
key: learningResources.detail(1).queryKey,
key: learningResourcesKeyFactory.detail(1).queryKey,
observerCount: 0,
status: "success",
},
Expand Down
1 change: 0 additions & 1 deletion frontends/api/src/test-utils/factories/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ const _channelShared = (): Partial<Omit<Channel, "channel_type">> => {
key: faker.lorem.slug(),
value: faker.lorem.slug(),
}),
channel_url: `${faker.internet.url({ appendSlash: false })}${faker.system.directoryPath()}`,
}
}

Expand Down
3 changes: 0 additions & 3 deletions frontends/api/src/test-utils/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import type {
NewsEventsApiNewsEventsListRequest,
TestimonialsApi,
ChannelsApi,
} from "../generated/v0"
import type {
LearningResourcesApi as LRApi,
Expand Down Expand Up @@ -187,8 +186,6 @@ const channels = {
details: (channelType: string, name: string) =>
`${API_BASE_URL}/api/v0/channels/type/${channelType}/${name}/`,
patch: (id: number) => `${API_BASE_URL}/api/v0/channels/${id}/`,
list: (params?: Paramsv0<ChannelsApi, "channelsList">) =>
`${API_BASE_URL}/api/v0/channels/${query(params)}`,
}

const widgetLists = {
Expand Down
6 changes: 3 additions & 3 deletions frontends/main/src/app-pages/DashboardPage/Dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
renderWithProviders,
} from "@/test-utils"
import { factories, urls } from "api/test-utils"
import { Permissions } from "@/common/permissions"
import { Permission } from "api/hooks/user"
import DashboardPage, {
DashboardTabKeys,
DashboardTabLabels,
Expand Down Expand Up @@ -108,7 +108,7 @@ describe("DashboardPage", () => {

setMockResponse.get(urls.userMe.get(), {
username: profile.username,
[Permissions.Authenticated]: true,
[Permission.Authenticated]: true,
})
setMockResponse.get(urls.profileMe.get(), profile)
setMockResponse.get(
Expand Down Expand Up @@ -207,7 +207,7 @@ describe("DashboardPage", () => {
test("Renders user info", async () => {
setupAPIs()
setMockResponse.get(urls.userMe.get(), {
[Permissions.Authenticated]: true,
[Permission.Authenticated]: true,
first_name: "Joe",
last_name: "Smith",
profile: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from "react"
import { renderWithProviders, setMockResponse } from "@/test-utils"
import { urls } from "api/test-utils"
import * as commonUrls from "@/common/urls"
import { ForbiddenError, Permissions } from "@/common/permissions"
import { ForbiddenError } from "@/common/errors"
import { Permission } from "api/hooks/user"
import { useFeatureFlagEnabled } from "posthog-js/react"
import CartPage from "./CartPage"
import { allowConsoleErrors } from "ol-test-utilities"
Expand Down Expand Up @@ -33,7 +34,7 @@ describe("CartPage", () => {
;["on", "off"].forEach((testCase: string) => {
test(`Renders when logged in and feature flag is ${testCase}`, async () => {
setMockResponse.get(urls.userMe.get(), {
[Permissions.Authenticated]: true,
[Permission.Authenticated]: true,
})
mockedUseFeatureFlagEnabled.mockReturnValue(testCase === "on")

Expand Down
6 changes: 3 additions & 3 deletions frontends/main/src/app-pages/ErrorPage/ForbiddenPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { renderWithProviders, screen } from "../../test-utils"
import { HOME } from "@/common/urls"
import ForbiddenPage from "./ForbiddenPage"
import { setMockResponse, urls } from "api/test-utils"
import { Permissions } from "@/common/permissions"
import { Permission } from "api/hooks/user"

const oldWindowLocation = window.location

Expand All @@ -26,15 +26,15 @@ afterAll(() => {

test("The ForbiddenPage loads with Correct Title", () => {
setMockResponse.get(urls.userMe.get(), {
[Permissions.Authenticated]: true,
[Permission.Authenticated]: true,
})
renderWithProviders(<ForbiddenPage />)
screen.getByRole("heading", { name: "Not Allowed" })
})

test("The ForbiddenPage loads with a link that directs to HomePage", () => {
setMockResponse.get(urls.userMe.get(), {
[Permissions.Authenticated]: true,
[Permission.Authenticated]: true,
})
renderWithProviders(<ForbiddenPage />)
const homeLink = screen.getByRole("link", { name: "Home" })
Expand Down
16 changes: 8 additions & 8 deletions frontends/main/src/app-pages/HomePage/HomePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const setupAPIs = () => {
describe("Home Page Hero", () => {
test("Submitting search goes to search page", async () => {
setupAPIs()
const { location } = renderWithProviders(<HomePage />)
const { location } = renderWithProviders(<HomePage heroImageIndex={1} />)
const searchbox = screen.getByRole("textbox", { name: /search for/i })
await user.click(searchbox)
await user.paste("physics")
Expand All @@ -101,7 +101,7 @@ describe("Home Page Hero", () => {
results: [],
})
setupAPIs()
renderWithProviders(<HomePage />)
renderWithProviders(<HomePage heroImageIndex={1} />)
const expected = [
{ label: "Topic", href: "/topics" },
{ label: "Recently Added", href: "/search?sortby=new" },
Expand All @@ -128,7 +128,7 @@ describe("Home Page Browse by Topic", () => {
const response = learningResources.topics({ count: 3 })
setMockResponse.get(urls.topics.list({ is_toplevel: true }), response)

renderWithProviders(<HomePage />)
renderWithProviders(<HomePage heroImageIndex={1} />)

await waitFor(() => {
const section = screen
Expand Down Expand Up @@ -258,7 +258,7 @@ describe("Home Page personalize section", () => {
test("Links to dashboard when authenticated", async () => {
setupAPIs()

renderWithProviders(<HomePage />)
renderWithProviders(<HomePage heroImageIndex={1} />)
const personalize = (
await screen.findByRole("heading", {
name: "Continue Your Journey",
Expand All @@ -273,7 +273,7 @@ describe("Home Page personalize section", () => {
setupAPIs()

setMockResponse.get(urls.userMe.get(), {}, { code: 403 })
renderWithProviders(<HomePage />)
renderWithProviders(<HomePage heroImageIndex={1} />)
const personalize = (
await screen.findByRole("heading", {
name: "Personalize Your Journey",
Expand All @@ -294,7 +294,7 @@ describe("Home Page Testimonials", () => {
test("Displays testimonials carousel", async () => {
setupAPIs()

renderWithProviders(<HomePage />)
renderWithProviders(<HomePage heroImageIndex={1} />)

await waitFor(() => {
screen.getAllByText(/testable title/i)
Expand All @@ -306,7 +306,7 @@ describe("Home Page Carousel", () => {
test("Tabbed Carousel sanity check", async () => {
setupAPIs()

renderWithProviders(<HomePage />)
renderWithProviders(<HomePage heroImageIndex={1} />)

await screen.findAllByRole("tablist").then(([featured, media]) => {
within(featured).getByRole("tab", { name: "All" })
Expand All @@ -325,7 +325,7 @@ describe("Home Page Carousel", () => {
test("Headings", async () => {
setupAPIs()

renderWithProviders(<HomePage />)
renderWithProviders(<HomePage heroImageIndex={1} />)
await waitFor(() => {
assertHeadings([
{ level: 1, name: "Learn with MIT" },
Expand Down
4 changes: 2 additions & 2 deletions frontends/main/src/app-pages/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ const StyledContainer = styled(Container)({
},
})

const HomePage: React.FC = () => {
const HomePage: React.FC<{ heroImageIndex: number }> = ({ heroImageIndex }) => {
return (
<>
<LearningResourceDrawer />
<FullWidthBackground>
<StyledContainer>
<HeroSearch />
<HeroSearch imageIndex={heroImageIndex} />
<section>
<FeaturedCoursesCarousel
titleComponent="h2"
Expand Down
4 changes: 2 additions & 2 deletions frontends/main/src/app-pages/PrivacyPage/PrivacyPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from "react"
import { screen, setMockResponse, renderWithProviders } from "@/test-utils"
import { urls } from "api/test-utils"
import { Permissions } from "@/common/permissions"
import { Permission } from "api/hooks/user"
import PrivacyPage from "./PrivacyPage"

describe("PrivacyPage", () => {
test("Renders title", async () => {
setMockResponse.get(urls.userMe.get(), {
[Permissions.Authenticated]: true,
[Permission.Authenticated]: true,
})

renderWithProviders(<PrivacyPage />)
Expand Down
Loading
Loading