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

Release 2024.12.5 #727

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions app/components/snippets/box_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<div id="<%= @snippet.id %>"
class="w-full p-4 flex flex-col self-center gap-y-4 bg-aoc-gray-darkest border border-aoc-gray-dark group"
data-controller="show-more">
data-controller="confirm show-more"
data-confirm-message-value="<%= @discuss_confirm_message %>">

<div class="flex items-center justify-between text-xs">
<div class="flex gap-x-3">
Expand All @@ -12,7 +13,7 @@
</div>

<% if @user_can_discuss_snippet %>
<%= button_to discuss_snippet_path(@snippet), method: :patch, form: { target: "_blank" } do %>
<%= button_to discuss_snippet_path(@snippet), method: :patch, data: { action: "confirm#handleSubmit" } do %>
<span class="link-explicit link-slack">discuss on Slack</span>
<% end %>
<% end %>
Expand Down
4 changes: 3 additions & 1 deletion app/components/snippets/box_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ def initialize(snippet:, user:)
@snippet = snippet

@user_can_edit_snippet = @snippet.user == @user
@user_can_discuss_snippet = @snippet.user != @user && @snippet.user.slack_linked?
@user_can_discuss_snippet = @snippet.user != @user && @snippet.user.slack_linked? && @user.slack_linked?
@user_reaction_vote_value = @snippet.reactions.find { _1.user_id == @user.id }

@discuss_confirm_message = "By clicking this button, you will create a new Slack thread on #aoc and notify the author of the solution. Do you want to proceed?" if @snippet.slack_url.nil?
end
end
end
18 changes: 18 additions & 0 deletions app/javascript/controllers/confirm_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
static values = {
message: String,
}

handleSubmit(event) {
event.preventDefault()
if (this.messageValue && !confirm(this.messageValue)) { return }

const newTab = window.open("", "_blank")
const form = event.currentTarget.parentElement.cloneNode(true)
form.style.display = "none"
newTab.document.body.appendChild(form)
form.submit()
}
}
Loading