-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Showing
14 changed files
with
127 additions
and
28 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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ui | ||
|
||
import ( | ||
"github.com/charmbracelet/bubbles/key" | ||
"github.com/charmbracelet/huh" | ||
) | ||
|
||
var DefaultHuhKeymap = huh.NewDefaultKeyMap() | ||
|
||
func init() { | ||
// redefinition of some of the default keys. | ||
DefaultHuhKeymap.Quit = key.NewBinding(key.WithKeys("ctrl+c", "esc"), key.WithHelp("esc", "quit")) | ||
} |
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
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
76 changes: 76 additions & 0 deletions
76
cmd/slackdump/internal/workspace/workspaceui/ezlogin3000.go
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package workspaceui | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
|
||
"github.com/rusq/slackdump/v3/auth" | ||
|
||
"github.com/rusq/slackdump/v3/auth/browser" | ||
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui" | ||
|
||
"github.com/charmbracelet/huh" | ||
) | ||
|
||
func ezLogin3000(ctx context.Context, mgr manager) error { | ||
var ( | ||
legacy bool | ||
) | ||
form := huh.NewForm(huh.NewGroup( | ||
huh.NewConfirm(). | ||
Title("Use legacy EZ-Login?"). | ||
Description("Do you want to use the legacy login?"). | ||
Value(&legacy), | ||
)).WithTheme(ui.HuhTheme()).WithKeyMap(ui.DefaultHuhKeymap) | ||
if err := form.RunWithContext(ctx); err != nil { | ||
if errors.Is(err, huh.ErrUserAborted) { | ||
return nil | ||
} | ||
return err | ||
} | ||
if legacy { | ||
return playwrightLogin(ctx, mgr) | ||
} | ||
return rodLogin(ctx, mgr) | ||
|
||
} | ||
|
||
func playwrightLogin(ctx context.Context, mgr manager) error { | ||
var brws = browser.Bchromium | ||
formBrowser := huh.NewForm(huh.NewGroup( | ||
huh.NewSelect[browser.Browser](). | ||
Options( | ||
huh.NewOption("Chromium", browser.Bchromium), | ||
huh.NewOption("Firefox", browser.Bfirefox), | ||
). | ||
Value(&brws), | ||
)).WithTheme(ui.HuhTheme()).WithKeyMap(ui.DefaultHuhKeymap) | ||
if err := formBrowser.RunWithContext(ctx); err != nil { | ||
if errors.Is(err, huh.ErrUserAborted) { | ||
return nil | ||
} | ||
return err | ||
} | ||
prov, err := auth.NewBrowserAuth(ctx, auth.BrowserWithBrowser(brws)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
name, err := createAndSelect(ctx, mgr, prov) | ||
if err != nil { | ||
return err | ||
} | ||
return success(ctx, name) | ||
} | ||
|
||
func rodLogin(ctx context.Context, mgr manager) error { | ||
prov, err := auth.NewRODAuth(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
name, err := createAndSelect(ctx, mgr, prov) | ||
if err != nil { | ||
return err | ||
} | ||
return success(ctx, name) | ||
} |
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