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

Feature: ability to see search result in index page #3134

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SahSantoshh
Copy link

Description

Fixes #2842

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

@SahSantoshh SahSantoshh marked this pull request as draft August 14, 2024 06:57
// This line fixes a bug where the search box would be duplicated on back navigation.
this.autocompleteTarget.innerHTML = ''

const { destroy } = autocomplete({
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

document.body.classList.remove('aa-Detached')
}

searchUrl(query) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

}
}

addSource(resourceName, data) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function addSource has 73 lines of code (exceeds 25 allowed). Consider refactoring.

header() {
return `${data.header.toUpperCase()} ${data.help}`
},
item({ item, createElement }) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function item has 54 lines of code (exceeds 25 allowed). Consider refactoring.

}
}

addSource(resourceName, data) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

Copy link

codeclimate bot commented Aug 14, 2024

Code Climate has analyzed commit 642358f and detected 0 issues on this pull request.

View more on Code Climate.

}
}

handleOnSelect({ item }) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

// params.global = true
// }

if (this.isBelongsToSearch || this.isHasManySearch) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

}
}

addSource(resourceName, data) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function addSource has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.

return this.dataset.searchResource === 'global'
}

connect() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function connect has 38 lines of code (exceeds 25 allowed). Consider refactoring.

return params
}

addReflectionParams(params) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

},
getSources: ({ query }) => {
document.body.classList.add('search-loading')
const endpoint = that.searchUrl(query)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first look, seems like potential XSS. Should query be sanitized?

const sanitizedQuery = encodeURIComponent(query);
const endpoint = that.searchUrl(sanitizedQuery);

'clearButton',
]

debouncedFetch = debouncePromise(fetch, this.searchDebounce)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this.searchDebounce return link to the function, instead of the result of searchDebounce()?

I'd advise adding tests

// form.requestSubmit()
// Retrieve params via url.search, passed into constructor
const url = new URL(window.location)
console.log(url.searchParams.toString(), event.target.value)

Check failure

Code scanning / CodeQL

Use of externally-controlled format string

Format string depends on a [user-provided value](1).
@SahSantoshh SahSantoshh force-pushed the feature/ability_to_see_search_result_in_index_page branch from c4b25cc to 642358f Compare September 5, 2024 08:08
Copy link
Contributor

This PR has been marked as stale because there was no activity for the past 15 days.

@github-actions github-actions bot added the Stale label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Ability to see the search result in index page
3 participants