Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update search #1313

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
test-e2e:
env:
OCW_STUDIO_BASE_URL: ${{ secrets.OCW_STUDIO_BASE_URL }}
SEARCH_API_URL: ${{ secrets.SEARCH_API_URL }}
COURSE_SEARCH_API_URL: ${{ secrets.COURSE_SEARCH_API_URL }}
CONTENT_FILE_SEARCH_API_URL: ${{ secrets.CONTENT_FILE_SEARCH_API_URL }}
STATIC_API_BASE_URL: ${{ secrets.STATIC_API_BASE_URL }}
RESOURCE_BASE_URL: ${{ secrets.RESOURCE_BASE_URL }}
COURSE_HUGO_CONFIG_PATH: "$GITHUB_WORKSPACE/ocw-hugo-projects/ocw-course-v2/config.yaml"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ jobs:
run: (cd ../ocw-www; hugo --config $GITHUB_WORKSPACE/ocw-hugo-projects/ocw-www/config.yaml --themesDir ../ocw-hugo-themes)
env:
OCW_STUDIO_BASE_URL: ${{ secrets.OCW_STUDIO_BASE_URL }}
SEARCH_API_URL: ${{ secrets.SEARCH_API_URL }}
COURSE_SEARCH_API_URL: ${{ secrets.COURSE_SEARCH_API_URL }}
CONTENT_FILE_SEARCH_API_URL: ${{ secrets.CONTENT_FILE_SEARCH_API_URL }}
OCW_COURSE_STARTER_SLUG: ${{ secrets.OCW_COURSE_STARTER_SLUG }}
STATIC_API_BASE_URL: ${{ secrets.STATIC_API_BASE_URL }}
RESOURCE_BASE_URL: ${{ secrets.RESOURCE_BASE_URL }}
Expand All @@ -63,7 +64,8 @@ jobs:
run: (cd ../ocw-course; hugo --config $GITHUB_WORKSPACE/ocw-hugo-projects/ocw-course-v2/config.yaml --destination public-v2 --themesDir ../ocw-hugo-themes)
env:
OCW_STUDIO_BASE_URL: ${{ secrets.OCW_STUDIO_BASE_URL }}
SEARCH_API_URL: ${{ secrets.SEARCH_API_URL }}
COURSE_SEARCH_API_URL: ${{ secrets.COURSE_SEARCH_API_URL }}
CONTENT_FILE_SEARCH_API_URL: ${{ secrets.CONTENT_FILE_SEARCH_API_URL }}
OCW_COURSE_STARTER_SLUG: ${{ secrets.OCW_COURSE_STARTER_SLUG }}
STATIC_API_BASE_URL: ${{ secrets.STATIC_API_BASE_URL }}
RESOURCE_BASE_URL: ${{ secrets.RESOURCE_BASE_URL }}
Expand Down
3 changes: 2 additions & 1 deletion base-theme/assets/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ declare global {
declare let RELEASE_VERSION: string
namespace NodeJS {
interface ProcessEnv {
SEARCH_API_URL: string
COURSE_SEARCH_API_URL: string
CONTENT_FILE_SEARCH_API_URL: string
}
}
}
Expand Down
11 changes: 8 additions & 3 deletions env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,14 @@ const envSchema = {
desc: "Base URL with which to prefix resource paths in Hugo's output.",
devDefault: "https://live-qa.ocw.mit.edu/"
}),
SEARCH_API_URL: envalid.url({
desc: "The URL of the search API.",
devDefault: "https://discussions-rc.odl.mit.edu/api/v0/search/"
COURSE_SEARCH_API_URL: envalid.url({
desc: "The URL of the learning resource search API.",
devDefault:
"https://mit-open-rc.odl.mit.edu/api/v1/learning_resources_search/"
}),
CONTENT_FILE_SEARCH_API_URL: envalid.url({
desc: "The URL of the contentfile search API.",
devDefault: "https://mit-open-rc.odl.mit.edu/api/v1/content_file_search/"
}),
SENTRY_ENV: envalid.str({
desc: "The environment for Sentry",
Expand Down
5 changes: 4 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const config: Config.InitialOptions = {
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ["/node_modules/", "tests-e2e/"],
preset: "ts-jest",
testEnvironment: "jsdom"
testEnvironment: "jsdom",
moduleNameMapper: {
axios: "axios/dist/node/axios.cjs"
}
}

export default config
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"browserslist": "> 0.25%, not dead",
"dependencies": {
"@mitodl/course-search-utils": "^2.3.0",
"@mitodl/course-search-utils": "^3.0.2",
"@sentry/browser": "^5.19.0",
"array-flat-polyfill": "^1.0.1",
"bootstrap": "^4.3.1",
Expand Down Expand Up @@ -70,7 +70,6 @@
"videojs-youtube": "^2.6.1"
},
"devDependencies": {
"@mitodl/ocw-to-hugo": "1.36.0",
"@playwright/test": "^1.40.0",
"@swc/core": "^1.3.14",
"@swc/helpers": "^0.4.12",
Expand Down
7 changes: 6 additions & 1 deletion www/assets/css/search-filter.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.filterable-facet {
margin-bottom: 1rem !important;
.input-wrapper {
position: relative;

Expand Down Expand Up @@ -46,6 +47,10 @@
background-color: #f6f6f6;
width: 100%;
border: none;
padding-left: 1rem !important;
padding-top: 0.5rem !important;
padding-bottom: 0.5rem !important;
padding-right: 0 !important;
}

.filter-section-main-title {
Expand Down Expand Up @@ -96,7 +101,7 @@
cursor: pointer;
}

.facet-label-div {
.facet-label {
display: flex;
flex-direction: row;
justify-content: space-between;
Expand Down
170 changes: 19 additions & 151 deletions www/assets/js/LearningResources.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable camelcase */
import { LearningResourceType, Facets } from "@mitodl/course-search-utils"
import {
OCW_PLATFORM,
COURSE_ARCHIVED,
COURSE_CURRENT,
PROFESSIONAL,
Expand All @@ -19,30 +17,6 @@ type Audience =

type Certification = [] | [typeof CERTIFICATE]

export interface CourseResult {
id: number
course_id: string
coursenum: string
title: string
url: string
image_src: string
short_description: string
department: string
platform: typeof OCW_PLATFORM
offered_by: [typeof OCW_PLATFORM]
topics: string[]
object_type: LearningResourceType.Course
runs: CourseRun[]
audience: Audience
certification: Certification
course_feature_tags: string[]
content_title: undefined
run_title: undefined
run_slug: undefined
content_type: undefined
short_url: undefined
}

interface Instructor {
first_name: string
last_name: string
Expand Down Expand Up @@ -144,137 +118,31 @@ export interface CourseRun {
short_url: undefined
}

export interface VideoResult {
id: number
video_id: string
title: string
url: string
image_src: string
short_description: string
topics: string[]
object_type: LearningResourceType.Video
offered_by: [typeof OCW_PLATFORM]
runs: any[]
audience: Audience
certification: Certification
department: undefined
content_title: undefined
run_title: undefined
run_slug: undefined
coursenum: undefined
content_type: undefined
short_url: undefined
course_id: undefined
course_feature_tags: undefined
}

export interface PodcastResult {
id: number
podcast_id: string
title: string
url: string
image_src: string
short_description: string
topics: string[]
object_type: LearningResourceType.Podcast
offered_by: [typeof OCW_PLATFORM]
runs: any[]
audience: Audience
certification: Certification
department: undefined
content_title: undefined
run_title: undefined
run_slug: undefined
coursenum: undefined
content_type: undefined
short_url: undefined
course_id: undefined
course_feature_tags: undefined
}

export interface PodcastEpisodeResult {
id: number
podcast_id: string
title: string
url: string
image_src: string
short_description: string
topics: string[]
object_type: LearningResourceType.PodcastEpisode
offered_by: [typeof OCW_PLATFORM]
runs: any[]
series_title: string
audience: Audience
certification: Certification
department: undefined
content_title: undefined
run_title: undefined
run_slug: undefined
coursenum: undefined
content_type: undefined
short_url: undefined
course_id: undefined
course_feature_tags: undefined
}

export interface ResourceFileResult {
id: number
course_id: string
coursenum: string
title: string
url: string
image_src: string
topics: string[]
object_type: LearningResourceType.ResourceFile
content_title: string
run_title: string
run_slug: string
content_type: ContentType
short_url: string
runs: undefined
audience: undefined
certification: undefined
department: undefined
short_description: string
course_feature_tags: undefined
}

export type LearningResourceResult =
| CourseResult
| VideoResult
| PodcastResult
| PodcastEpisodeResult
| ResourceFileResult

interface Topic {
name: string
}

export interface LearningResource {
id: number | string
title: string
id?: number | string
title: string | null
image_src: string
object_type: LearningResourceType
platform: string | null
object_type?: string
platform?: string | null
topics: Topic[]
runs: CourseRun[]
level: Level[] | null
runs?: CourseRun[]
level?: Level[] | null
instructors: string[]
department: string | undefined
audience: Audience | undefined
certification: Certification | undefined
content_title: string | undefined
run_title: string | null
run_slug: string | null
content_type: ContentType | null
url: string | null
short_url: string | null
course_id: string | null
coursenum: string | null
description: string | null
course_feature_tags: string[]
department?: string | undefined
audience?: Audience | undefined
certification?: Certification | undefined
content_title?: string | undefined | null
run_title?: string | null
run_slug?: string | null
content_type?: ContentType | null
url?: string | null
short_url?: string | null
course_id?: string | null
coursenum?: string | null
description?: string | null
course_feature_tags?: string[]
}

export type FacetKey = keyof Facets

export type FacetManifest = [FacetKey, string, boolean, boolean][]
9 changes: 3 additions & 6 deletions www/assets/js/components/CourseListRow.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { mount } from "enzyme"
import React from "react"
import { LearningResourceType } from "@mitodl/course-search-utils"

import { makeLearningResourceResult } from "../factories/search"
import { searchResultToLearningResource } from "../lib/search"
import { makeCourseSearchResult } from "../factories/search"
import { courseSearchResultToLearningResource } from "../lib/search"
import CourseListRow from "./CourseListRow"

function setup() {
const course = searchResultToLearningResource(
makeLearningResourceResult(LearningResourceType.Course)
)
const course = courseSearchResultToLearningResource(makeCourseSearchResult())

const wrapper = mount(<CourseListRow course={course} />)

Expand Down
Loading
Loading