-
Notifications
You must be signed in to change notification settings - Fork 2
Add documentation for frontend code #189
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
Open
subhankar-panda
wants to merge
33
commits into
master
Choose a base branch
from
frontend-docs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
eae331b
Added root-level frontend README
subhankar-panda 593ee9d
Tree
subhankar-panda 5b9d6f1
Removed links
subhankar-panda f63cf7e
Added pages documentation
subhankar-panda af31bfe
Documentation for AdminsPage and ApplyPage done
subhankar-panda aa50934
DashboardPage finished, TODO SettingsTab + StatisticsTab
subhankar-panda 7084fa3
Working through DashboardPage/components
subhankar-panda 21232d2
Event, HomePage Documentation complete
subhankar-panda 4e151e4
NewEventPage Documentation Complete
subhankar-panda adc8bb3
TODO RSVPConfirm onwards and UsersPage
subhankar-panda 8bc1755
User and UsersPage done
subhankar-panda 4314fef
Almost done with pages application
subhankar-panda e253abe
Ran tslint --fix
subhankar-panda 9af8651
Ran tslint --fix
subhankar-panda ea58fb4
Fixed merge conflict:
subhankar-panda 8437aea
Added root-level frontend README
subhankar-panda 93e6d47
Tree
subhankar-panda 8f5f642
Removed links
subhankar-panda e35f0c2
Added pages documentation
subhankar-panda f25ae32
Documentation for AdminsPage and ApplyPage done
subhankar-panda 2fc4eb2
DashboardPage finished, TODO SettingsTab + StatisticsTab
subhankar-panda 4da75a5
Working through DashboardPage/components
subhankar-panda 5c157b2
Event, HomePage Documentation complete
subhankar-panda be514e0
NewEventPage Documentation Complete
subhankar-panda c18ed86
TODO RSVPConfirm onwards and UsersPage
subhankar-panda c7b4585
User and UsersPage done
subhankar-panda 55ed7de
Almost done with pages application
subhankar-panda 307d9ad
Ran tslint --fix
subhankar-panda 8337ffc
Ran tslint --fix
subhankar-panda b4ca736
Last pass for frontend docs
subhankar-panda fd060ef
Added exportEmails Fn
subhankar-panda 5fd58f4
Fixed Merge
subhankar-panda 039fb65
Fixed exportEmails
subhankar-panda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,40 @@ | ||
| ## src/client - Frontend | ||
|
|
||
| This directory is the home for the frontend for tesc.events. | ||
|
|
||
| tesc.events' frontend is written entirely in [React.js](https://reactjs.org/). It was initially written in JavaScript, but [was ported over to TypeScript in April 2019](https://github.com/UCSDTESC/Check-in/pull/131) | ||
|
|
||
| The entry point to the code is in [main.tsx](https://github.com/UCSDTESC/Check-in/blob/master/src/client/main.tsx) | ||
|
|
||
|
|
||
| ### Directory Tree | ||
| ``` | ||
| ├── PrivateRoute.tsx | ||
| * Wrapper Component around react-router-dom's Route to handle rendering only if the user requesting the page is authenticated. Used on admin-side routes. | ||
| ├── PrivateUserRoute.tsx | ||
| * Wrapper Component around react-router-dom's Route to handle rendering only if the user requesting the page is authenticated. Used on user-side routes. | ||
| ├── README.md | ||
| * 😊 | ||
| ├── actions | ||
| * This directory holds application-level Redux Actions. | ||
| ├── auth | ||
| * This directory holds the components, Redux Actions and Redux Reducers related to the login/logout functionality of both users and admins. | ||
| ├── components | ||
| * Components that are required "globally" or in multiple places in the application are put here. Things like the Navbar, Footer, iOS Switch, Loading spinners etc. go here. | ||
| ├── data | ||
| * The `data/` directory holds `Api.ts` and `User.ts`, which provide the application with methods to make API calls to our backend. | ||
| ├── layouts | ||
| * A Layout defines the way our application looks. The application has different layouts depending on what kind of page you are looking at - admins and sponsors have sidebars, and users dont. Layouts are linked to a specific route in the `routes.tsx` file. | ||
| ├── main.tsx | ||
| * This is the entrypoint to our application. It sets up our app to be used with Redux, react-router and Cookies and makes the intial React.Component.render() call. | ||
| ├── pages | ||
| * Each `XYZPage` in the `pages` directory is linked to a specific page of the app. Each page is it’s own directory with an `index.tsx` file in it that defines that page. Each page can also define Redux Actions, Reducers and Components that it will use in `XYZPage/actions`, `XYZPage/reducers` and `XYZPage/components | ||
| ├── reducers | ||
| * This directory holds application-level Redux Reducers. | ||
| ├── routes.tsx | ||
| * This directory defines react-router-dom's routes for the application. | ||
| ├── static | ||
| * This directory holds "constant" data that the application needs - a list of universities, majors and so on. | ||
| └── typings | ||
| * TypeScript type definitions for JavaScript packages used in this application that are directly supplied by us - not by node_modules | ||
| ``` |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -23,8 +23,8 @@ import request, { SuperAgentRequest } from 'superagent'; | |
| import nocache from 'superagent-no-cache'; | ||
| import pref from 'superagent-prefix'; | ||
| import Cookies from 'universal-cookie'; | ||
| import { NewAdminModalFormData } from '~/components/NewAdminModal'; | ||
| import { EventFormData } from '~/components/EventForm'; | ||
| import { NewAdminModalFormData } from '~/components/NewAdminModal'; | ||
| import CookieTypes from '~/static/Cookies'; | ||
|
|
||
| import { promisify } from './helpers'; | ||
|
|
@@ -195,7 +195,6 @@ export const editExistingEvent = (id: string, event: Partial<EventFormData>) => | |
| closeTimeDay | ||
| )).toISOString(true); | ||
|
|
||
|
|
||
| const promiseReq = request | ||
| .post(`/events/edit/${id}`) | ||
| .set('Authorization', cookies.get(CookieTypes.admin.token)) | ||
|
|
@@ -204,14 +203,14 @@ export const editExistingEvent = (id: string, event: Partial<EventFormData>) => | |
| closeTime, | ||
| } as RegisterEventRequest)) | ||
| .use(adminApiPrefix) | ||
| .use(nocache) | ||
| .use(nocache); | ||
|
|
||
| if (logo) { | ||
| promiseReq.attach('logo', logo[0]) | ||
| if (logo) { | ||
| promiseReq.attach('logo', logo[0]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. misaligned |
||
| } | ||
|
|
||
| return promisify<void>(promiseReq); | ||
| } | ||
| return promisify<void>(promiseReq); | ||
| }; | ||
|
|
||
| /** | ||
| * Request to register a new admin. | ||
|
|
@@ -250,7 +249,7 @@ export const downloadResumes = (applicants: string[]): SuperAgentRequest => | |
| .post('/resumes') | ||
| .send({ applicants } as DownloadResumesRequest) | ||
| .set('Authorization', cookies.get(CookieTypes.admin.token)) | ||
| .use(adminApiPrefix) | ||
| .use(adminApiPrefix); | ||
|
|
||
| /** | ||
| * Requests the status of an ongoing download. | ||
|
|
@@ -450,4 +449,4 @@ export const sendWaitlistEmail = (user: TESCUser) => | |
| .send({ user } as StatusEmailRequest) | ||
| .use(adminApiPrefix) | ||
| .use(nocache) | ||
| ); | ||
| ); | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -12,4 +12,4 @@ class PublicLayout extends React.Component { | |
| } | ||
| } | ||
|
|
||
| export default PublicLayout; | ||
| export default PublicLayout; | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,8 +4,15 @@ import React from 'react'; | |
| import { Button } from 'reactstrap'; | ||
|
|
||
| interface AdminListProps { | ||
|
|
||
| // The admins in the system | ||
| admins: Admin[]; | ||
|
|
||
| // Function to be called when the delete button is pressed | ||
| onDeleteAdmin: (adminId: string) => void; | ||
|
|
||
| // Is the admin in editing mode | ||
| // TODO: remove - legacy feature | ||
| editing: boolean; | ||
| } | ||
|
|
||
|
|
@@ -19,12 +26,15 @@ interface AdminListState { | |
| columns: DisplayColumnMap; | ||
| } | ||
|
|
||
| /** | ||
| * This component renders a list of admins on the admins page | ||
| */ | ||
| export default class AdminList extends React.Component<AdminListProps, AdminListState> { | ||
| state: Readonly<AdminListState> = { | ||
| columns: { | ||
| username: 'Username', | ||
| role: 'Role', | ||
| lastAccessed: 'Last Accessed' | ||
| lastAccessed: 'Last Accessed', | ||
| }, | ||
| }; | ||
|
|
||
|
|
@@ -46,19 +56,19 @@ export default class AdminList extends React.Component<AdminListProps, AdminList | |
| renderAdmin = (admin: Admin) => { | ||
| const {columns} = this.state; | ||
|
|
||
| const adminToBeRendered = {...admin, | ||
| lastAccessed: admin.lastAccessed | ||
| ? moment(admin.lastAccessed).fromNow() | ||
| : 'Never Logged In' | ||
| } | ||
| const adminToBeRendered = {...admin, | ||
| lastAccessed: admin.lastAccessed | ||
| ? moment(admin.lastAccessed).fromNow() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you align these lines somehow |
||
| : 'Never Logged In', | ||
| }; | ||
| return Object.keys(columns).map(column => ( | ||
| <td key={column} className="admin-list__value"> | ||
| {/* | ||
| // TODO: Fix accessing dynamic properties | ||
| // @ts-ignore */} | ||
| {adminToBeRendered[column]} | ||
| </td>) | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| render() { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be aligned with line 1? Does ESLint fix these kind of formatting issues?
Since this is a refactoring PR I'm gonna be ocd about these kind of stuff 😛