-
Notifications
You must be signed in to change notification settings - Fork 336
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
feat: show default insight #10283
Merged
Merged
feat: show default insight #10283
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5af1ce4
add insights tab
nickoferrall 571ff2b
update tabs logic
nickoferrall 4b938b7
add team insight root and query
nickoferrall e80e457
add comment
nickoferrall 7894e90
show team insight
nickoferrall 0eabf01
add bottom margin
nickoferrall 292f3f8
feat: team insights skeleton, minor style nits (#10274)
ackernaut 8137177
Merge branch 'feat/10238/add-ui-skeleton' into feat/10239/show-defaul…
nickoferrall fc6400a
add meetingsCount and latestInsightByTeamId dataloader
nickoferrall a9218e4
rename link-styles
nickoferrall 485e984
only team lead can view insights tab
nickoferrall 1a8833e
fix merge conflict
nickoferrall 9274437
use insightId
nickoferrall 1581dbb
fix insight id type
nickoferrall 90cb781
Merge branch 'master' into feat/10238/add-ui-skeleton
nickoferrall 75173ad
fix merge conflicts
nickoferrall 57dde60
update migration order
nickoferrall cfd8c78
feat: generate insight from empty state (#10323)
nickoferrall 1f4b937
fix merge conflicts
nickoferrall 78204ca
update migration order
nickoferrall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const InsightId = { | ||
join: (ownerId: string, databaseId: number) => `insight:${ownerId}:${databaseId}`, | ||
split: (id: string) => { | ||
const [, ownerId, databaseId] = id.split(':') | ||
return {ownerId, databaseId} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import TeamInsightsId from 'parabol-client/shared/gqlIds/TeamInsightsId' | ||
import {InsightId} from '../../../../client/shared/gqlIds/InsightId' | ||
import toTeamMemberId from '../../../../client/utils/relay/toTeamMemberId' | ||
import {getUserId, isTeamMember} from '../../../utils/authorization' | ||
import {getFeatureTier} from '../../types/helpers/getFeatureTier' | ||
|
@@ -52,15 +53,13 @@ const Team: TeamResolvers = { | |
const teamMembers = await dataLoader.get('teamMembersByTeamId').load(teamId) | ||
return teamMembers.find((teamMember) => teamMember.isLead)! | ||
}, | ||
isViewerTeamLead: async ({id: teamId}, _args, {authToken, dataLoader}) => { | ||
const viewerId = getUserId(authToken) | ||
const teamMemberId = toTeamMemberId(teamId, viewerId) | ||
const teamMember = await dataLoader.get('teamMembers').load(teamMemberId) | ||
return teamMember?.isLead || false | ||
}, | ||
insight: async ({id: teamId}, _args, {dataLoader}) => { | ||
const insight = await dataLoader.get('latestInsightByTeamId').load(teamId) | ||
return insight || null | ||
if (!insight) return null | ||
return { | ||
...insight, | ||
id: InsightId.join(teamId, insight.id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 The nicer solution would be to have a resolver for the insights type. Define the DB type as source for it and then have a single id field doing this conversion. This way it will work in all occurrences where we would add this field. |
||
} | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting a type error. The problem seems to be that the id is an Int because I'm using SERIAL here.
Insight.id is defined as type ID here.
But I get a type error, that's resolved when I do:
So the problem seems to be the id is an int, but it's expecting a string. I could change the type Insight.id to Int here, but that doesn't seem clean when it's an ID.
Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1 Yes, the type error is correct and caught an error. We don't want to return the database id directly (of type int) because IDs should be globally unique (something to do with Relay caching). So we should create an GQL ID type for insights where we do the usual
join
/split
and something likeinsights:${teamId}:${databaseId}
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that makes sense, thanks!