Skip to content

Commit

Permalink
fix rubocop and eslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcicero45 committed Nov 7, 2023
1 parent 1ef7f27 commit f2f452b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 26 deletions.
32 changes: 20 additions & 12 deletions app/assets/javascripts/actions/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,26 @@ export const updateCollapsedStory =
);
};

export const expandOrCollapseStory = (currentStory, from) => async (dispatch, _, { Story }) => {
if (!currentStory.collapsed) return dispatch(toggleStory(currentStory.id, from));

dispatch(setLoadingStory(currentStory.id, from));
try {
const { data } = await projectStoriesService.fetchStory(currentStory);
dispatch(updateStorySuccess({ ...Story.deserialize(data.story), ...currentStory }, from));
dispatch(toggleStory(currentStory.id, from));
} catch (error) {
dispatch(sendErrorNotification(error));
}
};
export const expandOrCollapseStory =
(currentStory, from) =>
async (dispatch, _, { Story }) => {
if (!currentStory.collapsed)
return dispatch(toggleStory(currentStory.id, from));

dispatch(setLoadingStory(currentStory.id, from));
try {
const { data } = await projectStoriesService.fetchStory(currentStory);
dispatch(
updateStorySuccess(
{ ...Story.deserialize(data.story), ...currentStory },
from
)
);
dispatch(toggleStory(currentStory.id, from));
} catch (error) {
dispatch(sendErrorNotification(error));
}
};

export const dragDropStory =
(storyId, projectId, newAttributes, from) =>
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/services/stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import httpService from "./httpService";
import httpService from './httpService';

class ProjectStoriesService {
async fetchStory(story) {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/beta/project_boards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def show
project_id: params[:id],
current_user: current_user,
current_flow: cookies[:current_flow],
projects_scope: policy_scope(Project),
projects_scope: policy_scope(Project)
)

@project = result.success.project
Expand Down
30 changes: 20 additions & 10 deletions app/operations/beta/project_board_operations/read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create_project_board
current_user: current_user,
current_flow: current_flow,
default_flow: default_flow,
labels: project_labels,
labels: project_labels
)

project_board = ::ProjectBoard.new(project_board_params)
Expand All @@ -54,8 +54,8 @@ def stories_and_past_iterations
yield project_iterations

yield Success(
stories: @active_stories,
past_iterations: past_iterations,
stories: @active_stories,
past_iterations: past_iterations
)
end

Expand All @@ -64,25 +64,35 @@ def active_stories
project
.stories
.where("state != 'accepted' OR accepted_at >= ?", current_iteration_start)
.select(:id, :title, :description, :estimate, :story_type, :state, :requested_by_name, :owned_by_initials, :project_id)
.order("updated_at DESC")
.select(
:id,
:title,
:description,
:estimate,
:story_type,
:state,
:requested_by_name,
:owned_by_initials,
:project_id
)
.order('updated_at DESC')
end

Success(@active_stories)
end

def project_labels
possibly_duplicated_labels = project.stories.map(&:labels).reject(&:blank?)
uniq_labels = possibly_duplicated_labels.join(",").split(",").uniq.join(",")
uniq_labels = possibly_duplicated_labels.join(',').split(',').uniq.join(',')
uniq_labels
end

def project
@project ||= current_user
.projects
.friendly
.preload(:users)
.find(project_id)
.projects
.friendly
.preload(:users)
.find(project_id)
end

def default_flow
Expand Down
4 changes: 2 additions & 2 deletions app/operations/story_operations/read_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def call

Success(
active_stories: @active_stories,
past_iterations: past_iterations,
past_iterations: past_iterations
)
end

Expand All @@ -36,7 +36,7 @@ def active_stories
.stories
.with_dependencies
.where("state != 'accepted' OR accepted_at >= ?", current_iteration_start)
.order("updated_at DESC")
.order('updated_at DESC')
end

Success(@active_stories)
Expand Down

0 comments on commit f2f452b

Please sign in to comment.