Skip to content

Commit

Permalink
Added ability to preview modal with slack block kit builder
Browse files Browse the repository at this point in the history
  • Loading branch information
Jnesselr committed Dec 29, 2024
1 parent 98ce2da commit 1d71320
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/External/Slack/Modals/ModalTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Http\Requests\SlackRequest;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
use SlackPhp\BlockKit\Previewer;
use SlackPhp\BlockKit\Surfaces\Modal;

trait ModalTrait
Expand All @@ -19,6 +20,19 @@ public function jsonSerialize(): array
return $this->modalView->jsonSerialize();
}

/**
* This is for debugging so you can see what your modal looks like in the Slack block kit builder.
*
* @return string Block kit url string
*/
public function preview(): string
{
// We have to validate it here again, but most places validate it directly through jsonSerialize.
$this->modalView->validate();

return Previewer::new()->preview($this->modalView);
}

public function push(): JsonResponse
{
return response()->json([
Expand Down

0 comments on commit 1d71320

Please sign in to comment.