-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Tasks ("Act Now") section to home view (#6095)
* feat: Add Tasks section to home view * feature flag * tests * copy and fix
- Loading branch information
1 parent
c15f2e5
commit 675ad99
Showing
14 changed files
with
267 additions
and
47 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,35 @@ | ||
import { GraphQLObjectType } from "graphql" | ||
import { pageable } from "relay-cursor-paging" | ||
import { | ||
connectionWithCursorInfo, | ||
emptyConnection, | ||
} from "schema/v2/fields/pagination" | ||
import { TaskType } from "schema/v2/me/task" | ||
import { NodeInterface } from "schema/v2/object_identification" | ||
import { ResolverContext } from "types/graphql" | ||
import { | ||
HomeViewGenericSectionInterface, | ||
standardSectionFields, | ||
} from "./GenericSectionInterface" | ||
import { HomeViewSectionTypeNames } from "./names" | ||
|
||
export const HomeViewTasksSectionType = new GraphQLObjectType< | ||
any, | ||
ResolverContext | ||
>({ | ||
name: HomeViewSectionTypeNames.HomeViewSectionTasks, | ||
description: "A tasks section in the home view", | ||
interfaces: [HomeViewGenericSectionInterface, NodeInterface], | ||
fields: { | ||
...standardSectionFields, | ||
|
||
tasksConnection: { | ||
type: connectionWithCursorInfo({ | ||
nodeType: TaskType, | ||
}).connectionType, | ||
args: pageable({}), | ||
resolve: (parent, ...rest) => | ||
parent.resolver ? parent.resolver(parent, ...rest) : emptyConnection, | ||
}, | ||
}, | ||
}) |
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,40 @@ | ||
import { connectionFromArraySlice } from "graphql-relay" | ||
import { convertConnectionArgsToGravityArgs } from "lib/helpers" | ||
import { createPageCursors } from "schema/v2/fields/pagination" | ||
import { HomeViewSection } from "." | ||
import { withHomeViewTimeout } from "../helpers/withHomeViewTimeout" | ||
import { HomeViewSectionTypeNames } from "../sectionTypes/names" | ||
|
||
export const Tasks: HomeViewSection = { | ||
id: "home-view-section-tasks", | ||
type: HomeViewSectionTypeNames.HomeViewSectionTasks, | ||
// TODO: Create context module in Cohesion | ||
// contextModule: ContextModule.tasks, | ||
component: { | ||
title: "Act Now", | ||
}, | ||
featureFlag: "emerald_home-view-tasks-section", | ||
requiresAuthentication: true, | ||
resolver: withHomeViewTimeout(async (_parent, args, { meTasksLoader }) => { | ||
if (!meTasksLoader) return null | ||
|
||
const { page, size, offset } = convertConnectionArgsToGravityArgs(args) | ||
|
||
const { body: results, headers } = await meTasksLoader({ | ||
page, | ||
size, | ||
total_count: true, | ||
}) | ||
|
||
const count = parseInt(headers["x-total-count"] || "0", 10) | ||
|
||
return { | ||
totalCount: count, | ||
pageCursors: createPageCursors({ ...args, page, size }, count), | ||
...connectionFromArraySlice(results, args, { | ||
arrayLength: count, | ||
sliceStart: offset, | ||
}), | ||
} | ||
}), | ||
} |
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
Oops, something went wrong.