Bug fixes in browse workflow table (#2944)

* Bug fixes in browse workflow table

Signed-off-by: SarthakJain26 <sarthak@chaosnative.com>

* Fixed import order

Signed-off-by: SarthakJain26 <sarthak@chaosnative.com>
This commit is contained in:
Sarthak Jain 2021-06-25 13:49:06 +05:30 committed by GitHub
parent 48c079aa85
commit 38af7328a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 73 deletions

View File

@ -97,7 +97,7 @@ export interface ListManifestTemplate {
} }
export interface SortInput { export interface SortInput {
field: 'Name'; field: 'Name' | 'Time';
descending?: Boolean; descending?: Boolean;
} }
@ -116,7 +116,7 @@ export interface ListWorkflowsInput {
} }
export interface ListWorkflowsOutput { export interface ListWorkflowsOutput {
totalNoOfWorkflows: number; total_no_of_workflows: number;
workflows: ScheduledWorkflow[]; workflows: ScheduledWorkflow[];
} }

View File

@ -69,7 +69,7 @@ const BrowseSchedule: React.FC = () => {
// State for sorting // State for sorting
const [sortData, setSortData] = useState<SortInput>({ const [sortData, setSortData] = useState<SortInput>({
field: 'Name', field: 'Time',
descending: true, descending: true,
}); });
@ -366,7 +366,7 @@ const BrowseSchedule: React.FC = () => {
<TablePagination <TablePagination
rowsPerPageOptions={[10, 25, 50]} rowsPerPageOptions={[10, 25, 50]}
component="div" component="div"
count={data?.ListWorkflow.totalNoOfWorkflows ?? 0} count={data?.ListWorkflow.total_no_of_workflows ?? 0}
rowsPerPage={paginationData.limit} rowsPerPage={paginationData.limit}
page={paginationData.page} page={paginationData.page}
onChangePage={(_, page) => onChangePage={(_, page) =>

View File

@ -625,6 +625,7 @@ github.com/litmuschaos/chaos-scheduler v0.0.0-20210607090343-9952190ad032 h1:Nza
github.com/litmuschaos/chaos-scheduler v0.0.0-20210607090343-9952190ad032/go.mod h1:7EO6kbZKeJGKzkchgQepCxywvqNFNvNHW0G+u9923AY= github.com/litmuschaos/chaos-scheduler v0.0.0-20210607090343-9952190ad032/go.mod h1:7EO6kbZKeJGKzkchgQepCxywvqNFNvNHW0G+u9923AY=
github.com/litmuschaos/elves v0.0.0-20201107015738-552d74669e3c/go.mod h1:DsbHGNUq/78NZozWVVI9Q6eBei4I+JjlkkD5aibJ3MQ= github.com/litmuschaos/elves v0.0.0-20201107015738-552d74669e3c/go.mod h1:DsbHGNUq/78NZozWVVI9Q6eBei4I+JjlkkD5aibJ3MQ=
github.com/litmuschaos/litmus v0.0.0-20210623100610-9204af1e8d30 h1:J5+8Q3Zk+K1zw4r3Ar1rvduyXjBvgSyTvrVDdAR1NbE= github.com/litmuschaos/litmus v0.0.0-20210623100610-9204af1e8d30 h1:J5+8Q3Zk+K1zw4r3Ar1rvduyXjBvgSyTvrVDdAR1NbE=
github.com/litmuschaos/litmus v0.0.0-20210625045545-48c079aa85a1 h1:yQwgVyBQPlQlNskpmggDxbyFYJXagElNaKIZBXNErw4=
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/lpabon/godbc v0.1.1/go.mod h1:Jo9QV0cf3U6jZABgiJ2skINAXb9j8m51r07g4KI92ZA= github.com/lpabon/godbc v0.1.1/go.mod h1:Jo9QV0cf3U6jZABgiJ2skINAXb9j8m51r07g4KI92ZA=
github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f/go.mod h1:JpH9J1c9oX6otFSgdUHwUBUizmKlrMjxWnIAjff4m04= github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f/go.mod h1:JpH9J1c9oX6otFSgdUHwUBUizmKlrMjxWnIAjff4m04=

View File

@ -5268,13 +5268,13 @@ input Pagination {
limit: Int! limit: Int!
} }
enum WorkflowRunSortingField { enum WorkflowSortingField {
Name Name
Time Time
} }
input WorkflowRunSortInput { input WorkflowRunSortInput {
field: WorkflowRunSortingField! field: WorkflowSortingField!
descending: Boolean descending: Boolean
} }
@ -5326,10 +5326,6 @@ input ListWorkflowsInput {
filter: WorkflowFilterInput filter: WorkflowFilterInput
} }
enum WorkflowSortingField {
Name
}
input WorkflowSortInput { input WorkflowSortInput {
field: WorkflowSortingField! field: WorkflowSortingField!
descending: Boolean descending: Boolean
@ -24913,7 +24909,7 @@ func (ec *executionContext) unmarshalInputWorkflowRunSortInput(ctx context.Conte
switch k { switch k {
case "field": case "field":
var err error var err error
it.Field, err = ec.unmarshalNWorkflowRunSortingField2githubᚗcomᚋlitmuschaosᚋlitmusᚋlitmusᚑportalᚋgraphqlᚑserverᚋgraphᚋmodelᚐWorkflowRunSortingField(ctx, v) it.Field, err = ec.unmarshalNWorkflowSortingField2githubᚗcomᚋlitmuschaosᚋlitmusᚋlitmusᚑportalᚋgraphqlᚑserverᚋgraphᚋmodelᚐWorkflowSortingField(ctx, v)
if err != nil { if err != nil {
return it, err return it, err
} }
@ -30638,15 +30634,6 @@ func (ec *executionContext) unmarshalNWorkflowRunInput2githubᚗcomᚋlitmuschao
return ec.unmarshalInputWorkflowRunInput(ctx, v) return ec.unmarshalInputWorkflowRunInput(ctx, v)
} }
func (ec *executionContext) unmarshalNWorkflowRunSortingField2githubᚗcomᚋlitmuschaosᚋlitmusᚋlitmusᚑportalᚋgraphqlᚑserverᚋgraphᚋmodelᚐWorkflowRunSortingField(ctx context.Context, v interface{}) (model.WorkflowRunSortingField, error) {
var res model.WorkflowRunSortingField
return res, res.UnmarshalGQL(v)
}
func (ec *executionContext) marshalNWorkflowRunSortingField2githubᚗcomᚋlitmuschaosᚋlitmusᚋlitmusᚑportalᚋgraphqlᚑserverᚋgraphᚋmodelᚐWorkflowRunSortingField(ctx context.Context, sel ast.SelectionSet, v model.WorkflowRunSortingField) graphql.Marshaler {
return v
}
func (ec *executionContext) unmarshalNWorkflowRunStatsRequest2githubᚗcomᚋlitmuschaosᚋlitmusᚋlitmusᚑportalᚋgraphqlᚑserverᚋgraphᚋmodelᚐWorkflowRunStatsRequest(ctx context.Context, v interface{}) (model.WorkflowRunStatsRequest, error) { func (ec *executionContext) unmarshalNWorkflowRunStatsRequest2githubᚗcomᚋlitmuschaosᚋlitmusᚋlitmusᚑportalᚋgraphqlᚑserverᚋgraphᚋmodelᚐWorkflowRunStatsRequest(ctx context.Context, v interface{}) (model.WorkflowRunStatsRequest, error) {
return ec.unmarshalInputWorkflowRunStatsRequest(ctx, v) return ec.unmarshalInputWorkflowRunStatsRequest(ctx, v)
} }

View File

@ -628,8 +628,8 @@ type WorkflowRunInput struct {
} }
type WorkflowRunSortInput struct { type WorkflowRunSortInput struct {
Field WorkflowRunSortingField `json:"field"` Field WorkflowSortingField `json:"field"`
Descending *bool `json:"descending"` Descending *bool `json:"descending"`
} }
type WorkflowRunStatsRequest struct { type WorkflowRunStatsRequest struct {
@ -1114,47 +1114,6 @@ func (e UsageSort) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String())) fmt.Fprint(w, strconv.Quote(e.String()))
} }
type WorkflowRunSortingField string
const (
WorkflowRunSortingFieldName WorkflowRunSortingField = "Name"
WorkflowRunSortingFieldTime WorkflowRunSortingField = "Time"
)
var AllWorkflowRunSortingField = []WorkflowRunSortingField{
WorkflowRunSortingFieldName,
WorkflowRunSortingFieldTime,
}
func (e WorkflowRunSortingField) IsValid() bool {
switch e {
case WorkflowRunSortingFieldName, WorkflowRunSortingFieldTime:
return true
}
return false
}
func (e WorkflowRunSortingField) String() string {
return string(e)
}
func (e *WorkflowRunSortingField) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
*e = WorkflowRunSortingField(str)
if !e.IsValid() {
return fmt.Errorf("%s is not a valid WorkflowRunSortingField", str)
}
return nil
}
func (e WorkflowRunSortingField) MarshalGQL(w io.Writer) {
fmt.Fprint(w, strconv.Quote(e.String()))
}
type WorkflowRunStatus string type WorkflowRunStatus string
const ( const (
@ -1204,15 +1163,17 @@ type WorkflowSortingField string
const ( const (
WorkflowSortingFieldName WorkflowSortingField = "Name" WorkflowSortingFieldName WorkflowSortingField = "Name"
WorkflowSortingFieldTime WorkflowSortingField = "Time"
) )
var AllWorkflowSortingField = []WorkflowSortingField{ var AllWorkflowSortingField = []WorkflowSortingField{
WorkflowSortingFieldName, WorkflowSortingFieldName,
WorkflowSortingFieldTime,
} }
func (e WorkflowSortingField) IsValid() bool { func (e WorkflowSortingField) IsValid() bool {
switch e { switch e {
case WorkflowSortingFieldName: case WorkflowSortingFieldName, WorkflowSortingFieldTime:
return true return true
} }
return false return false

View File

@ -22,13 +22,13 @@ input Pagination {
limit: Int! limit: Int!
} }
enum WorkflowRunSortingField { enum WorkflowSortingField {
Name Name
Time Time
} }
input WorkflowRunSortInput { input WorkflowRunSortInput {
field: WorkflowRunSortingField! field: WorkflowSortingField!
descending: Boolean descending: Boolean
} }
@ -80,10 +80,6 @@ input ListWorkflowsInput {
filter: WorkflowFilterInput filter: WorkflowFilterInput
} }
enum WorkflowSortingField {
Name
}
input WorkflowSortInput { input WorkflowSortInput {
field: WorkflowSortingField! field: WorkflowSortingField!
descending: Boolean descending: Boolean

View File

@ -306,7 +306,7 @@ func QueryWorkflowRuns(input model.GetWorkflowRunsInput) (*model.GetWorkflowsOut
var sortStage bson.D var sortStage bson.D
switch { switch {
case input.Sort != nil && input.Sort.Field == model.WorkflowRunSortingFieldTime: case input.Sort != nil && input.Sort.Field == model.WorkflowSortingFieldTime:
// Sorting based on LastUpdated time // Sorting based on LastUpdated time
if input.Sort.Descending != nil && *input.Sort.Descending { if input.Sort.Descending != nil && *input.Sort.Descending {
sortStage = bson.D{ sortStage = bson.D{
@ -321,7 +321,7 @@ func QueryWorkflowRuns(input model.GetWorkflowRunsInput) (*model.GetWorkflowsOut
}}, }},
} }
} }
case input.Sort != nil && input.Sort.Field == model.WorkflowRunSortingFieldName: case input.Sort != nil && input.Sort.Field == model.WorkflowSortingFieldName:
// Sorting based on WorkflowName time // Sorting based on WorkflowName time
if input.Sort.Descending != nil && *input.Sort.Descending { if input.Sort.Descending != nil && *input.Sort.Descending {
sortStage = bson.D{ sortStage = bson.D{
@ -491,8 +491,25 @@ func QueryListWorkflow(workflowInput model.ListWorkflowsInput) (*model.ListWorkf
var sortStage bson.D var sortStage bson.D
switch { switch {
case workflowInput.Sort != nil && workflowInput.Sort.Field == model.WorkflowSortingFieldTime:
// Sorting based on LastUpdated time
if workflowInput.Sort.Descending != nil && *workflowInput.Sort.Descending {
sortStage = bson.D{
{"$sort", bson.D{
{"updated_at", -1},
}},
}
} else {
sortStage = bson.D{
{"$sort", bson.D{
{"updated_at", 1},
}},
}
}
case workflowInput.Sort != nil && workflowInput.Sort.Field == model.WorkflowSortingFieldName: case workflowInput.Sort != nil && workflowInput.Sort.Field == model.WorkflowSortingFieldName:
// Sorting based on WorkflowName time // Sorting based on WorkflowName
if workflowInput.Sort.Descending != nil && *workflowInput.Sort.Descending { if workflowInput.Sort.Descending != nil && *workflowInput.Sort.Descending {
sortStage = bson.D{ sortStage = bson.D{
{"$sort", bson.D{ {"$sort", bson.D{