Skip to content

Commit

Permalink
apply enter function only for object folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Abrar-Ahmed7 committed Feb 7, 2023
1 parent 626cc8c commit 71b0da4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
6 changes: 3 additions & 3 deletions internal/dao/buck_obj.go
Expand Up @@ -71,9 +71,9 @@ func setFoldersAndFIles(Folder []*s3.CommonPrefix, File []*s3.Object) []S3Object
o := S3Object{
Name: keyA[len(keyA)-2],
ObjectType: "Folder",
LastModified: "_",
Size: "0",
StorageClass: "_",
LastModified: "-",
Size: "-",
StorageClass: "-",
}
s3Objects = append(s3Objects, o)
indx++
Expand Down
12 changes: 12 additions & 0 deletions internal/ui/select_table.go
Expand Up @@ -79,6 +79,18 @@ func (s *SelectTable) GetSelectedItem() string {
return sel
}

func (s *SelectTable) GetSecondColumn() string {
if s.GetSelectedRowIndex() == 0 || s.model.Empty() {
return ""
}
sel := s.GetCell(s.GetSelectedRowIndex(), 1).Text

if s.selectedFn != nil {
return s.selectedFn(sel)
}
return sel
}

// GetSelectedCell returns the content of a cell for the currently selected row.
func (s *SelectTable) GetSelectedCell(col int) string {
r, _ := s.GetSelection()
Expand Down
27 changes: 15 additions & 12 deletions internal/view/buck_obj.go
Expand Up @@ -34,18 +34,21 @@ func (obj *BObj) bindKeys(aa ui.KeyActions) {

func (obj *BObj) enterCmd(evt *tcell.EventKey) *tcell.EventKey {
oName := obj.GetTable().GetSelectedItem()
o := NewS3FileViewer("OBJ")
ctx := obj.App().GetContext()
bn := ctx.Value(internal.BucketName)
fn := fmt.Sprintf("%v%v/", ctx.Value(internal.FolderName), oName)
log.Info().Msg(fmt.Sprintf("In view Folder Name: %v", fn))
ctx = context.WithValue(obj.App().context, internal.BucketName, bn)
obj.App().SetContext(ctx)
ctx = context.WithValue(obj.App().context, internal.FolderName, fn)
obj.App().SetContext(ctx)
fileType := obj.GetTable().GetSecondColumn()
if fileType == "Folder" {
o := NewS3FileViewer("OBJ")
ctx := obj.App().GetContext()
bn := ctx.Value(internal.BucketName)
fn := fmt.Sprintf("%v%v/", ctx.Value(internal.FolderName), oName)
log.Info().Msg(fmt.Sprintf("In view Folder Name: %v", fn))
ctx = context.WithValue(obj.App().context, internal.BucketName, bn)
obj.App().SetContext(ctx)
ctx = context.WithValue(obj.App().context, internal.FolderName, fn)
obj.App().SetContext(ctx)

obj.App().Flash().Info("Bucket Name: " + oName)
// println(bName)
obj.App().inject(o)
obj.App().Flash().Info("Bucket Name: " + oName)
// println(bName)
obj.App().inject(o)
}
return nil
}

0 comments on commit 71b0da4

Please sign in to comment.