Skip to content

Conversation

@rosemcc
Copy link
Contributor

@rosemcc rosemcc commented Feb 14, 2022

Feature

Include results from the Staff Intranet in the ResearchHub search results UI

Description

The Intranet contains documents that overlap with the material the Research Hub provides. It is helpful to be able to include results from the Intranet in the Research Hub search, enabling users to navigate directly to these documents from the Research Hub search results page.

Intranet search results are accessed via a Swiftype API, within a collection called "Staff Intranet". This feature provides an update to the search page UI so logged-in users can choose to view the Intranet results, as well as the implementation of the backend API wrapper to access the Swiftype API securely. More information around the technical and security considerations of adding this feature can be found here.

Solution

Swiftype API Wrapper - Lambda function

A new endpoint has been added to the Hub-Search-Proxy lambda function which acts as a middleware between the UI and the Swiftype API. The purpose of this is to provide a secure way to access the Intranet search results, which must be behind SSO, as well as keeping the Swiftype API key in a secure location which will never be exposed to the frontend.

The new endpoint function is implemented in a separate handler file (uoasearch.js). The endpoint path is /uoasearch, which is configured in the serverless.yml, along with an API Gateway Authorizer to enable Cognito user pool authorization of requests to the endpoint. Requests must contain a valid auth token or they will be blocked by API Gateway. Requests are authorized by checking the user is in the valid access group to be able to view Staff Intranet data.

Search UI Changes

A tabbed interface has been added to the search results page using Angular Material Tabs component. ResearchHub results are shown in the default tab, and Staff Intranet results are shown (if the user is logged in) in a second tab, as a separate list. Results are only returned when a search query is present. Search filters are not applied on the Intranet results.

New components/services:

  • IntranetSearchService
  • IntranetSearchComponent
  • IntranetSearchResultsListComponent

Cloudfront Function change

  • updated CSP to allow the new search endpoint

Screenshots

Before

image

After

image

Staff Intranet tab:
image

Testing

research-hub-web

IntranetSearchComponent:

  • should create
  • Initial search properties should be undefined
  • search should update search variables
  • should not call intranet search if not logged in

IntranetSearchResultsListComponent:

  • should create
  • should show skeleton when loading
  • should show 1 results card for each search result

IntranetSearchService

  • should be created
  • should make a POST request and return search result

hub-search-proxy

  • POST uoasearch request returns a response
  • POST uoasearch request with invalid sort option returns an error

Have the changes been checked in the following browsers?

  • Chrome
  • Safari
  • Firefox
  • Edge

@rosemcc rosemcc requested a review from Trombach February 14, 2022 00:22
@rosemcc rosemcc requested a review from robmint February 14, 2022 02:53
Copy link
Contributor

@Trombach Trombach left a comment

Choose a reason for hiding this comment

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

See comments

<div>No More Results</div>
</div>
<mat-tab label="ResearchHub">
<app-search-filter-bar
Copy link
Contributor

Choose a reason for hiding this comment

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

The bar is currently not sticky.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Trombach may need your help on this one.

@rosemcc
Copy link
Contributor Author

rosemcc commented Feb 21, 2022

@Trombach have addressed most comments, just haven't managed to fix the sticky filter bar. Also added some (very) basic error handling for if there's any issue with fetching search results. The error handling could be improved with adding more informative message for the user, but for now I think it is enough.

@rosemcc
Copy link
Contributor Author

rosemcc commented Feb 21, 2022

@Trombach also, if you have time could you please do a quick check of the interface in Safari? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants