Skip to content

Commit

Permalink
Merge branch 'master' into improve-stories-load
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcicero45 committed Nov 7, 2023
2 parents 59827e3 + 97e423d commit 1ef7f27
Show file tree
Hide file tree
Showing 213 changed files with 5,950 additions and 4,831 deletions.
28 changes: 14 additions & 14 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
env:
jquery: true
extends:
- plugin:backbone/recommended
plugins:
- react
- backbone
parser: "babel-eslint"
rules:
eqeqeq: 1
backbone/initialize-on-top: 0
backbone/events-on-top: 0
backbone/no-silent: 0
strict: 0
{
"env": { "jquery": true },
"extends": ["plugin:backbone/recommended", "prettier"],
"plugins": ["react", "backbone", "prettier"],
"parser": "babel-eslint",
"rules": {
"eqeqeq": 1,
"backbone/initialize-on-top": 0,
"backbone/events-on-top": 0,
"backbone/no-silent": 0,
"strict": 0,
"prettier/prettier": "error"
}
}
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"arrowParens": "avoid",
"semi": true,
"singleQuote": true
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
2 changes: 1 addition & 1 deletion app/assets/javascripts/actions/actionTypes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import keyMirror from "keymirror";
import keyMirror from 'keymirror';

export default keyMirror({
REQUEST_PROJECT_BOARD: null,
Expand Down
17 changes: 8 additions & 9 deletions app/assets/javascripts/actions/labels.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import actionTypes from './actionTypes';

export const addLabelToProject = (label) => ({
export const addLabelToProject = label => ({
type: actionTypes.ADD_LABEL_TO_PROJECT,
label
label,
});

export const addLabelSuccess = (storyId, label) => ({
type: actionTypes.ADD_LABEL,
storyId,
label
label,
});

export const removeLabel = (storyId, labelName) => ({
type: actionTypes.DELETE_LABEL,
storyId,
labelName
labelName,
});

export const addLabel = (storyId, label) =>
(dispatch) => {
dispatch(addLabelSuccess(storyId, label));
dispatch(addLabelToProject(label));
}
export const addLabel = (storyId, label) => dispatch => {
dispatch(addLabelSuccess(storyId, label));
dispatch(addLabelToProject(label));
};
20 changes: 10 additions & 10 deletions app/assets/javascripts/actions/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,37 @@ import { setLoadingStory, storyFailure } from './story';
export const deleteNoteSuccess = (storyId, noteId) => ({
type: actionTypes.DELETE_NOTE,
storyId,
noteId
noteId,
});

export const createNoteSuccess = (storyId, note) => ({
type: actionTypes.ADD_NOTE,
storyId,
note
note,
});

export const deleteNote = (projectId, storyId, noteId) =>
export const deleteNote =
(projectId, storyId, noteId) =>
async (dispatch, getState, { Note }) => {
dispatch(setLoadingStory(storyId));

try {
await Note.destroy(projectId, storyId, noteId);
return dispatch(deleteNoteSuccess(storyId, noteId));
}
catch (error) {
} catch (error) {
return dispatch(storyFailure(storyId, error));
}
}
};

export const createNote = (projectId, storyId, note) =>
export const createNote =
(projectId, storyId, note) =>
async (dispatch, getState, { Note }) => {
dispatch(setLoadingStory(storyId));

try {
const newNote = await Note.post(projectId, storyId, note);
return dispatch(createNoteSuccess(storyId, newNote));
}
catch (error) {
} catch (error) {
return dispatch(storyFailure(storyId, error));
}
}
};
55 changes: 29 additions & 26 deletions app/assets/javascripts/actions/notifications.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
import actionTypes from './actionTypes';
import status from 'http-status';

export const addNotification = (notification) => ({
export const addNotification = notification => ({
type: actionTypes.ADD_NOTIFICATION,
notification
notification,
});

export const removeNotification = (id) => ({
export const removeNotification = id => ({
type: actionTypes.REMOVE_NOTIFICATION,
id
id,
});

export const sendSuccessNotification = (message) =>
export const sendSuccessNotification =
message =>
(dispatch, getState, { Notification }) => {
const newNotification = Notification.createNotification({
type: Notification.types.SUCCESS,
message
message,
});

dispatch(addNotification(newNotification));

setTimeout(() => {
dispatch(removeNotification(newNotification.id));
}, 4000);
}
};

export const sendErrorNotification = (error, { custom = false } = {}) => {
if (error.response) return sendServerErrorNotification(error);
if (custom) return sendCustomErrorNotification(error);
return sendDefaultErrorNotification();
}
};

export const sendCustomErrorNotification = code =>
export const sendCustomErrorNotification =
code =>
(dispatch, _, { Notification }) =>
dispatch(
addNotification(
Notification.createNotification({
type: Notification.types.ERROR,
message: I18n.t(code)
message: I18n.t(code),
})
)
);

const sendServerErrorNotification = (error) =>
const sendServerErrorNotification =
error =>
(dispatch, getState, { Notification }) => {
const type = Notification.types.ERROR;

Expand All @@ -56,7 +59,9 @@ const sendServerErrorNotification = (error) =>
addNotification(
Notification.createNotification({
type,
message: I18n.t('users.You are not authorized to perform this action')
message: I18n.t(
'users.You are not authorized to perform this action'
),
})
)
);
Expand All @@ -65,39 +70,37 @@ const sendServerErrorNotification = (error) =>
addNotification(
Notification.createNotification({
type,
message: I18n.t('not_found')
message: I18n.t('not_found'),
})
)
);
default:
return dispatch(
addDefaultErrorNotification(Notification)
);
return dispatch(addDefaultErrorNotification(Notification));
}
}
};

export const sendDefaultErrorNotification = () =>
export const sendDefaultErrorNotification =
() =>
(dispatch, getState, { Notification }) =>
dispatch(
addDefaultErrorNotification(Notification)
);
dispatch(addDefaultErrorNotification(Notification));

const addDefaultErrorNotification = Notification =>
addNotification(
Notification.createNotification({
type: Notification.types.ERROR,
message: I18n.t('messages.operations.error.default_error')
message: I18n.t('messages.operations.error.default_error'),
})
)
);

export const addValidationNotifications = (errors) =>
export const addValidationNotifications =
errors =>
(dispatch, getState, { Notification }) => {
const notifications = Object.keys(errors).map(error =>
Notification.createNotification({
type: Notification.types.ERROR,
message: `Error. ${error}: ${errors[error]}`
message: `Error. ${error}: ${errors[error]}`,
})
);

dispatch(addNotification(notifications));
}
};
15 changes: 8 additions & 7 deletions app/assets/javascripts/actions/pastIterations.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import actionTypes from './actionTypes';

export const receivePastIterations = (pastIterations) => ({
export const receivePastIterations = pastIterations => ({
type: actionTypes.RECEIVE_PAST_ITERATIONS,
data: pastIterations
data: pastIterations,
});

export const requestPastStories = iterationNumber => ({
type: actionTypes.REQUEST_PAST_STORIES,
iterationNumber
iterationNumber,
});

export const receivePastStories = (stories, iterationNumber, from) => ({
type: actionTypes.RECEIVE_PAST_STORIES,
iterationNumber,
stories,
from
from,
});

export const errorRequestPastStories = (error, iterationNumber) => ({
type: actionTypes.ERROR_REQUEST_PAST_STORIES,
iterationNumber,
error
});
error,
});

export const fetchPastStories = (iterationNumber, startDate, endDate) =>
export const fetchPastStories =
(iterationNumber, startDate, endDate) =>
async (dispatch, getState, { PastIteration }) => {
const { project } = getState();

Expand Down
Loading

0 comments on commit 1ef7f27

Please sign in to comment.