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

XiaoW Add tooltip to new timer and cleanup old timer #1455

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/__tests__/ForcePasswordUpdate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ describe('When user tries to input data', () => {
});

const url = ENDPOINTS.FORCE_PASSWORD;
const timerUrl = ENDPOINTS.TIMER(mockState.auth.user.userid);
const userProjectsUrl = ENDPOINTS.USER_PROJECTS(mockState.auth.user.userid);
let passwordUpdated = false;
//When user is sent to forced Password Update they are not
Expand Down Expand Up @@ -158,9 +157,6 @@ const server = setupServer(
]),
);
}),
rest.get(timerUrl, (req, res, ctx) => {
return res(ctx.status(200), ctx.json({}));
}),
//Any other requests error out
rest.get('*', (req, res, ctx) => {
console.error(
Expand Down
4 changes: 0 additions & 4 deletions src/__tests__/Leaderboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { ENDPOINTS , ApiEndpoint } from '../utils/URL';
import { render, fireEvent, waitFor, screen } from '@testing-library/react';
import routes from './../routes';
const url = ENDPOINTS.LEADER_BOARD(mockState.auth.user.userid);
const timerUrl = ENDPOINTS.TIMER(mockState.auth.user.userid);
const userProjectsUrl = ENDPOINTS.USER_PROJECTS(mockState.auth.user.userid);
let requestedLeaderBoard = false;
let refreshed = false;
Expand Down Expand Up @@ -76,9 +75,6 @@ const server = setupServer(
rest.get(userProjectsUrl, (req, res, ctx) => {
return res(ctx.status(200), ctx.json([]));
}),
rest.get(timerUrl, (req, res, ctx) => {
return res(ctx.status(200), ctx.json({}));
}),
rest.get('*', (req, res, ctx) => {
console.error(
`Please add request handler for ${req.url.toString()} in your MSW server requests.`,
Expand Down
2 changes: 0 additions & 2 deletions src/__tests__/LoginPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { clearErrors } from '../actions/errorsActions';
import { loginUser } from '../actions/authActions';

const url = ENDPOINTS.LOGIN;
const timerUrl = ENDPOINTS.TIMER(mockState.auth.user.userid);
const userProjectsUrl = ENDPOINTS.USER_PROJECTS(mockState.auth.user.userid);

const server = setupServer(
Expand Down Expand Up @@ -66,7 +65,6 @@ const server = setupServer(
),
),
rest.get(userProjectsUrl, (req, res, ctx) => res(ctx.status(200), ctx.json([]))),
rest.get(timerUrl, (req, res, ctx) => res(ctx.status(200), ctx.json({}))),
rest.get('*', (req, res, ctx) => {
console.error(
`Please add request handler for ${req.url.toString()} in your MSW server requests.`,
Expand Down
4 changes: 0 additions & 4 deletions src/__tests__/Logout.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import mockState from './mockAdminState.js';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { ApiEndpoint, ENDPOINTS } from '../utils/URL';
const timerUrl = ENDPOINTS.TIMER(mockState.auth.user.userid);
const userProjectsUrl = ENDPOINTS.USER_PROJECTS(mockState.auth.user.userid);

window.confirm = jest.fn(() => true);
Expand Down Expand Up @@ -50,9 +49,6 @@ const server = setupServer(
]),
);
}),
rest.get(timerUrl, (req, res, ctx) => {
return res(ctx.status(200), ctx.json({}));
}),
rest.get('http://*/hash.txt', (req, res, ctx) => {
return res(ctx.status(200), ctx.json({}));
}),
Expand Down
4 changes: 0 additions & 4 deletions src/__tests__/Projects/Projects.WBS.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import routes from '../../routes';
const projectWBSUrl = ENDPOINTS.WBS('5ad91ec3590b19002asacd26');
const userProfileUrl = ENDPOINTS.USER_PROFILE(mockState.auth.user.userid);
const leaderboardUrl = ENDPOINTS.LEADER_BOARD(mockState.auth.user.userid);
const timerUrl = ENDPOINTS.TIMER(mockState.auth.user.userid);
const userProjectsUrl = ENDPOINTS.USER_PROJECTS(mockState.auth.user.userid);
let deleteWbsCalled = false;
let addedWBSCalled = false;
Expand Down Expand Up @@ -80,9 +79,6 @@ const server = setupServer(
]),
);
}),
rest.get(timerUrl, (req, res, ctx) => {
return res(ctx.status(200), ctx.json({}));
}),
rest.get('*', (req, res, ctx) => {
console.error(
`Please add request handler for ${req.url.toString()} in your MSW server requests.`,
Expand Down
84 changes: 0 additions & 84 deletions src/actions/timer.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/BMDashboard/BMHeader/BMHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect } from 'react';
// import { getUserProfile } from '../../actions/userProfile'
import { getHeaderData } from '../../../actions/authActions';
import { getTimerData } from '../../../actions/timer';
import { getAllRoles } from '../../../actions/role';
import { Link } from 'react-router-dom';
import { connect, useDispatch } from 'react-redux';
Expand Down Expand Up @@ -90,7 +89,6 @@ export const Header = props => {
useEffect(() => {
if (props.auth.isAuthenticated) {
props.getHeaderData(props.auth.user.userid);
props.getTimerData(props.auth.user.userid);
if (props.auth.user.role === 'Administrator') {
dispatch(fetchTaskEditSuggestions());
}
Expand Down Expand Up @@ -321,7 +319,6 @@ const mapStateToProps = state => ({
});
export default connect(mapStateToProps, {
getHeaderData,
getTimerData,
getAllRoles,
hasPermission,
})(Header);
7 changes: 1 addition & 6 deletions src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React, { useState, useEffect } from 'react';
// import { getUserProfile } from '../../actions/userProfile'
import { getHeaderData } from '../../actions/authActions';
import { getTimerData } from '../../actions/timer';
import { getAllRoles } from '../../actions/role';
import { Link } from 'react-router-dom';
import { connect, useDispatch } from 'react-redux';
import Timer from '../Timer/NewTimer';
// import OldTimer from '../Timer/Timer';
import Timer from '../Timer/Timer';
import OwnerMessage from '../OwnerMessage/OwnerMessage';
import {
LOGO,
Expand Down Expand Up @@ -79,7 +77,6 @@ export const Header = props => {
useEffect(() => {
if (props.auth.isAuthenticated) {
props.getHeaderData(props.auth.user.userid);
props.getTimerData(props.auth.user.userid);
if (props.auth.user.role === 'Administrator') {
dispatch(fetchTaskEditSuggestions());
}
Expand Down Expand Up @@ -110,7 +107,6 @@ export const Header = props => {
style={user.role == 'Owner' ? { marginRight: '6rem' } : { marginRight: '10rem' }}
>
{isAuthenticated && <Timer />}
{/* {isAuthenticated && <OldTimer />} */}
{isAuthenticated && (
<div className="owner-message">
<OwnerMessage />
Expand Down Expand Up @@ -270,7 +266,6 @@ const mapStateToProps = state => ({
});
export default connect(mapStateToProps, {
getHeaderData,
getTimerData,
getAllRoles,
hasPermission,
})(Header);
43 changes: 14 additions & 29 deletions src/components/Timelog/TimeEntryForm/TimeEntryForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { getUserProjects } from '../../../actions/userProjects';
import { getUserProfile } from 'actions/userProfile';
import { updateUserProfile } from 'actions/userProfile';

import { stopTimer } from '../../../actions/timer';
import AboutModal from './AboutModal';
import TangibleInfoModal from './TangibleInfoModal';
import ReminderModal from './ReminderModal';
Expand All @@ -45,14 +44,13 @@ import { boxStyle } from 'styles';
* @param {*} props.timer
* @param {boolean} props.data.isTangible
* @param {*} props.userProfile
* @param {function} props.resetTimer
* @param {string} props.LoggedInuserId
* @param {string} props.curruserId
* @returns
*/
const TimeEntryForm = props => {

const { userId, edit, data, isOpen, toggle, timer, LoggedInuserId, curruserId, resetTimer = () => {}, sendClear = () => {}, sendStop = () => {} } = props;
const { userId, edit, data, isOpen, toggle, timer, LoggedInuserId, curruserId, sendStop } = props;
const canEditTimeEntry = props.hasPermission('editTimeEntry');
const canPutUserProfileImportantInfo = props.hasPermission('putUserProfileImportantInfo');

Expand Down Expand Up @@ -504,30 +502,6 @@ const TimeEntryForm = props => {
}
}

//Clear the form and clean up.
if (fromTimer) {
const timerStatus = await dispatch(stopTimer(userId));
if (timerStatus === 200 || timerStatus === 201) {
resetTimer();
} else {
alert(
'Your time entry was successfully recorded, but an error occurred while asking the server to reset your timer. There is no need to submit your hours a second time, and doing so will result in a duplicate time entry.',
);
}
sendClear();
} else if (!reminder.notice) {
setReminder(reminder => ({
...reminder,
editNotice: !reminder.editNotice,
}));
}

if (fromTimer) {
sendStop();
clearForm();
}
setReminder(initialReminder);

if (!props.edit) setInputs(initialFormValues);

await getUserProfile(userId)(dispatch);
Expand All @@ -538,6 +512,19 @@ const TimeEntryForm = props => {

await dispatch(getUserProfile(curruserId));
await dispatch(getTimeEntriesForWeek(curruserId, 0));

//Clear the form and clean up.
if (fromTimer) {
sendStop();
clearForm();
} else if (!reminder.notice) {
setReminder(reminder => ({
...reminder,
editNotice: !reminder.editNotice,
}));
}

setReminder(initialReminder);
if (isOpen) toggle();
};

Expand Down Expand Up @@ -810,8 +797,6 @@ TimeEntryForm.propTypes = {
isOpen: PropTypes.bool.isRequired,
timer: PropTypes.any,
data: PropTypes.any.isRequired,
userProfile: PropTypes.any.isRequired,
resetTimer: PropTypes.func,
LoggedInuserId: PropTypes.string,
curruserId: PropTypes.string,
handleStop: PropTypes.func,
Expand Down
Loading
Loading