-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathblock_plan.go
More file actions
55 lines (46 loc) · 1.37 KB
/
block_plan.go
File metadata and controls
55 lines (46 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package slack
// PlanBlock defines a block of type plan used by AI agents
// to group multiple task cards under a shared title.
//
// More Information: https://docs.slack.dev/reference/block-kit/blocks/plan-block/
type PlanBlock struct {
Type MessageBlockType `json:"type"`
BlockID string `json:"block_id,omitempty"`
Title string `json:"title"`
Tasks []TaskCardBlock `json:"tasks,omitempty"`
}
// BlockType returns the type of the block
func (s PlanBlock) BlockType() MessageBlockType {
return s.Type
}
// ID returns the ID of the block
func (s PlanBlock) ID() string {
return s.BlockID
}
// PlanBlockOption allows configuration of options for a new plan block
type PlanBlockOption func(*PlanBlock)
// PlanBlockOptionBlockID sets the block ID for the plan block
func PlanBlockOptionBlockID(blockID string) PlanBlockOption {
return func(block *PlanBlock) {
block.BlockID = blockID
}
}
// NewPlanBlock returns a new instance of a plan block
func NewPlanBlock(title string, options ...PlanBlockOption) *PlanBlock {
block := PlanBlock{
Type: MBTPlan,
Title: title,
}
for _, option := range options {
option(&block)
}
return &block
}
// WithTasks sets the tasks for the PlanBlock
func (s *PlanBlock) WithTasks(tasks ...*TaskCardBlock) *PlanBlock {
s.Tasks = make([]TaskCardBlock, len(tasks))
for i, t := range tasks {
s.Tasks[i] = *t
}
return s
}