Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI update #340

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions cmd/slackdump/internal/apiconfig/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/cfg"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/bubbles/filemgr"
)

Expand Down Expand Up @@ -62,21 +62,19 @@ func wizConfigCheck(ctx context.Context, cmd *base.Command, args []string) error
f.Focus()
f.ShowHelp = true
f.Style = filemgr.Style{
Normal: cfg.Theme.Focused.File,
Directory: cfg.Theme.Focused.Directory,
Inverted: lipgloss.NewStyle().
Foreground(cfg.Theme.Focused.FocusedButton.GetForeground()).
Background(cfg.Theme.Focused.FocusedButton.GetBackground()),
Shaded: cfg.WizStyle.ShadedCursor,
Normal: ui.DefaultTheme().Focused.UnselectedFile,
Directory: ui.DefaultTheme().Focused.Directory,
Inverted: ui.DefaultTheme().Focused.SelectedFile,
Shaded: ui.DefaultTheme().Focused.DisabledFile,
}
vp := viewport.New(80-filemgr.Width, f.Height)
vp.Style = lipgloss.NewStyle().Margin(0, 2)
vp.SetContent("Select a config file to check and press [Enter].")
m := checkerModel{
files: f,
view: vp,
FocusStyle: cfg.WizStyle.FocusedBorder,
BlurStyle: cfg.WizStyle.BlurredBorder,
FocusStyle: ui.DefaultTheme().Focused.Border,
BlurStyle: ui.DefaultTheme().Blurred.Border,
}

if _, err := tea.NewProgram(m).Run(); err != nil {
Expand Down
55 changes: 6 additions & 49 deletions cmd/slackdump/internal/archive/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,16 @@ package archive

import (
"context"
"strings"

"github.com/charmbracelet/huh"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/cfg"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/cfgui"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/wizard"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/dumpui"
)

func archiveWizard(ctx context.Context, cmd *base.Command, args []string) error {
var (
action string = "run"
)

menu := func() *huh.Form {
return huh.NewForm(
huh.NewGroup(
huh.NewSelect[string]().
Key("selection").
Title("Archive Slackdump workspace").
Options(
huh.NewOption("Run!", "run"),
huh.NewOption("Configure", "config"),
huh.NewOption("Show Config", "show"),
huh.NewOption(strings.Repeat("-", 10), ""),
huh.NewOption("Exit archive wizard", "exit"),
).Value(&action),
),
).WithTheme(cfg.Theme).WithAccessible(cfg.AccessibleMode)
}

LOOP:
for {
if err := menu().RunWithContext(ctx); err != nil {
return err
}
switch action {
case "exit":
break LOOP
case "config":
if err := wizard.Config(ctx); err != nil {
return err
}
case "show":
if err := cfgui.Show(ctx); err != nil {
return err
}
case "run":
if err := RunArchive(ctx, CmdArchive, nil); err != nil {
return err
}
}
w := &dumpui.Wizard{
Title: "Archive Slackdump workspace",
Particulars: "Archive",
Cmd: cmd,
}

return nil
return w.Run(ctx)
}
28 changes: 0 additions & 28 deletions cmd/slackdump/internal/cfg/wizard.go

This file was deleted.

12 changes: 7 additions & 5 deletions cmd/slackdump/internal/dump/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import (
"context"

"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/dumpui"
)

func WizDump(ctx context.Context, cmd *base.Command, args []string) error {
// ask for the list of channels
// ask for from and to dates
// ask name template
// ask filesystem
panic("not implemented")
w := dumpui.Wizard{
Title: "Dump Slackdump channels",
Particulars: "Dump",
Cmd: cmd,
}
return w.Run(ctx)
}
65 changes: 7 additions & 58 deletions cmd/slackdump/internal/export/wizard.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,14 @@ import (
"context"

"github.com/rusq/slackdump/v3/cmd/slackdump/internal/golang/base"
"github.com/rusq/slackdump/v3/cmd/slackdump/internal/ui/dumpui"
)

func wizExport(ctx context.Context, cmd *base.Command, args []string) error {
// options.Logger = logger.FromContext(ctx)
// prov, err := auth.FromContext(ctx)
// if err != nil {
// return err
// }
// // ask for the list
// list, err := ask.ConversationList("Enter conversations to export (optional)?")
// if err != nil {
// return err
// }
// options.List = list

// // ask if user wants time range
// options.Oldest, options.Latest, err = ask.MaybeTimeRange()
// if err != nil {
// return err
// }

// // ask for the type
// exportType, err := ask.ExportType()
// if err != nil {
// return err
// } else {
// options.Type = exportType
// }

// if wantExportToken, err := ui.Confirm("Do you want to specify an export token for attachments?", false); err != nil {
// return err
// } else if wantExportToken {
// // ask for the export token
// exportToken, err := ui.String("Export token", "Enter the export token, that will be appended to each of the attachment URLs.")
// if err != nil {
// return err
// }
// options.ExportToken = exportToken
// }

// // ask for the save location
// baseLoc, err := ui.FileSelector("Output ZIP or Directory name", "Enter the name of the ZIP or directory to save the export to.")
// if err != nil {
// return err
// }
// fsa, err := fsadapter.New(baseLoc)
// if err != nil {
// return err
// }
// defer fsa.Close()

// sess, err := slackdump.New(ctx, prov, slackdump.WithFilesystem(fsa), slackdump.WithLogger(options.Logger))
// if err != nil {
// return err
// }
// // TODO v3
// exp := export.New(sess, fsa, options)

// // run export
// return exp.Run(ctx)
return nil
w := &dumpui.Wizard{
Title: "Export Slackdump workspace",
Particulars: "Export",
Cmd: cmd,
}
return w.Run(ctx)
}
Loading