Skip to content

Commit

Permalink
Merge pull request #373 from revelrylabs/confirmation_modal
Browse files Browse the repository at this point in the history
Feat: Confirmation Modals for Enable and Disable
  • Loading branch information
bford002 authored Dec 15, 2023
2 parents 1d49d51 + 00b338e commit 6682e64
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 5 deletions.
96 changes: 94 additions & 2 deletions lib/slax_web/websockets/disable.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ defmodule SlaxWeb.Disable do
disabled: true
})

:ok
build_disable_confirmation_view(name)
end
end

Expand All @@ -78,7 +78,7 @@ defmodule SlaxWeb.Disable do
disabled: false
})

:ok
build_enable_confirmation_view(name)
end

defp parse_state_values([
Expand Down Expand Up @@ -221,4 +221,96 @@ defmodule SlaxWeb.Disable do
]
}
end

defp build_disable_confirmation_view(name) do
%{
type: "modal",
callback_id: "disable_view",
title: %{
type: "plain_text",
text: "Confirmation",
emoji: true
},
close: %{
type: "plain_text",
text: "Close",
emoji: true
},
blocks: [
%{
type: "rich_text",
elements: [
%{
type: "rich_text_section",
elements: [
%{
type: "text",
text: "Slax has been disabled in "
},
%{
type: "text",
text: "#{name} ",
style: %{
bold: true
}
},
%{
type: "emoji",
name: "homer"
}
]
}
]
}
]
}
end

defp build_enable_confirmation_view(name) do
%{
type: "modal",
callback_id: "enable_view",
title: %{
type: "plain_text",
text: "Confirmation",
emoji: true
},
close: %{
type: "plain_text",
text: "Close",
emoji: true
},
blocks: [
%{
type: "rich_text",
elements: [
%{
type: "rich_text_section",
elements: [
%{
type: "text",
text: "Slax has been enabled in "
},
%{
type: "text",
text: "#{name}",
style: %{
bold: true
}
},
%{
type: "text",
text: "! "
},
%{
type: "emoji",
name: "reversehomer"
}
]
}
]
}
]
}
end
end
5 changes: 2 additions & 3 deletions test/slax_web/websockets/disable_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ defmodule SlaxWeb.Disable.Test do
[channel_id: channel_id, values: values]
end

test "creates or updates a channel to be enabled", %{channel_id: channel_id, values: values} do
test "updates a channel to be enabled", %{channel_id: channel_id, values: values} do
event = %{
"trigger_id" => "trigger_id",
"type" => "view_submission",
"view" => %{
"callback_id" => "enable_view",
Expand All @@ -34,7 +33,7 @@ defmodule SlaxWeb.Disable.Test do
}
}

assert :ok == Disable.handle_payload(event)
assert %{title: %{text: "Confirmation"}} = Disable.handle_payload(event)
assert Channels.get_by_channel_id(channel_id).disabled == false
end
end

0 comments on commit 6682e64

Please sign in to comment.