|
| 1 | +/* |
| 2 | +Copyright 2023 The Vitess Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreedto in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package interactive |
| 18 | + |
| 19 | +import ( |
| 20 | + tea "github.com/charmbracelet/bubbletea" |
| 21 | + "vitess.io/vitess-releaser/go/releaser/pre_release" |
| 22 | +) |
| 23 | + |
| 24 | +type createMilestone string |
| 25 | + |
| 26 | +func createMilestoneMenuItem() menuItem { |
| 27 | + return menuItem{ |
| 28 | + name: "Create a new GitHub Milestone", |
| 29 | + act: createMilestoneAct, |
| 30 | + update: createMilestoneUpdate, |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +func createMilestoneUpdate(mi menuItem, msg tea.Msg) (menuItem, tea.Cmd) { |
| 35 | + milestoneLink, ok := msg.(createMilestone) |
| 36 | + if !ok { |
| 37 | + return mi, nil |
| 38 | + } |
| 39 | + |
| 40 | + mi.state = string(milestoneLink) |
| 41 | + return mi, nil |
| 42 | +} |
| 43 | + |
| 44 | +func createMilestoneAct(mi menuItem) (menuItem, tea.Cmd) { |
| 45 | + mi.state = "running..." |
| 46 | + pl, create := pre_release.NewMilestone() |
| 47 | + return mi, tea.Batch(func() tea.Msg { |
| 48 | + return createMilestone(create()) |
| 49 | + }, push(newProgressDialog("Creating new GitHub Milestone", pl))) |
| 50 | +} |
0 commit comments