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

Refine request tabs visibility conditions #14347

Conversation

ncounter
Copy link
Contributor

@ncounter ncounter commented May 17, 2023

Request action tabs visibility are too generic. In case of a :delete action, the following conditions are missing:

  • changes tab should be visible only if the :delete action's target is a package. If it is a project no changes tab instead
  • mentioned issues tab should never be visible in case of a :delete action

This PR, based on #14346, refine the visibility conditions according to the above statements.

Reviewers

Do not consider the first three commits, they are included in #14346 instead. This PR is rebased on top of that one

@github-actions github-actions bot added the Frontend Things related to the OBS RoR app label May 17, 2023
@ncounter ncounter force-pushed the refine-request-tabs-visibility-conditions branch from 8158e08 to 3934053 Compare May 17, 2023 15:37
@ncounter ncounter force-pushed the refine-request-tabs-visibility-conditions branch from 3934053 to 116af26 Compare May 17, 2023 15:47
@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Merging #14347 (1f186d9) into master (bad2d69) will decrease coverage by 0.01%.
The diff coverage is 55.55%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14347      +/-   ##
==========================================
- Coverage   87.90%   87.90%   -0.01%     
==========================================
  Files         736      736              
  Lines       24753    24759       +6     
==========================================
+ Hits        21759    21764       +5     
- Misses       2994     2995       +1     

@@ -199,4 +199,18 @@ def next_prev_path(**opts)
request_show_path(parameters)
end
end

# Handle tabs visibility
def request_action_tab_visibility(action, tab_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of extracting the data from the action and then computing the logic, we should ask the action if I should render that tab or not. So ideally each bs request action class should have a method telling the view if it should render the tab or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point but, to be honest, I prefer to avoid view conditions in the model. It if was about a policy or specific property of the action itself I would agree 100%. In this case instead, the model is ignorant about how the elements are rendered and presented, it is just a view condition method that belongs to the view, and I just wrapped and centralized in a method to be more handy. If the webui page will change in the future (like no tabs, or anything different), the model should be loose from that change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay in avoiding view conditions in the model, but I think we can live with that in order to achieve better code structure. Also the view helpers are tightly coupled to the bs_request_action details right now, and I think that's worse

And the view knows too much: we're breaking the Tell, don't ask principle.

If you are not comfortable with that, then maybe we need a decorator, a class sitting between the model and the view that encapsulates the "view logic" (as we do with Finders).

@ncounter
Copy link
Contributor Author

ncounter commented Jun 7, 2023

Superseded by #14349

@ncounter ncounter closed this Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Things related to the OBS RoR app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants