From a4859d26865c08ef13efc135e85e1eccaeab175c Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Thu, 27 Jun 2024 09:54:01 -0700 Subject: [PATCH] chore: convert all 'search-modal' code to TypeScript (#1129) * chore: convert all 'search-modal' code to TypeScript * fix: lint should check .ts[x] files too * fix: remove unused dependency meilisearch-instantsearch --- package-lock.json | 9 - package.json | 3 +- .../ContentTagsCollapsible.d.ts | 37 ++-- ...{BlockTypeLabel.jsx => BlockTypeLabel.tsx} | 5 +- ...ltersButton.jsx => ClearFiltersButton.tsx} | 5 +- .../{EmptyStates.jsx => EmptyStates.tsx} | 20 +- ...rByBlockType.jsx => FilterByBlockType.tsx} | 15 +- .../{FilterByTags.jsx => FilterByTags.tsx} | 44 ++--- .../{Highlight.jsx => Highlight.tsx} | 5 +- ...ilterWidget.jsx => SearchFilterWidget.tsx} | 10 +- ...wordsField.jsx => SearchKeywordsField.tsx} | 6 +- ...rchModal.test.jsx => SearchModal.test.tsx} | 7 +- .../{SearchModal.jsx => SearchModal.tsx} | 5 +- .../{SearchResult.jsx => SearchResult.tsx} | 40 ++-- .../{SearchResults.jsx => SearchResults.tsx} | 6 +- .../{SearchUI.test.jsx => SearchUI.test.tsx} | 21 +- .../{SearchUI.jsx => SearchUI.tsx} | 6 +- src/search-modal/{Stats.jsx => Stats.tsx} | 5 +- src/search-modal/data/{api.js => api.ts} | 186 ++++++++++-------- .../data/{apiHooks.js => apiHooks.ts} | 47 +++-- .../{SearchManager.js => SearchManager.ts} | 72 ++++--- src/search-modal/{messages.js => messages.ts} | 4 +- 22 files changed, 261 insertions(+), 297 deletions(-) rename src/search-modal/{BlockTypeLabel.jsx => BlockTypeLabel.tsx} (85%) rename src/search-modal/{ClearFiltersButton.jsx => ClearFiltersButton.tsx} (83%) rename src/search-modal/{EmptyStates.jsx => EmptyStates.tsx} (75%) rename src/search-modal/{FilterByBlockType.jsx => FilterByBlockType.tsx} (92%) rename src/search-modal/{FilterByTags.jsx => FilterByTags.tsx} (89%) rename src/search-modal/{Highlight.jsx => Highlight.tsx} (87%) rename src/search-modal/{SearchFilterWidget.jsx => SearchFilterWidget.tsx} (86%) rename src/search-modal/{SearchKeywordsField.jsx => SearchKeywordsField.tsx} (87%) rename src/search-modal/{SearchModal.test.jsx => SearchModal.test.tsx} (93%) rename src/search-modal/{SearchModal.jsx => SearchModal.tsx} (80%) rename src/search-modal/{SearchResult.jsx => SearchResult.tsx} (84%) rename src/search-modal/{SearchResults.jsx => SearchResults.tsx} (90%) rename src/search-modal/{SearchUI.test.jsx => SearchUI.test.tsx} (98%) rename src/search-modal/{SearchUI.jsx => SearchUI.tsx} (95%) rename src/search-modal/{Stats.jsx => Stats.tsx} (83%) rename src/search-modal/data/{api.js => api.ts} (75%) rename src/search-modal/data/{apiHooks.js => apiHooks.ts} (82%) rename src/search-modal/manager/{SearchManager.js => SearchManager.ts} (61%) rename src/search-modal/{messages.js => messages.ts} (98%) diff --git a/package-lock.json b/package-lock.json index 1003712cd..fe0ea0df0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,6 @@ "@fortawesome/free-regular-svg-icons": "5.15.4", "@fortawesome/free-solid-svg-icons": "5.15.4", "@fortawesome/react-fontawesome": "0.2.0", - "@meilisearch/instant-meilisearch": "^0.17.0", "@openedx-plugins/course-app-calculator": "file:plugins/course-apps/calculator", "@openedx-plugins/course-app-edxnotes": "file:plugins/course-apps/edxnotes", "@openedx-plugins/course-app-learning_assistant": "file:plugins/course-apps/learning_assistant", @@ -4073,14 +4072,6 @@ "@lezer/lr": "^1.0.0" } }, - "node_modules/@meilisearch/instant-meilisearch": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/@meilisearch/instant-meilisearch/-/instant-meilisearch-0.17.0.tgz", - "integrity": "sha512-6SDDivDWsmYjX33m2fAUCcBvatjutBbvqV8Eg+CEllz0l6piAiDK/WlukVpYrSmhYN2YGQsJSm62WbMGciPhUg==", - "dependencies": { - "meilisearch": "^0.38.0" - } - }, "node_modules/@newrelic/publish-sourcemap": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/@newrelic/publish-sourcemap/-/publish-sourcemap-5.1.0.tgz", diff --git a/package.json b/package.json index 29a02287b..47577ea3c 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "build": "fedx-scripts webpack", "i18n_extract": "fedx-scripts formatjs extract", "stylelint": "stylelint \"plugins/**/*.scss\" \"src/**/*.scss\" \"scss/**/*.scss\" --config .stylelintrc.json", - "lint": "npm run stylelint && fedx-scripts eslint --ext .js --ext .jsx .", + "lint": "npm run stylelint && fedx-scripts eslint --ext .js --ext .jsx --ext .ts --ext .tsx .", "lint:fix": "npm run stylelint -- --fix && fedx-scripts eslint --fix --ext .js --ext .jsx .", "snapshot": "TZ=UTC fedx-scripts jest --updateSnapshot", "start": "fedx-scripts webpack-dev-server --progress", @@ -54,7 +54,6 @@ "@fortawesome/free-regular-svg-icons": "5.15.4", "@fortawesome/free-solid-svg-icons": "5.15.4", "@fortawesome/react-fontawesome": "0.2.0", - "@meilisearch/instant-meilisearch": "^0.17.0", "@openedx-plugins/course-app-calculator": "file:plugins/course-apps/calculator", "@openedx-plugins/course-app-edxnotes": "file:plugins/course-apps/edxnotes", "@openedx-plugins/course-app-learning_assistant": "file:plugins/course-apps/learning_assistant", diff --git a/src/content-tags-drawer/ContentTagsCollapsible.d.ts b/src/content-tags-drawer/ContentTagsCollapsible.d.ts index 364e7d291..32a1ff41f 100644 --- a/src/content-tags-drawer/ContentTagsCollapsible.d.ts +++ b/src/content-tags-drawer/ContentTagsCollapsible.d.ts @@ -5,24 +5,24 @@ import type {} from 'react-select/base'; // and add our custom property 'myCustomProp' to it. export interface TagTreeEntry { - explicit: boolean; - children: Record; - canChangeObjecttag: boolean; - canDeleteObjecttag: boolean; + explicit: boolean; + children: Record; + canChangeObjecttag: boolean; + canDeleteObjecttag: boolean; } export interface TaxonomySelectProps { - taxonomyId: number; - searchTerm: string; - appliedContentTagsTree: Record; - stagedContentTagsTree: Record; - checkedTags: string[]; - selectCancelRef: Ref, - selectAddRef: Ref, - selectInlineAddRef: Ref, - handleCommitStagedTags: () => void; - handleCancelStagedTags: () => void; - handleSelectableBoxChange: React.ChangeEventHandler; + taxonomyId: number; + searchTerm: string; + appliedContentTagsTree: Record; + stagedContentTagsTree: Record; + checkedTags: string[]; + selectCancelRef: Ref, + selectAddRef: Ref, + selectInlineAddRef: Ref, + handleCommitStagedTags: () => void; + handleCancelStagedTags: () => void; + handleSelectableBoxChange: React.ChangeEventHandler; } // Unfortunately the only way to specify the custom props we pass into React Select @@ -32,11 +32,8 @@ export interface TaxonomySelectProps { // we should change to using a 'react context' to share this data within , // rather than using the custom