-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f0dc2c
commit 501c034
Showing
5 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,45 @@ | ||
package keys | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/algorandfoundation/hack-tui/api" | ||
"github.com/algorandfoundation/hack-tui/ui/pages" | ||
"github.com/charmbracelet/bubbles/spinner" | ||
"github.com/charmbracelet/lipgloss" | ||
) | ||
|
||
func (m ViewModel) View() string { | ||
return lipgloss.JoinVertical(lipgloss.Center, pages.Padding1(m.table.View()), m.controls.View()) | ||
if m.SelectedKeyToDelete != nil { | ||
return lipgloss.JoinVertical( | ||
lipgloss.Center, | ||
renderDeleteConfirmationModal(m.SelectedKeyToDelete, m.DeleteLoading), | ||
m.controls.View(), | ||
) | ||
} | ||
return lipgloss.JoinVertical( | ||
lipgloss.Center, | ||
pages.Padding1(m.table.View()), | ||
m.controls.View(), | ||
) | ||
} | ||
|
||
func renderDeleteConfirmationModal(partKey *api.ParticipationKey, deleteLoading bool) string { | ||
modalStyle := lipgloss.NewStyle(). | ||
Width(60). | ||
Height(7). | ||
Align(lipgloss.Center). | ||
Border(lipgloss.RoundedBorder()). | ||
Padding(1, 2) | ||
|
||
var modalContent string | ||
if deleteLoading { | ||
s := spinner.New() | ||
s.Spinner = spinner.Dot | ||
modalContent = fmt.Sprintf("Deleting key...\n%s", s.View()) | ||
} else { | ||
modalContent = fmt.Sprintf("Are you sure you want to delete this key from your node?\nParticipation Key: %v\nAccount Address: %v\nPress either y (yes) or n (no).", partKey.Id, partKey.Address) | ||
} | ||
|
||
return modalStyle.Render(modalContent) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters