-
Notifications
You must be signed in to change notification settings - Fork 0
KP-433: add KTHPeriods to course search filter #371
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
base: issues/KP-448-lyft-kod-i-shared-som-ts
Are you sure you want to change the base?
KP-433: add KTHPeriods to course search filter #371
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the course search functionality to improve period/semester handling by:
- Replacing semester-based search parameters (
semesters: ['HT2024', 'VT2024']) with KTH period-based parameters (period: ['2024:P1', '2024:summer']) - Moving shared search logic from JavaScript to TypeScript in the
shared/directory - Consolidating type definitions and removing duplicated code
- Updating the webpack configuration to disable TypeScript project references to prevent build errors
- Modernizing React components by replacing
defaultPropswith default parameter values
Reviewed Changes
Copilot reviewed 57 out of 61 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| webpack.config.js | Disables TypeScript project references in webpack to prevent TS6307 errors |
| tsconfig.json | Adds project references configuration for shared and public directories |
| shared/searchPageCtrlUtils.ts | New file containing TypeScript implementation of course search logic |
| shared/periodSearchUtils.ts | Refactored period configuration logic with new convertSummerToPeriods function |
| shared/periods.ts | Removes unused getSummerPeriodsList function |
| shared/languageUtil.ts | New shared language utility functions and types |
| shared/SearchTypes.ts | New shared TypeScript types for search responses |
| server/controllers/searchPageCtrl.js | Delegates to TypeScript implementation in shared directory |
| public/js/app/util/searchHelper.ts | Updates period display logic to use new KTH period data structures |
| public/js/app/pages/types/searchPageTypes.ts | Replaces semesters with period parameter and converts SEARCH_MODES to enum |
| domain/searchParams.js | Removes period transformation logic, delegates to shared TypeScript implementation |
| Various test files | Updates tests to use new period format (2024:P1 instead of HT2024) |
| Various component files | Replaces defaultProps with default parameter values per React best practices |
Comments suppressed due to low confidence (3)
shared/periodSearchUtils.ts:1
- Corrected spelling of 'periodSearchutils' to 'periodSearchUtils' to match the file name.
domain/searchParams.js:136 - Superfluous argument passed to function _periodConfigByYearType.
return _periodConfigByYearType('currentYear', langIndex, true)
domain/searchParams.js:138
- Superfluous argument passed to function _periodConfigByYearType.
return _periodConfigByYearType('nextYear', langIndex, true)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@belanglos I've opened a new pull request, #372, to work on those changes. Once the pull request is ready, I'll request review from you. |
c7ccca1 to
51442a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 57 out of 61 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (3)
public/js/app/pages/types/searchPageTypes.ts:1
- The Period type definition is incorrect. It only allows 'P' followed by '1' | '2' | '3' | '4' | 'summer', but the actual period values used throughout the code include 'P0' and 'P5' (e.g., in tests and convertSummerToPeriods function). The type should be
${number}:P${'0' | '1' | '2' | '3' | '4' | '5'}or${number}:${'summer' | \P${0 | 1 | 2 | 3 | 4 | 5}`}`.
domain/searchParams.js:136 - Superfluous argument passed to function _periodConfigByYearType.
return _periodConfigByYearType('currentYear', langIndex, true)
domain/searchParams.js:138
- Superfluous argument passed to function _periodConfigByYearType.
return _periodConfigByYearType('nextYear', langIndex, true)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5a6e2b2 to
322e94d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 57 out of 61 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (2)
domain/searchParams.js:136
- Superfluous argument passed to function _periodConfigByYearType.
return _periodConfigByYearType('currentYear', langIndex, true)
domain/searchParams.js:138
- Superfluous argument passed to function _periodConfigByYearType.
return _periodConfigByYearType('nextYear', langIndex, true)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
efab51b to
6e9f229
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 57 out of 61 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (3)
public/js/app/components-shared/Alert.jsx:1
- The
typeprop is marked asisRequiredin PropTypes but has a default value of 'info' in the function signature. Remove.isRequiredto align with the default parameter behavior.
// https://intra.kth.se/style/en/components/alert
domain/searchParams.js:136
- Superfluous argument passed to function _periodConfigByYearType.
return _periodConfigByYearType('currentYear', langIndex, true)
domain/searchParams.js:138
- Superfluous argument passed to function _periodConfigByYearType.
return _periodConfigByYearType('nextYear', langIndex, true)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Avoid TS project reference mode inside webpack build to prevent TS6307 We build referenced projects (e.g. shared/) separately via npm scripts and resolve them via path/webpack aliases during bundling.
6e9f229 to
2e5762a
Compare
axelbjo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much work done here, really nice job! I like the refactoring and general restructuring of things throughout the repo. Nice to see more TS introduced too.
Tested the application locally and ran the tests as well, no problems there. Great job Benni!
📌 Summary
This has to be merged after #370
Adds possibility to filter by KTH Periods to course search.
When visiting the page in spring, this years KTHPeriods and next years spring KTHPeriods should be available as filters.
When visiting the page in autumn, this years Autumn KTHPeriods and next years KTHPeriods should be available as filters.
Fixes https://kth-se.atlassian.net/browse/KP-433
🔍 Changes
@kth/om-kursen-ladok-clientdefaultProps✅ Checklist (Author)
🧪 Testing & Verification
🚧 Out of Scope
We could benefit from integration tests at this level.
Also, we do not have working cypress-E2E-tests for course search.
Copilot Summary
This pull request introduces several improvements and refactorings across the codebase, focusing on simplifying prop handling in React components, updating search parameter logic, enhancing internationalization, and improving development tooling. The most significant changes are grouped below.
Refactoring and Simplification of React Component Props
defaultPropsassignments forAlert,Article,KoppsData, andLadokDatacomponents, instead setting default values directly in function parameters. This streamlines component definitions and reduces boilerplate. [1] [2] [3] [4] [5] [6] [7] [8]SearchDepartmentsPropsto use the correct type fordepartmentCode, improving type safety.Search Parameter Logic and Test Improvements
domain/searchParams.jsto simplify period handling, remove unused functions, and utilize shared utilities for period configuration. This makes the search logic more maintainable and consistent. [1] [2]SearchFilters.test.tsxto use the correct types, improve test clarity, and switch touser-eventfor more realistic user interaction simulation. [1] [2] [3] [4] [5]Internationalization Updates
listtostandardin both English and Swedish message files to ensure consistency in UI terminology. [1] [2]Development Tooling Enhancements
dev:sharedscript to clean the build directory before compiling TypeScript, preventing stale artifacts.@testing-library/user-eventas a dependency to support improved testing practices.Cleanup
SearchTodos.MDfile, keeping documentation current.