github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/client/teams_ui.go (about)

     1  package client
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"golang.org/x/net/context"
     8  
     9  	"github.com/keybase/client/go/libkb"
    10  	"github.com/keybase/client/go/protocol/keybase1"
    11  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
    12  )
    13  
    14  type TeamsUI struct {
    15  	libkb.Contextified
    16  }
    17  
    18  func NewTeamsUIProtocol(g *libkb.GlobalContext) rpc.Protocol {
    19  	ui := &TeamsUI{
    20  		Contextified: libkb.NewContextified(g),
    21  	}
    22  	return keybase1.TeamsUiProtocol(ui)
    23  }
    24  
    25  func (t *TeamsUI) ConfirmRootTeamDelete(ctx context.Context, arg keybase1.ConfirmRootTeamDeleteArg) (bool, error) {
    26  	term := t.G().UI.GetTerminalUI()
    27  	term.Printf("WARNING: This will:\n\n")
    28  	term.Printf("(1) destroy all data in %s's chats, KBFS folders, and git repositories.\n", arg.TeamName)
    29  	term.Printf("(2) prevent %q from being used again as a team name.\n\n", arg.TeamName)
    30  	confirm := fmt.Sprintf("nuke %s", arg.TeamName)
    31  	response, err := term.Prompt(PromptDescriptorDeleteRootTeam,
    32  		fmt.Sprintf("** if you are sure, please type: %q > ", confirm))
    33  	if err != nil {
    34  		return false, err
    35  	}
    36  	return strings.TrimSpace(response) == confirm, nil
    37  }
    38  
    39  func (t *TeamsUI) ConfirmSubteamDelete(ctx context.Context, arg keybase1.ConfirmSubteamDeleteArg) (bool, error) {
    40  	term := t.G().UI.GetTerminalUI()
    41  	term.Printf("WARNING: This will destroy all data in %s's chats, KBFS folders, and git repositories.\n\n", arg.TeamName)
    42  	confirm := fmt.Sprintf("nuke %s", arg.TeamName)
    43  	response, err := term.Prompt(PromptDescriptorDeleteSubteam,
    44  		fmt.Sprintf("** if you are sure, please type: %q > ", confirm))
    45  	if err != nil {
    46  		return false, err
    47  	}
    48  	return strings.TrimSpace(response) == confirm, nil
    49  }
    50  
    51  func (t *TeamsUI) ConfirmInviteLinkAccept(ctx context.Context, arg keybase1.ConfirmInviteLinkAcceptArg) (bool, error) {
    52  	term := t.G().UI.GetTerminalUI()
    53  
    54  	term.Printf("%v invited to join team %v (%v members).\n", arg.Details.InviterUsername, arg.Details.TeamName, arg.Details.TeamNumMembers)
    55  	if len(arg.Details.TeamDesc) > 0 {
    56  		term.Printf("team description: %v\n", arg.Details.TeamDesc)
    57  	}
    58  	if arg.Details.InviterResetOrDel {
    59  		_, _ = term.PrintfUnescaped(ColorString(t.G(), "bold", "\nWARNING: %v deleted or reset their account since this invite was created.\n\n", arg.Details.InviterUsername))
    60  	}
    61  	err := term.PromptForConfirmation(fmt.Sprintf("Do you want to join team %v?", arg.Details.TeamName))
    62  	return err == nil, err
    63  }