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

feat: markdown, link click support, and project view for hackathon projects #877

Merged
merged 12 commits into from
Oct 28, 2021
2 changes: 1 addition & 1 deletion packages/hackathon/src/components/Header/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { Header } from './Header'
export * from './Header'
2 changes: 1 addition & 1 deletion packages/hackathon/src/components/Loading/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { Loading } from './Loading'
export * from './Loading'
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,28 @@
*/
import type { FC } from 'react'
import React from 'react'
import {
Dialog,
DialogHeader,
DialogContent,
Paragraph,
SpaceVertical,
TextArea,
} from '@looker/components'
import { useSelector, useDispatch } from 'react-redux'
import { setMoreInfo } from '../../data/projects/actions'
import { getMoreInfoState } from '../../data/projects/selectors'
import { Dialog, DialogHeader, DialogContent } from '@looker/components'
import { ProjectView } from '../../scenes/ProjectViewScene/components'
import type { IProjectProps } from '../../models'

interface MoreInfoDialogProps {}

export const MoreInfoDialog: FC<MoreInfoDialogProps> = () => {
const dispatch = useDispatch()
const moreInfoProject = useSelector(getMoreInfoState)
interface ProjectViewDialogProps {
project?: IProjectProps
closer: () => void
}

const closeMoreInfo = () => {
dispatch(setMoreInfo())
export const ProjectViewDialog: FC<ProjectViewDialogProps> = ({
project,
closer,
}) => {
const closeDialog = () => {
closer()
}

return (
<Dialog isOpen={!!moreInfoProject} onClose={closeMoreInfo}>
<DialogHeader>{moreInfoProject?.title}</DialogHeader>
<Dialog isOpen={!!project} onClose={closeDialog}>
<DialogHeader>Judging {project?.title}</DialogHeader>
<DialogContent>
<SpaceVertical>
<Paragraph>
Copy the link below and paste into a new browser window to see
additional information about the project
</Paragraph>
<TextArea
readOnly={true}
value={moreInfoProject?.moreInfo}
></TextArea>
</SpaceVertical>
{!!project && <ProjectView project={project} />}
</DialogContent>
</Dialog>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { MoreInfoDialog } from './MoreInfoDialog'
export * from './ProjectViewDialog'
2 changes: 1 addition & 1 deletion packages/hackathon/src/components/Scroller/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { Scroller } from './Scroller'
export * from './Scroller'
6 changes: 3 additions & 3 deletions packages/hackathon/src/components/SideNav/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import type { FC } from 'react'
import React from 'react'
import styled from 'styled-components'
import { Box, MenuList, MenuItem } from '@looker/components'
import { Box2, MenuList, MenuItem } from '@looker/components'
import { Beaker } from '@looker/icons'
import { Map } from '@styled-icons/material/Map'
import { Settings } from '@styled-icons/material/Settings'
Expand All @@ -41,7 +41,7 @@ export interface SideNavProps {
}

export const SideNav: FC<SideNavProps> = ({ authorizedRoutes }) => (
<Box fontSize="xxlarge" mt="40px">
<Box2 fontSize="xxlarge" mt="40px">
<MenuList type="none">
{authorizedRoutes.includes(Routes.HOME) && (
<MenuItem icon={<Home />}>
Expand Down Expand Up @@ -74,7 +74,7 @@ export const SideNav: FC<SideNavProps> = ({ authorizedRoutes }) => (
</MenuItem>
)}
</MenuList>
</Box>
</Box2>
)

const Link = styled(NavLink)`
Expand Down
2 changes: 1 addition & 1 deletion packages/hackathon/src/components/SideNav/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { SideNav } from './SideNav'
export * from './SideNav'
17 changes: 0 additions & 17 deletions packages/hackathon/src/data/projects/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ export interface LockProjectAction {
}
}

export interface SetMoreInfoAction {
type: Actions.SET_MORE_INFO
payload?: {
title: string
moreInfo: string
}
}

export type ProjectAction =
| AllProjectsRequestAction
| AllProjectsResponseAction
Expand All @@ -161,7 +153,6 @@ export type ProjectAction =
| LockProjectAction
| ChangeMembershipAction
| UpdateProjectsPageNumAction
| SetMoreInfoAction

export const allProjectsRequest = (): AllProjectsRequestAction => ({
type: Actions.ALL_PROJECTS_REQUEST,
Expand Down Expand Up @@ -278,11 +269,3 @@ export const changeMembership = (
leave,
},
})

export const setMoreInfo = (
title?: string,
moreInfo?: string
): SetMoreInfoAction => ({
type: Actions.SET_MORE_INFO,
payload: moreInfo && title ? { title, moreInfo } : undefined,
})
9 changes: 0 additions & 9 deletions packages/hackathon/src/data/projects/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ export interface ProjectsState {
validationMessages?: ValidationMessages
projectUpdated?: boolean
projectLoaded: boolean
moreInfo?: {
title: string
moreInfo: string
}
}

const defaultState: Readonly<ProjectsState> = Object.freeze({
Expand Down Expand Up @@ -123,11 +119,6 @@ export const projectsReducer = (
isProjectMember: action.payload.isProjectMember,
projectUpdated: true,
}
case Actions.SET_MORE_INFO:
return {
...state,
moreInfo: action.payload,
}
default:
return state
}
Expand Down
9 changes: 8 additions & 1 deletion packages/hackathon/src/data/projects/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ import { getCurrentProjectsState, getIsProjectMemberState } from './selectors'
const createNewProject = (): IProjectProps => {
const newProject: unknown = {
title: '',
description: '',
description: `<Put a project overview here. Should be at least one paragraph.>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Feel free to update/tweak this template. This is what shows up for a new project in the Description field

Copy link
Collaborator

Choose a reason for hiding this comment

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

Internationalize?


Team name: **My fabulous team**
- Pre-recorded [demo video link](https://youtube.com) (preferably youtube)
- Working [demo](https://looker.com) (optional). Provide any relevant start-up instructions for someone to run the demo.
- Links to any other [supporting resources](https://docs.google.com) (slides, images, etc.) (preferably google slides and imgur)
- Add your pictures/screenshots of your team hacking to the [Hack@Home 2021 shared folder](https://tbd). Create your own team folder inside it if you'd like!
`,
project_type: 'Open',
contestant: false,
locked: false,
Expand Down
5 changes: 0 additions & 5 deletions packages/hackathon/src/data/projects/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ export const getProjectsLoadedState = (state: RootState): boolean =>
export const getProjectsPageNumState = (state: RootState): number =>
state.projectsState.currentPageNum

export const getMoreInfoState = (
state: RootState
): { title: string; moreInfo: string } | undefined =>
state.projectsState.moreInfo

export const getProjectState = (state: RootState): IProjectProps | undefined =>
state.projectsState.currentProject

Expand Down
12 changes: 9 additions & 3 deletions packages/hackathon/src/models/Judgings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export interface IJudgingProps extends IRowModelProps {
notes: string
$title: string
$description: string
$more_info: string
$project_type: string
$contestant: boolean
$technologies: string[]
$judge_name: string
$members: string[]
}
Expand All @@ -72,8 +74,10 @@ export class Judging extends SheetRow<IJudging> {
notes = ''
$title = ''
$description = ''
$more_info = ''
$judge_name = ''
$project_type = ''
$contestant = false
$technologies: string[] = []
$members: string[] = []

constructor(values?: any) {
Expand All @@ -95,10 +99,12 @@ export class Judging extends SheetRow<IJudging> {
}
const p = data.projects?.find(this.project_id) as Project
if (p) {
this.$project_type = p.project_type
this.$contestant = p.contestant
this.$technologies = p.technologies
this.$title = p.title
this.$description = p.description
this.$members = p.$members
this.$more_info = p.more_info
}
}

Expand Down
8 changes: 8 additions & 0 deletions packages/hackathon/src/routes/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ import {
ProjectEditorScene,
ResourceScene,
} from '../scenes'
import { ProjectViewScene } from '../scenes/ProjectViewScene'
export enum Routes {
HOME = '/home',
ADMIN = '/admin',
JUDGING = '/judging',
EDIT_JUDGING = '/judging/:id',
PROJECTS = '/projects',
VIEW_PROJECT = '/projectview/:id',
CREATE_PROJECT = '/projects/new',
EDIT_PROJECT = '/projects/:id',
USERS = '/users',
Expand All @@ -65,6 +67,7 @@ export const getAuthorizedRoutes = (
if (hacker) {
if (currentHackathon) {
authorizedRoutes.push(Routes.PROJECTS)
authorizedRoutes.push(Routes.VIEW_PROJECT)
authorizedRoutes.push(Routes.CREATE_PROJECT)
authorizedRoutes.push(Routes.EDIT_PROJECT)
if (hacker.canAdmin || hacker.canJudge || hacker.canStaff) {
Expand Down Expand Up @@ -132,6 +135,11 @@ export const AppRouter: FC<AppRouterProps> = ({ authorizedRoutes, hacker }) => (
<ProjectEditorScene />
</Route>
)}
{authorizedRoutes.includes(Routes.VIEW_PROJECT) && (
<Route path={Routes.VIEW_PROJECT} exact>
<ProjectViewScene />
</Route>
)}
{authorizedRoutes.includes(Routes.USERS) && (
<Route path={Routes.USERS}>
<UsersScene />
Expand Down
2 changes: 1 addition & 1 deletion packages/hackathon/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { AppRouter, getAuthorizedRoutes } from './AppRouter'
export * from './AppRouter'
2 changes: 1 addition & 1 deletion packages/hackathon/src/scenes/AdminScene/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { AdminScene } from './AdminScene'
export * from './AdminScene'
2 changes: 1 addition & 1 deletion packages/hackathon/src/scenes/HomeScene/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { HomeScene } from './HomeScene'
export * from './HomeScene'
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { JudgingForm } from './JudgingForm'
export * from './JudgingForm'
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
SOFTWARE.

*/
export { JudgingEditorScene } from './JudgingEditorScene'
export * from './JudgingEditorScene'
Loading