OneDrive details UX improvements (#1034)
## Description - Rename `LastModified` to `Modified` in OneDrive backup details - Humanize file size units ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [x] 🐹 Trivial/Minor ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #627 ## Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
8ab5d5c112
commit
3df3d68a3e
@ -51,7 +51,7 @@ require (
|
|||||||
github.com/chmduquesne/rollinghash v4.0.0+incompatible // indirect
|
github.com/chmduquesne/rollinghash v4.0.0+incompatible // indirect
|
||||||
github.com/cjlapao/common-go v0.0.27 // indirect
|
github.com/cjlapao/common-go v0.0.27 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.0 // indirect
|
github.com/dustin/go-humanize v1.0.0
|
||||||
github.com/edsrzf/mmap-go v1.1.0 // indirect
|
github.com/edsrzf/mmap-go v1.1.0 // indirect
|
||||||
github.com/go-logr/logr v1.2.3 // indirect
|
github.com/go-logr/logr v1.2.3 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
|
|||||||
@ -57,11 +57,11 @@ func driveItemReader(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &details.OneDriveInfo{
|
return &details.OneDriveInfo{
|
||||||
ItemType: details.OneDriveItem,
|
ItemType: details.OneDriveItem,
|
||||||
ItemName: *item.GetName(),
|
ItemName: *item.GetName(),
|
||||||
Created: *item.GetCreatedDateTime(),
|
Created: *item.GetCreatedDateTime(),
|
||||||
LastModified: *item.GetLastModifiedDateTime(),
|
Modified: *item.GetLastModifiedDateTime(),
|
||||||
Size: *item.GetSize(),
|
Size: *item.GetSize(),
|
||||||
}, resp.Body, nil
|
}, resp.Body, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/dustin/go-humanize"
|
||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/print"
|
"github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/internal/common"
|
"github.com/alcionai/corso/src/internal/common"
|
||||||
"github.com/alcionai/corso/src/internal/model"
|
"github.com/alcionai/corso/src/internal/model"
|
||||||
@ -361,25 +363,25 @@ func (i SharepointInfo) Values() []string {
|
|||||||
|
|
||||||
// OneDriveInfo describes a oneDrive item
|
// OneDriveInfo describes a oneDrive item
|
||||||
type OneDriveInfo struct {
|
type OneDriveInfo struct {
|
||||||
ItemType ItemType `json:"itemType,omitempty"`
|
ItemType ItemType `json:"itemType,omitempty"`
|
||||||
ParentPath string `json:"parentPath"`
|
ParentPath string `json:"parentPath"`
|
||||||
ItemName string `json:"itemName"`
|
ItemName string `json:"itemName"`
|
||||||
Size int64 `json:"size,omitempty"`
|
Size int64 `json:"size,omitempty"`
|
||||||
Created time.Time `json:"created,omitempty"`
|
Created time.Time `json:"created,omitempty"`
|
||||||
LastModified time.Time `json:"lastModified,omitempty"`
|
Modified time.Time `json:"modified,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Headers returns the human-readable names of properties in a OneDriveInfo
|
// Headers returns the human-readable names of properties in a OneDriveInfo
|
||||||
// for printing out to a terminal in a columnar display.
|
// for printing out to a terminal in a columnar display.
|
||||||
func (i OneDriveInfo) Headers() []string {
|
func (i OneDriveInfo) Headers() []string {
|
||||||
return []string{"ItemName", "ParentPath", "Size", "Created", "LastModified"}
|
return []string{"ItemName", "ParentPath", "Size", "Created", "Modified"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values returns the values matching the Headers list for printing
|
// Values returns the values matching the Headers list for printing
|
||||||
// out to a terminal in a columnar display.
|
// out to a terminal in a columnar display.
|
||||||
func (i OneDriveInfo) Values() []string {
|
func (i OneDriveInfo) Values() []string {
|
||||||
return []string{
|
return []string{
|
||||||
i.ItemName, i.ParentPath, strconv.FormatInt(i.Size, 10),
|
i.ItemName, i.ParentPath, humanize.Bytes(uint64(i.Size)),
|
||||||
common.FormatTabularDisplayTime(i.Created), common.FormatTabularDisplayTime(i.LastModified),
|
common.FormatTabularDisplayTime(i.Created), common.FormatTabularDisplayTime(i.Modified),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,16 +112,16 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
|||||||
ShortRef: "deadbeef",
|
ShortRef: "deadbeef",
|
||||||
ItemInfo: details.ItemInfo{
|
ItemInfo: details.ItemInfo{
|
||||||
OneDrive: &details.OneDriveInfo{
|
OneDrive: &details.OneDriveInfo{
|
||||||
ItemName: "itemName",
|
ItemName: "itemName",
|
||||||
ParentPath: "parentPath",
|
ParentPath: "parentPath",
|
||||||
Size: 1000,
|
Size: 1000,
|
||||||
Created: now,
|
Created: now,
|
||||||
LastModified: now,
|
Modified: now,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectHs: []string{"Reference", "ItemName", "ParentPath", "Size", "Created", "LastModified"},
|
expectHs: []string{"Reference", "ItemName", "ParentPath", "Size", "Created", "Modified"},
|
||||||
expectVs: []string{"deadbeef", "itemName", "parentPath", "1000", nowStr, nowStr},
|
expectVs: []string{"deadbeef", "itemName", "parentPath", "1.0 kB", nowStr, nowStr},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -440,7 +440,7 @@ func (s OneDriveScope) matchesInfo(dii details.ItemInfo) bool {
|
|||||||
case FileFilterCreatedAfter, FileFilterCreatedBefore:
|
case FileFilterCreatedAfter, FileFilterCreatedBefore:
|
||||||
i = common.FormatTime(info.Created)
|
i = common.FormatTime(info.Created)
|
||||||
case FileFilterModifiedAfter, FileFilterModifiedBefore:
|
case FileFilterModifiedAfter, FileFilterModifiedBefore:
|
||||||
i = common.FormatTime(info.LastModified)
|
i = common.FormatTime(info.Modified)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.Matches(filterCat, i)
|
return s.Matches(filterCat, i)
|
||||||
|
|||||||
@ -297,12 +297,12 @@ func (suite *OneDriveSelectorSuite) TestOneDriveScope_MatchesInfo() {
|
|||||||
|
|
||||||
itemInfo := details.ItemInfo{
|
itemInfo := details.ItemInfo{
|
||||||
OneDrive: &details.OneDriveInfo{
|
OneDrive: &details.OneDriveInfo{
|
||||||
ItemType: details.OneDriveItem,
|
ItemType: details.OneDriveItem,
|
||||||
ParentPath: "folder1/folder2",
|
ParentPath: "folder1/folder2",
|
||||||
ItemName: "file1",
|
ItemName: "file1",
|
||||||
Size: 10,
|
Size: 10,
|
||||||
Created: now,
|
Created: now,
|
||||||
LastModified: now,
|
Modified: now,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user