modals

package
v0.0.0-...-3e092da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// BlockIdTitle is the block identifier to use for inputs
	// that should be used as the title of a Jira issue
	BlockIdTitle = "title"
)

Variables

This section is empty.

Functions

func BulletListFunc

func BulletListFunc() template.FuncMap

BulletListFunc exposes a function to turn lines into a bullet list

func ErrorView

func ErrorView(action string, err error) slack.ModalViewRequest

ErrorView is a modal View to show the user an error

func JiraView

func JiraView(key string) slack.ModalViewRequest

JiraView is a modal View to show the user the Jira issue we just created for them

func PendingJiraView

func PendingJiraView() *slack.ModalViewRequest

PendingJiraView is a placeholder modal View for the user to know we are working on publishing a Jira issue

func ToJiraIssue

func ToJiraIssue(parameters JiraIssueParameters, filer jira.IssueFiler, updater ViewUpdater) interactions.Handler

ToJiraIssue responds to the user with a confirmation screen and files a Jira issue behind the scenes, updating the View once the operation has finished. We need this asynchronous response mechanism as the API calls needed to file the issue often take longer than the 3sec TTL on responding to the interaction payload we have.

func UpdateViewForButtonPress

func UpdateViewForButtonPress(identifier, buttonId string, updater ViewUpdater, view slack.ModalViewRequest) interactions.PartialHandler

UpdateViewForButtonPress updates the given View if the interaction being handled was the identified button being pushed

Types

type FakeViewUpdater

type FakeViewUpdater struct {
	// contains filtered or unexported fields
}

FakeViewUpdater is a ViewUpdater with injectable behavior

func NewFake

func NewFake(calls []ViewUpdate) *FakeViewUpdater

NewFake creates a new fake updater with the injected behavior

func (*FakeViewUpdater) Called

func (f *FakeViewUpdater) Called() context.Context

Called allows a consumer to know we have been called

func (*FakeViewUpdater) UpdateView

func (f *FakeViewUpdater) UpdateView(view slack.ModalViewRequest, externalID, hash, viewID string) (*slack.ViewResponse, error)

func (*FakeViewUpdater) Validate

func (f *FakeViewUpdater) Validate(t *testing.T)

Validate ensures that all expected client calls happened

type FlowWithView

type FlowWithView struct {
	// Identifier is how we identify callbacks for this modal
	Identifier Identifier
	// View is the modal we create for a user
	View slack.ModalViewRequest
}

FlowWithView holds the data for the first step in registration

func ForView

func ForView(id Identifier, view slack.ModalViewRequest) *FlowWithView

ForView begins a registration process for a modal View

func (*FlowWithView) WithFollowUps

WithFollowUps adds follow-up handlers for a modal View

type FlowWithViewAndFollowUps

type FlowWithViewAndFollowUps struct {
	*FlowWithView
	// FollowUps are what we do when the user interacts
	// with and submits this modal
	FollowUps map[slack.InteractionType]interactions.Handler
}

FlowWithViewAndFollowUps holds the data for the second step in registration

type Identifier

type Identifier string

Identifier identifies a modal View, either in an interaction callback identifier from Slack or in private metadata on the View as set by this bot when we publish the View. We need this mechanism as there's no other way to associate interaction payloads for a modal with the code that created the modal in the first place

const (
	IdentifierJira        Identifier = "jira"
	IdentifierJiraPending Identifier = "jira_pending"
	IdentifierError       Identifier = "error"
)

type JiraIssueParameters

type JiraIssueParameters struct {
	Id        Identifier
	IssueType string
	Template  *template.Template
	Fields    []string
}

JiraIssueParameters holds the metadata used to create a Jira issue

func (*JiraIssueParameters) Process

func (p *JiraIssueParameters) Process(callback *slack.InteractionCallback) (string, string, error)

Process processes the interaction callback data to render the Jira issue title and body

type ViewUpdate

type ViewUpdate struct {
	ViewUpdateRequest
	ViewUpdateResponse
}

ViewUpdate is a tuple holding a view update request and response

type ViewUpdateRequest

type ViewUpdateRequest struct {
	View                     slack.ModalViewRequest
	ExternalID, Hash, ViewID string
}

ViewUpdateRequest describes a client call to update a view

type ViewUpdateResponse

type ViewUpdateResponse struct {
	Response *slack.ViewResponse
	Error    error
}

ViewUpdateResponse describes the response to the client call

type ViewUpdater

type ViewUpdater interface {
	UpdateView(view slack.ModalViewRequest, externalID, hash, viewID string) (*slack.ViewResponse, error)
}

ViewUpdater is a subset of the Slack client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL