Skip to content

Commit

Permalink
Merge pull request #538 from engaging-computing/revert-501-doc
Browse files Browse the repository at this point in the history
Revert "Added documentation for missing functions and some clean up"
  • Loading branch information
kdvalin authored Feb 7, 2022
2 parents ef10929 + 99bd8ec commit 8998b31
Show file tree
Hide file tree
Showing 69 changed files with 991 additions and 1,628 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on: [push, pull_request]
jobs:
ci-checks:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: '--max_old_space_size=4096'
container:
image: node:12.18

Expand Down
11 changes: 2 additions & 9 deletions src/actions/authActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as types from "../constants/ActionTypes";
*
* @param {obj} user User data from the firebase auth obj
*
* @returns {object} reducer action obj with type: LOGIN and user obj
* @returns reducer action obj with type: LOGIN and user obj
*/
export function login(user) {
return { type: types.LOGIN, user };
Expand All @@ -14,19 +14,12 @@ export function login(user) {
/**
* Sends a signal to the reducer to logout the current user
*
* @returns {object} reducer action obj with type: LOGOUT
* @returns reducer action obj with type: LOGOUT
*/
export function logout() {
return { type: types.LOGOUT };
}

/**
* Sends a signal to the reducer to refresh the token
*
* @param {object} token
*
* @returns {object} reducer action object with type: REFRESH_TOKEN and token obj
*/
export function refreshToken(token) {
return { type: types.REFRESH_TOKEN, token };
}
Expand Down
52 changes: 8 additions & 44 deletions src/actions/collectionActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@ import * as types from "../constants/ActionTypes";

export const collectRef = "/apiv1/collections";


/**
* Fetch the list of the user collection asynchronously
* Use when user login or added a new collection
*
* @param {*} uid A JWT token to authenticate with the backend
*/
export function asyncCollections(uid) {
export function asyncCollections(id) {
// fetch user's collections
return (dispatch) => {
if (uid) {
if (id) {
let userCollections = [];
fetch(collectRef, {headers: {"x-access-token": uid}}).then((data) => {
fetch(collectRef, {headers: {"x-access-token": id}}).then((data) => {
data.json().then((data) => {
data.forEach((doc) => {
userCollections.push(doc);
Expand All @@ -26,23 +19,10 @@ export function asyncCollections(uid) {
};
}

/**
* Sends a signal to the reducer to sync the user collections
*
* @param {object} payload List of user collections
*
* @returns {object} reducer action obj with type SYNC_COLLECTIONS with payload
*/
export function syncCollections(payload) {
return { type: types.SYNC_COLLECTIONS, payload: payload };
return { type: types.SYNC_CLASSES, payload: payload };
}

/**
* Fetch the specific collection specify by user
*
* @param {string} collectionID Collection id
* @param {*} uid A JWT token to authenticate with the backend
*/
export function asyncCollection(collectionID, uid) {
// fetch projects in collection
return (dispatch) => {
Expand Down Expand Up @@ -82,27 +62,13 @@ export function asyncCollection(collectionID, uid) {
};
}

/**
* Sends a signal to the reducer to load the retrieved collection
*
* @param {object} payload Data of retrieved collection
*
* @returns {object} reducer action obj with type: SYNC_COLLECTION and payload
*/
export function syncCollection(payload) {
return { type: types.SYNC_COLLECTION, payload: payload };
return { type: types.SYNC_CLASS, payload: payload };
}

/**
* Sends a signal to the reducer to delete the specific collection of user
*
* @param {string} collectionID Collection ID
* @param {string} name Name of the collection if exists
* @param {*} uid A JWT token to authenticate with the backend
*/
export function deleteCollection(collectionID, name = null, uid) {
export function deleteCollection(id, name = null, uid) {
return (dispatch) => {
name = (name ? name : collectionID);
name = (name ? name : id);
if (window.confirm(`Are you sure you want to delete collection "${name}"?`)) {

// Delete Document
Expand All @@ -111,14 +77,12 @@ export function deleteCollection(collectionID, name = null, uid) {
console.error(`Error deleting collection ${name}: ${resp.statusText}`);
return;
}
dispatch({ type: types.DELETE_COLLECTION, id: collectionID });
dispatch({ type: types.DELETE_CLASS, id: id });
});
}
};
}

/**
* Creates a new collection
*
* @param {string} name The name of the collection to be created
* @param {*} uid A JWT token to authenticate with the backend
Expand Down
78 changes: 24 additions & 54 deletions src/actions/courseActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as sceneActions from "./sceneActions";

const courseRef = "/apiv1/courses/";
const header = { headers: { "content-type": "application/json" } };
const noLessons = {
let noLessons = {
name: "",
id: -1,
prompt: "There are no lessons in this course",
Expand All @@ -19,11 +19,8 @@ const problem = {
code: ""
};

/*
* Course Actions
*/
/**
* Fetch all the courses available
* Course Actions
*/
export function fetchCourses() {
return (dispatch) => {
Expand All @@ -45,22 +42,10 @@ export function fetchCourses() {
};
}

/**
* Sends a signal to the reducer to synchronize the courses
*
* @param {*} payload List of courses retrieved
*
* @returns reducer action object with type: SYNC_COURSE and payload
*/
export function syncCourses(payload) {
return { type: types.SYNC_COURSES, payload: payload };
}

/**
* Fetch specific course
*
* @param {string} courseId id of the course getting
*/
export function fetchCourse(courseId) {
return (dispatch) => {
fetch(courseRef + courseId, header)
Expand Down Expand Up @@ -99,22 +84,15 @@ export function fetchCourse(courseId) {
};
}

/**
* Sends signal to the reducer to load the course retrieved
*
* @param {*} course Data of course retrieved
* @returns {object} reducer action obj with type: LOAD_COURSE and payload
*/
export function loadCourse(course) {
return { type: types.LOAD_COURSE, payload: course };
return {
type: types.LOAD_COURSE,
payload: course
};
}

/*
* Lesson Actions
*/
/**
* Fetch the lesson that is supplied by the parameter.
* @param {*} json Lesson data
* Lesson Actions
*/
export function fetchLesson(json) {
return (dispatch) => {
Expand All @@ -128,21 +106,10 @@ export function fetchLesson(json) {
}

/**
* Sends signal to the reducer to load a new lesson supplied by parameter
*
* @param {object} lesson Lesson data
* @returns reducer action obj with type: LOAD_LESSON and payload: lesson
*/
export function loadLesson(lesson) {
return { type: types.LOAD_LESSON, payload: lesson };
}

/**
* Increment the lesson index and load the next lesson.
* Frontend disables option if out of bounds
* Frontend disables option if out of bounds
*
* @param {number} currentIndex current index of the course
* @param {object} next Object of lesson to be load next
* @param {*} currentIndex !!!DESCRIPTION NEEDED!!!
* @param {*} next !!!DESCRIPTION NEEDED!!!
*/
export function nextLesson(currentIndex, next) {
return (dispatch) => {
Expand All @@ -152,11 +119,10 @@ export function nextLesson(currentIndex, next) {
}

/**
* Decrement the lesson index and load the previous lesson.
* Frontend disables option if out of bounds
* Frontend disables option if out of bounds
*
* @param {number} currentIndex current index of the course
* @param {object} prev Object of lesson to be load previous
* @param {*} currentIndex !!!DESCRIPTION NEEDED!!!
* @param {*} prev !!!DESCRIPTION NEEDED!!!
*/
export function previousLesson(currentIndex, prev) {
return (dispatch) => {
Expand All @@ -165,14 +131,18 @@ export function previousLesson(currentIndex, prev) {
};
}

/**
* Sends signal to the reducer to update the current index of the Course
*
* @param {number} newIndex New index to be set
* @returns {object} reducer action obj with type: SET_INDEX and payload: newIndex
*/
export function setCurrentIndex(newIndex) {
return { type: types.SET_INDEX, payload: newIndex };
return {
type: types.SET_INDEX,
payload: newIndex
};
}

export function loadLesson(lesson) {
return {
type: types.LOAD_LESSON,
payload: lesson
};
}

export default {
Expand Down
15 changes: 8 additions & 7 deletions src/actions/editorActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const sceneRef = "/apiv1/scenes";
* Sends a signal to the reducer to render the scene
*
* @param {string} text Text from the Ace Editor component
* @param {*} uid A JWT token to authenticate with the backend
*
*
* @returns reducer action obj with action type and text
*/
export function render(text, uid) {
Expand All @@ -20,7 +19,6 @@ export function render(text, uid) {
* Sends a signal to the reducer to refresh with the given text
*
* @param {string} text Text from the Ace Editor component
* @param {*} uid A JWT token to authenticate with the backend
*
* @returns reducer action obj with action type and text
*/
Expand All @@ -38,11 +36,8 @@ export function recover() {
}

/**
* This does an async fetch to backend to grab the scene, then
* This does an async fetch to Firebase to grab the scene, then
* dispatches the necessary functions to update the state.
*
* @param {string} id scene id
* @param {*} uid A JWT token to authenticate with the backend
*/
export function fetchScene(id, uid = "anon") {
return (dispatch) => { // Return a func that dispatches events after async
Expand Down Expand Up @@ -94,14 +89,20 @@ export function fetchScene(id, uid = "anon") {
*
* @returns reducer action obj with action type
*/

export function updateSavedText(savedText){
return {type: types.EDITOR_UPDATE_SAVEDTEXT, savedText};
}

export function addPassword(payload) {
return { type: types.ADD_PW, payload };
}

export default {
render,
refresh,
recover,
fetchScene,
addPassword,
updateSavedText,
};
36 changes: 3 additions & 33 deletions src/actions/projectActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import * as types from "../constants/ActionTypes";
const sceneRef = "/apiv1/scenes";
const previewRef = "/apiv1/preview/id";

/**
* Retrieved the list of user scenes
*
* @param {*} uid A JWT token to authenticate with the backend
*/
export function asyncUserProj(uid) {
export function asyncUserProj(id) {
// fetch user's project
return (dispatch) => {
if (uid) {
fetch(`${sceneRef}/`, {headers: {"x-access-token": uid}}).then((response) =>{
if (id) {
fetch(`${sceneRef}/`, {headers: {"x-access-token": id}}).then((response) =>{
if(response.status === 200){
response.json().then((json) =>{
json.forEach(element => {
Expand All @@ -26,21 +21,10 @@ export function asyncUserProj(uid) {
};
}


/**
* Sends signal to the reducer to sync the user project
*
* @param {*} payload list of user projects
*
* @returns reducer action obj with type: SYNC_USER_PROJ wiht payload
*/
export function syncUserProj(payload) {
return { type: types.SYNC_USER_PROJ, payload: payload };
}

/**
* Fetch a eample scenes from the backend
*/
export const asyncExampleProj = () => {
// fetch example projects
return (dispatch) => {
Expand All @@ -57,24 +41,10 @@ export const asyncExampleProj = () => {
};
};


/**
* Sends signal to the reducer to sync the example project
* @param {*} payload List of the example project
*
* @returns reducer action obj with type: SYNC_EXAMP_PROJ with payload
*/
export function syncExampleProj(payload) {
return { type: types.SYNC_EXAMP_PROJ, payload: payload };
}

/**
* Delete the specify user project
*
* @param {*} uid A JWT token to authenticate with the backend
* @param {string} id Scene id to be deleted
* @param {string} name Name of the scene
*/
export function deleteProj(uid, id, name) {
return (dispatch) => {
if (window.confirm(`Are you sure you want to delete ${name}?`)) {
Expand Down
Loading

0 comments on commit 8998b31

Please sign in to comment.