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

Godirectory #813

Merged
merged 14 commits into from
Nov 3, 2020
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ services:
- VALID_EMAIL_GLOB_EXPRESSION=*.gov.sg
- LOGIN_MESSAGE=Your OTP might take awhile to get to you.
- USER_MESSAGE=User message test
- ANNOUNCEMENT_MESSAGE=The quick brown fox jumps over a lazy dog
- ANNOUNCEMENT_TITLE=Some title
- ANNOUNCEMENT_SUBTITLE=Subtitle is found here
- ANNOUNCEMENT_MESSAGE=Search by email to find link owners, or by keyword to discover other links! \n PRO TIP! Search your email domain to find out all the links made by your agency.
- ANNOUNCEMENT_TITLE=GoDirectory is here!
- ANNOUNCEMENT_SUBTITLE=Search all go.gov.sg links
- ANNOUNCEMENT_URL=https://go.gov.sg/
- ANNOUNCEMENT_IMAGE=/assets/transition-page/images/browser.svg
- ANNOUNCEMENT_IMAGE=/assets/transition-page/images/directory-browser.svg
- AWS_S3_BUCKET=local-bucket
- ROTATED_LINKS=whatsapp,passport,spsc,sppr
- AWS_ACCESS_KEY_ID=foobar
Expand Down
20 changes: 20 additions & 0 deletions 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.
9 changes: 9 additions & 0 deletions src/client/actions/directory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ 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'
Expand All @@ -28,6 +30,12 @@ function setDirectoryResults(payload: {
}
}

function resetDirectoryResults(): ResetDirectoryResultsAction {
return {
type: SET_INITIAL_STATE,
}
}

const getDirectoryResults = (
query: string,
order: SearchResultsSortOrder,
Expand Down Expand Up @@ -103,4 +111,5 @@ export default {
getDirectoryResults,
setDirectoryResults,
redirectToDirectoryPage,
resetDirectoryResults,
}
9 changes: 8 additions & 1 deletion src/client/actions/directory/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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
Expand All @@ -12,4 +13,10 @@ export type SetDirectoryResultsAction = {
}
}

export type DirectoryActionType = SetDirectoryResultsAction
export type ResetDirectoryResultsAction = {
type: typeof SET_INITIAL_STATE
}

export type DirectoryActionType =
| SetDirectoryResultsAction
| ResetDirectoryResultsAction
23 changes: 5 additions & 18 deletions src/client/components/DirectoryPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,6 @@ const SearchPage: FunctionComponent<SearchPageProps> = () => {
),
)

// Reset offset
const getFilteredResults = () =>
dispatch(
directoryActions.getDirectoryResults(
query,
queryOrder,
rowsPerPage,
defaultParams.currentPage,
querystate,
queryFile,
queryEmail
)
)

const resultsCount = useSelector(
(state: GoGovReduxState) => state.directory.resultsCount,
)
Expand Down Expand Up @@ -193,18 +179,20 @@ const SearchPage: FunctionComponent<SearchPageProps> = () => {

// Changes when queryEmail changes
useEffect(() => {
setPendingQuery('')
dispatch(
directoryActions.resetDirectoryResults()
)
redirectWithParams(
{
...params,
...defaultParams,
state: querystate,
isFile: queryFile,
sortOrder: queryOrder,
isEmail: queryEmail,
currentPage: defaultParams.currentPage,
},
history,
)
getFilteredResults()
}, [queryEmail])

const onClearQuery = () => {
Expand Down Expand Up @@ -248,7 +236,6 @@ const SearchPage: FunctionComponent<SearchPageProps> = () => {
}

const queryToDisplay = (queryForResult || '').trim()

// detect changes in query
useEffect(() => {
if (!query) {
Expand Down
30 changes: 25 additions & 5 deletions src/client/components/UserPage/AnnouncementModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ const useStyles = makeStyles((theme) =>
backgroundColor: theme.palette.primary.dark,
},
announcementImage: {
marginTop: theme.spacing(-4),
width: '600px',
marginLeft: 'auto',
marginRight: 'auto',
paddingLeft: '80px',
paddingRight: '80px',
marginTop: theme.spacing(-6),
marginBottom: theme.spacing(4),
[theme.breakpoints.down('sm')]: {
paddingLeft: '0px',
paddingRight: '0px',
},
},
announcementPadding: {
paddingBottom: theme.spacing(4),
Expand All @@ -43,9 +52,19 @@ const useStyles = makeStyles((theme) =>
justifyContent: 'center',
width: '100%',
},
justifyCenterImage: {
display: 'flex',
justifyContent: 'center',
width: '600px',
[theme.breakpoints.down('sm')]: {
width: '100%',
},
},
messagePadding: {
paddingLeft: theme.spacing(4),
paddingRight: theme.spacing(4),
whiteSpace: 'pre-line',
textAlign: 'center',
},
closeIconButton: {
fill: (props) =>
Expand Down Expand Up @@ -174,13 +193,13 @@ export default function AnnouncementModal() {
)}
{announcement?.image ? (
<img
className={`${classes.justifyCenter} ${classes.announcementImage}`}
className={`${classes.justifyCenterImage} ${classes.announcementImage}`}
alt=""
src={announcement.image}
/>
) : (
<div
className={`${classes.justifyCenter} ${classes.announcementPadding}`}
className={`${classes.justifyCenterImage} ${classes.announcementPadding}`}
/>
)}
{announcement?.subtitle ? (
Expand All @@ -197,7 +216,8 @@ export default function AnnouncementModal() {
className={`${classes.justifyCenter} ${classes.messagePadding}`}
variant="body2"
>
{announcement.message}
{/* Enable line break */}
{announcement.message.replace(/\\n/g, '\n')}
</Typography>
) : null}
<div className={`${classes.justifyCenter} ${classes.modalBottom}`}>
Expand All @@ -210,7 +230,7 @@ export default function AnnouncementModal() {
variant="text"
className={classes.learnMoreButton}
>
Learn More
Try it now
LoneRifle marked this conversation as resolved.
Show resolved Hide resolved
</Button>
) : null}
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/client/reducers/directory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { DirectoryState } from './types'
import {
DirectoryActionType,
SET_DIRECTORY_RESULTS,
SET_INITIAL_STATE,
} from '../../actions/directory/types'

const initialState: DirectoryState = {
export const initialState: DirectoryState = {
results: [],
resultsCount: 0,
queryForResult: null,
Expand All @@ -23,6 +24,9 @@ const directory: (
queryForResult: action.payload.query,
}
break
case SET_INITIAL_STATE:
nextState = initialState
break
default:
break
}
Expand Down