-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: godirectory endpoint draft 1 - add GET endpoint for /api/directory/search - requires query, order, limit, offset and isEmail - decision to search by email or text is done in UrlRepository - to be done: use mappers - to be done: change hardcoded sql variables and sql query checkers - to be done: include user guard for route - to be done: isolate filter checkers into helper functions * feat: godirectory dashboard - add directory ui - add directory redirection - add actions and reducers for directory - remove userid that was previously added to urltypes - refactor endpoint * feat: include email in directory - include individual email in search results * fix: ui and redirection for directory - add mini go logo for mobile version - ensure directory to redirect back to itself on refresh - stop pagination row and sort panel from intersecting - fix svg resizing - refactor domain validation * fix: filter panel and ui tweaks - expand filter button to cover square area - replace go logo with mini version for mobile mode - clip shorturl in mobile panel for directory * refactor: add userguard to directory endpoint - change the jsdoc for rawdirectoryinput * refactor: godirectory - refactor code for redirection to directory page from login page - remove the new email validation and use the old validation - replace lengthy arguments with directoryquerycondition - make isfile condition explicit - refactor rawdirectorysearch - add noopener and noreferrer to window open and anchor tag - remove semicolon for both directory and search headers - add test for directorycontroller - add test for directorysearchservice - add test for urlrepository * feat: event tracking and redirection - track ga event and sentry event for directory search for both success and error case - track ga event and pageview when entering into directory page - provide redirection to directory page in error message on link creation modal * fix: directory reset and announcement modal - add new reset result state and action in redux - reset to initial result state when toggle between keyword and email in directory - add new svg to announcement modal - add line break functionality to announcement message * Update BaseLayoutHeader.jsx * Update UrlManagementService.ts * fix: ga tracking and refactor Co-authored-by: oxiang <[email protected]>
- Loading branch information
Showing
75 changed files
with
3,525 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
public/assets/transition-page/images/directory-browser.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import { ThunkAction } from 'redux-thunk' | ||
import { Dispatch } from 'react' | ||
import querystring from 'querystring' | ||
import { History } from 'history' | ||
import * as Sentry from '@sentry/browser' | ||
import { | ||
DirectoryActionType, | ||
ResetDirectoryResultsAction, | ||
SET_DIRECTORY_RESULTS, | ||
SET_INITIAL_STATE, | ||
SetDirectoryResultsAction, | ||
} from './types' | ||
import { GoGovReduxState } from '../../reducers/types' | ||
import { RootActionType, SetErrorMessageAction } from '../root/types' | ||
import rootActions from '../root' | ||
import { SearchResultsSortOrder } from '../../../shared/search' | ||
import { get } from '../../util/requests' | ||
import { DIRECTORY_PAGE } from '../../util/types' | ||
import { UrlTypePublic } from '../../reducers/directory/types' | ||
import { GAEvent } from '../ga' | ||
|
||
function setDirectoryResults(payload: { | ||
count: number | ||
urls: Array<UrlTypePublic> | ||
query: string | ||
}): SetDirectoryResultsAction { | ||
return { | ||
type: SET_DIRECTORY_RESULTS, | ||
payload, | ||
} | ||
} | ||
|
||
function resetDirectoryResults(): ResetDirectoryResultsAction { | ||
return { | ||
type: SET_INITIAL_STATE, | ||
} | ||
} | ||
|
||
const getDirectoryResults = ( | ||
query: string, | ||
order: SearchResultsSortOrder, | ||
rowsPerPage: number, | ||
currentPage: number, | ||
state: string, | ||
isFile: string, | ||
isEmail: string, | ||
): ThunkAction< | ||
void, | ||
GoGovReduxState, | ||
void, | ||
DirectoryActionType | RootActionType | ||
> => async ( | ||
dispatch: Dispatch<SetErrorMessageAction | SetDirectoryResultsAction>, | ||
) => { | ||
if (!query.trim()) { | ||
return | ||
} | ||
const offset = currentPage * rowsPerPage | ||
const limit = rowsPerPage | ||
const paramsObj = { | ||
query, | ||
order, | ||
limit, | ||
offset, | ||
state, | ||
isFile, | ||
isEmail, | ||
} | ||
const params = querystring.stringify(paramsObj) | ||
const response = await get(`/api/directory/search?${params}`) | ||
const json = await response.json() | ||
if (!response.ok) { | ||
// Report error from endpoints | ||
GAEvent('directory page', query, 'unsuccessful') | ||
Sentry.captureMessage('directory search unsuccessful') | ||
dispatch( | ||
rootActions.setErrorMessage( | ||
json.message || 'Error fetching search results', | ||
), | ||
) | ||
return | ||
} | ||
|
||
let filteredQuery = '' | ||
|
||
if (isEmail === 'true') { | ||
// split by space, then split each subset by @ and take the last part (domain), then rejoin back the string | ||
filteredQuery = query | ||
.split(' ') | ||
.map((subset) => subset.split('@').slice(-1)) | ||
.join(' ') | ||
} else { | ||
// Remove all words that have @ inside to prevent potential email address problem | ||
filteredQuery = query.replace('@', ' ') | ||
} | ||
GAEvent('directory page', filteredQuery, 'successful') | ||
dispatch( | ||
setDirectoryResults({ | ||
count: json.count, | ||
urls: json.urls as Array<UrlTypePublic>, | ||
query, | ||
}), | ||
) | ||
} | ||
|
||
const redirectToDirectoryPage = ( | ||
history: History, | ||
query: string, | ||
): ThunkAction< | ||
void, | ||
GoGovReduxState, | ||
void, | ||
DirectoryActionType | RootActionType | ||
> => () => { | ||
history.push({ | ||
pathname: DIRECTORY_PAGE, | ||
search: querystring.stringify({ query }), | ||
}) | ||
} | ||
|
||
export default { | ||
getDirectoryResults, | ||
setDirectoryResults, | ||
redirectToDirectoryPage, | ||
resetDirectoryResults, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { UrlTypePublic } from '../../reducers/directory/types' | ||
|
||
export const SET_DIRECTORY_RESULTS = 'SET_DIRECTORY_RESULTS' | ||
export const SET_DIRECTORY_TABLE_CONFIG = 'SET_DIRECTORY_TABLE_CONFIG' | ||
export const SET_INITIAL_STATE = 'SET_INITIAL_STATE' | ||
|
||
export type SetDirectoryResultsAction = { | ||
type: typeof SET_DIRECTORY_RESULTS | ||
payload: { | ||
urls: Array<UrlTypePublic> | ||
count: number | ||
query: string | ||
} | ||
} | ||
|
||
export type ResetDirectoryResultsAction = { | ||
type: typeof SET_INITIAL_STATE | ||
} | ||
|
||
export type DirectoryActionType = | ||
| SetDirectoryResultsAction | ||
| ResetDirectoryResultsAction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
src/client/components/BaseLayout/assets/logout-white-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.