Skip to content

Commit

Permalink
KAAV-1473 Added proptypes and cleaned scss comments
Browse files Browse the repository at this point in the history
  • Loading branch information
henrihaapalasiili committed Jun 10, 2024
1 parent 428b393 commit 5c1eb13
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/components/ProjectTimeline/AddGroupModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useDispatch } from 'react-redux';
import { EDIT_PROJECT_TIMETABLE_FORM } from '../../constants'
import { IconPlus,Button } from 'hds-react'
import { useTranslation } from 'react-i18next'
import PropTypes from 'prop-types'

const AddGroupModal = ({toggleOpenAddDialog,addDialogStyle,addDialogData,closeAddDialog, allowedToEdit, isAdmin}) => {
const {t} = useTranslation()
Expand Down Expand Up @@ -31,4 +32,13 @@ const AddGroupModal = ({toggleOpenAddDialog,addDialogStyle,addDialogData,closeAd
);
}

AddGroupModal.propTypes = {
toggleOpenAddDialog: PropTypes.func,
addDialogStyle: PropTypes.object,
addDialogData: PropTypes.object,
closeAddDialog: PropTypes.func,
allowedToEdit: PropTypes.bool,
isAdmin: PropTypes.bool
};

export default AddGroupModal;
16 changes: 16 additions & 0 deletions src/components/ProjectTimeline/TimelineModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EDIT_PROJECT_TIMETABLE_FORM } from '../../constants'
import FormField from '../input/FormField'
import { isArray } from 'lodash'
import { showField } from '../../utils/projectVisibilityUtils'
import PropTypes from 'prop-types'
import './VisTimeline.css'

const TimelineModal = ({ open,group,content,deadlinegroup,deadlines,openDialog,visValues,deadlineSections,formSubmitErrors,projectPhaseIndex,archived,allowedToEdit }) => {
Expand Down Expand Up @@ -150,5 +151,20 @@ const TimelineModal = ({ open,group,content,deadlinegroup,deadlines,openDialog,v
</Modal>
)
}

TimelineModal.propTypes = {
open: PropTypes.bool,
group: PropTypes.object,
content: PropTypes.string,
deadlinegroup: PropTypes.object,
deadlines: PropTypes.array,
openDialog: PropTypes.func,
visValues: PropTypes.object,
deadlineSections: PropTypes.array,
formSubmitErrors: PropTypes.object,
projectPhaseIndex: PropTypes.number,
archived: PropTypes.bool,
allowedToEdit: PropTypes.bool
};

export default TimelineModal
6 changes: 2 additions & 4 deletions src/components/ProjectTimeline/VisTimeline.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
width: 300px;
}
.vis-drag-left{
//Disabled for now because we don't want to allow dragging the timeline at this point
//pointer-events: auto;
/*TODO: v1.2 Disabled for now because we don't want to allow dragging the timeline at this point set to auto*/
pointer-events:none;
}
.vis-drag-right{
//Disabled for now because we don't want to allow dragging the timeline at this point
//pointer-events: auto;
/*TODO: v1.2 Disabled for now because we don't want to allow dragging the timeline at this point set to auto*/
pointer-events:none;
}
.vis-time-axis.vis-foreground{
Expand Down
13 changes: 13 additions & 0 deletions src/components/ProjectTimeline/VisTimelineGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'vis-timeline/dist/vis-timeline-graph2d.min.css'
import TimelineModal from './TimelineModal'
import VisTimelineMenu from './VisTimelineMenu'
import AddGroupModal from './AddGroupModal';
import PropTypes from 'prop-types';
import './VisTimeline.css'
Moment().locale('fi');

Expand Down Expand Up @@ -671,4 +672,16 @@ const VisTimelineGroup = forwardRef(({ groups, items, deadlines, visValues, dead
)
});
VisTimelineGroup.displayName = 'VisTimelineGroup';
VisTimelineGroup.propTypes = {
groups: PropTypes.array,
items: PropTypes.array,
deadlines: PropTypes.array,
visValues: PropTypes.object,
deadlineSections: PropTypes.array,
formSubmitErrors: PropTypes.object,
projectPhaseIndex: PropTypes.number,
archived: PropTypes.bool,
allowedToEdit: PropTypes.bool,
isAdmin: PropTypes.bool
};
export default VisTimelineGroup
9 changes: 9 additions & 0 deletions src/components/ProjectTimeline/VisTimelineMenu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react'
import {Button,IconAngleLeft,IconAngleRight} from 'hds-react'
import PropTypes from 'prop-types';

function VisTimelineMenu({goToToday, moveLeft, moveRight,showYers,showMonths}) {
const [selectedButton, setSelectedButton] = useState(null);
Expand Down Expand Up @@ -38,4 +39,12 @@ function VisTimelineMenu({goToToday, moveLeft, moveRight,showYers,showMonths}) {
)
}

VisTimelineMenu.propTypes = {
goToToday: PropTypes.func,
moveLeft: PropTypes.func,
moveRight: PropTypes.func,
showYers: PropTypes.func,
showMonths: PropTypes.func
};

export default VisTimelineMenu
14 changes: 12 additions & 2 deletions src/components/common/ConfirmModal.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Modal } from 'semantic-ui-react';
import { Button,IconInfoCircle } from 'hds-react';

function ConfirmCancelModal({ headerText, contentText, button1Text, button2Text, onContinue, onCancel }) {
function ConfirmModal({ headerText, contentText, button1Text, button2Text, onContinue, onCancel }) {
return (
<Modal open={true} className="timetable-confirm-modal">
<Modal.Header><IconInfoCircle className='header-icon' size="s" aria-hidden="true"/>{headerText}</Modal.Header>
Expand All @@ -17,4 +18,13 @@ function ConfirmCancelModal({ headerText, contentText, button1Text, button2Text,
);
}

export default ConfirmCancelModal;
ConfirmModal.propTypes = {
headerText: PropTypes.string,
contentText: PropTypes.string,
button1Text: PropTypes.string,
button2Text: PropTypes.string,
onContinue: PropTypes.func,
onCancel: PropTypes.func
};

export default ConfirmModal;
20 changes: 20 additions & 0 deletions src/components/input/CustomCheckbox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react'
import PropTypes from 'prop-types';
import { getFormValues } from 'redux-form'
import { EDIT_PROJECT_TIMETABLE_FORM } from '../../constants'
import { getFieldAutofillValue } from '../../utils/projectAutofillUtils'
Expand Down Expand Up @@ -108,4 +109,23 @@ const CustomCheckbox = ({
}
}

CustomCheckbox.propTypes = {
input: PropTypes.shape({
name: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
onChange: PropTypes.func,
}),
meta: PropTypes.shape({
error: PropTypes.string,
}),
autofillRule: PropTypes.string,
label: PropTypes.string,
className: PropTypes.string,
disabled: PropTypes.bool,
updated: PropTypes.bool,
formName: PropTypes.string,
display: PropTypes.string,
isProjectTimetableEdit: PropTypes.bool
};

export default CustomCheckbox
5 changes: 5 additions & 0 deletions src/components/input/DeadlineInfoText.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ const DeadlineInfoText = props => {
DeadlineInfoText.propTypes = {
fieldData:PropTypes.object,
meta: PropTypes.object,
input: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
])
}

export default DeadlineInfoText
9 changes: 9 additions & 0 deletions src/components/input/DeadlineInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ const DeadLineInput = ({

DeadLineInput.propTypes = {
input: PropTypes.object.isRequired,
error: PropTypes.string,
attributeData: PropTypes.object,
currentDeadline: PropTypes.object,
editable: PropTypes.bool,
type: PropTypes.string,
disabled: PropTypes.bool,
placeholder: PropTypes.string,
className: PropTypes.string,
autofillRule: PropTypes.string,
timeTableDisabled: PropTypes.bool
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/project/EditProjectTimetableModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Button,IconInfoCircle } from 'hds-react'
import { isEqual } from 'lodash'
import VisTimelineGroup from '../../ProjectTimeline/VisTimelineGroup'
import * as visdata from 'vis-data'
import ConfirmCancelModal from '../../common/ConfirmModal';
import ConfirmModal from '../../common/ConfirmModal';

class EditProjectTimeTableModal extends Component {
constructor(props) {
Expand Down Expand Up @@ -579,7 +579,7 @@ class EditProjectTimeTableModal extends Component {
toggleTimelineModal={this.state.toggleTimelineModal}
/>
{this.state.showModal &&
<ConfirmCancelModal
<ConfirmModal
headerText={"Haluatko peruuttaa tekemäsi muutokset?"}
contentText={"Olet muuttanut aikataulun tietoja. Mikäli jatkat, tekemäsi muutokset peruutetaan. Haluatko jatkaa?"}
button1Text={"Jatka"}
Expand Down Expand Up @@ -629,6 +629,10 @@ EditProjectTimeTableModal.propTypes = {
allowedToEdit: PropTypes.bool,
attributeData: PropTypes.object,
isAdmin: PropTypes.bool,
formSubmitErrors: PropTypes.object,
deadlineSections: PropTypes.array,
formValues: PropTypes.object,
deadlines: PropTypes.array
}

const mapStateToProps = state => ({
Expand Down
1 change: 0 additions & 1 deletion src/components/projectEdit/ProjectEdit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@
margin-top: 20px;
margin-left: 0px !important;
margin-right: 20px !important;
//max-height: 700px !important;
overflow: auto !important;
.date-content{
display: flex;
Expand Down

0 comments on commit 5c1eb13

Please sign in to comment.