Skip to content

Commit

Permalink
chore: remove noTemplateLimit flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch committed Apr 11, 2024
1 parent abaa30b commit b9dbfae
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ graphql`
orgId
teamId
illustrationUrl
isFree
scope
viewerLowestScope
...TemplateDetails_activity
Expand Down Expand Up @@ -78,7 +77,6 @@ const ActivityDetails = (props: Props) => {
meetingType: activity.type,
scope: activity.scope,
templateName: activity.name,
isFree: activity.isFree,
queryString: activityLibrarySearch
})
}, [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,16 @@ export const TemplateDetails = (props: Props) => {
const viewer = useFragment(
graphql`
fragment TemplateDetails_user on User {
tier
preferredTeamId
teams {
...TeamPickerModal_teams
}
...useTemplateDescription_viewer
}
`,
viewerRef
)

const {teams, tier, preferredTeamId} = viewer
const {teams, preferredTeamId} = viewer
const history = useHistory<{prevCategory?: string; edit?: boolean}>()
const prevCategory = history.location.state?.prevCategory

Expand Down Expand Up @@ -201,7 +199,7 @@ export const TemplateDetails = (props: Props) => {

const isOwner = viewerLowestScope === 'TEAM'

const description = useTemplateDescription(viewerLowestScope, activity, tier, viewer)
const description = useTemplateDescription(viewerLowestScope, activity)

useEffect(() => {
setIsEditing(!!history.location.state?.edit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const ActivityDetailsSidebar = (props: Props) => {
teamId
orgId
scope
isFree
}
`,
selectedTemplateRef
Expand Down
27 changes: 3 additions & 24 deletions packages/client/utils/useTemplateDescription.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import graphql from 'babel-plugin-relay/macro'
import {readInlineData} from 'react-relay'
import {useTemplateDescription_template$key} from '../__generated__/useTemplateDescription_template.graphql'
import {useTemplateDescription_viewer$key} from '../__generated__/useTemplateDescription_viewer.graphql'
import {TierEnum} from '../__generated__/OrganizationSubscription.graphql'
import relativeDate from './date/relativeDate'

const useTemplateDescription = (
lowestScope: string,
templateRef?: useTemplateDescription_template$key,
tier?: TierEnum,
viewerRef?: useTemplateDescription_viewer$key
templateRef?: useTemplateDescription_template$key
) => {
if (!templateRef) {
return null
Expand All @@ -20,7 +16,6 @@ const useTemplateDescription = (
fragment useTemplateDescription_template on MeetingTemplate @inline {
lastUsedAt
scope
isFree
team {
name
}
Expand All @@ -29,26 +24,10 @@ const useTemplateDescription = (
templateRef
)

const viewer = readInlineData(
graphql`
fragment useTemplateDescription_viewer on User @inline {
id
featureFlags {
noTemplateLimit
}
}
`,
viewerRef ?? null
)

const {lastUsedAt, team, isFree} = template
const {lastUsedAt, team} = template
const {name: teamName} = team
if (lowestScope === 'PUBLIC') {
return isFree
? 'Free template'
: `Premium template ${
tier === 'starter' && !viewer?.featureFlags?.noTemplateLimit ? '🔒' : '✨'
}`
return 'Public template'
}
if (lowestScope === 'TEAM')
return lastUsedAt
Expand Down
10 changes: 0 additions & 10 deletions packages/server/graphql/mutations/helpers/bootstrapNewUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ const bootstrapNewUser = async (
experimentalFlags.push('signUpDestinationTeam')
}

// No template limit
const domainUserHasNoTemplateLimitFlag = usersWithDomain.some((user) =>
user.featureFlags.includes('noTemplateLimit')
)
if (domainUserHasNoTemplateLimitFlag) {
experimentalFlags.push('noTemplateLimit')
} else if (Math.random() < 0.5) {
experimentalFlags.push('noTemplateLimit')
}

const isVerified = identities.some((identity) => identity.isEmailVerified)
const hasSAMLURL = !!(await getSAMLURLFromEmail(email, dataLoader, false))
const isQualifiedForAutoJoin = (isVerified || hasSAMLURL) && isCompanyDomain
Expand Down
18 changes: 3 additions & 15 deletions packages/server/graphql/mutations/selectTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import publish from '../../utils/publish'
import standardError from '../../utils/standardError'
import {GQLContext} from '../graphql'
import SelectTemplatePayload from '../types/SelectTemplatePayload'
import {getFeatureTier} from '../types/helpers/getFeatureTier'
import {Logger} from '../../utils/Logger'

const selectTemplate = {
Expand All @@ -32,17 +31,16 @@ const selectTemplate = {
const viewerId = getUserId(authToken)

// AUTH
const [template, viewer] = await Promise.all([
dataLoader.get('meetingTemplates').load(selectedTemplateId) as Promise<MeetingTemplate>,
dataLoader.get('users').loadNonNull(viewerId)
const [template] = await Promise.all([
dataLoader.get('meetingTemplates').load(selectedTemplateId) as Promise<MeetingTemplate>
])

if (!template || !template.isActive) {
Logger.log('no template', selectedTemplateId, template)
return standardError(new Error('Template not found'), {userId: viewerId})
}

const {scope, isFree} = template
const {scope} = template
const viewerTeam = await dataLoader.get('teams').loadNonNull(teamId)
if (scope === 'TEAM') {
if (!isTeamMember(authToken, template.teamId))
Expand All @@ -52,16 +50,6 @@ const selectTemplate = {
if (viewerTeam.orgId !== templateTeam.orgId) {
return standardError(new Error('Template is scoped to organization'), {userId: viewerId})
}
} else if (scope === 'PUBLIC') {
if (
!isFree &&
!viewer.featureFlags.includes('noTemplateLimit') &&
getFeatureTier(viewerTeam) === 'starter'
) {
return standardError(new Error('User does not have access to this premium template'), {
userId: viewerId
})
}
}

// RESOLUTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ enum UserFlagEnum {
noAISummary
noMeetingHistoryLimit
adHocTeams
noTemplateLimit
signUpDestinationTeam
}

Expand All @@ -22,7 +21,6 @@ type UserFeatureFlags {
noAISummary: Boolean!
noMeetingHistoryLimit: Boolean!
adHocTeams: Boolean!
noTemplateLimit: Boolean!
signUpDestinationTeam: Boolean!
}

Expand Down
1 change: 0 additions & 1 deletion packages/server/graphql/public/types/UserFeatureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const UserFeatureFlags: UserFeatureFlagsResolvers = {
noAISummary: ({noAISummary}) => !!noAISummary,
noMeetingHistoryLimit: ({noMeetingHistoryLimit}) => !!noMeetingHistoryLimit,
adHocTeams: ({adHocTeams}) => !!adHocTeams,
noTemplateLimit: ({noTemplateLimit}) => !!noTemplateLimit,
signUpDestinationTeam: ({signUpDestinationTeam}) => !!signUpDestinationTeam
}

Expand Down
30 changes: 4 additions & 26 deletions packages/server/graphql/queries/helpers/resolveSelectedTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,18 @@ import getRethink from '../../../database/rethinkDriver'
import MeetingSettingsPoker from '../../../database/types/MeetingSettingsPoker'
import MeetingSettingsRetrospective from '../../../database/types/MeetingSettingsRetrospective'
import {GQLContext} from '../../graphql'
import {getUserId} from '../../../utils/authorization'
import isValid from '../../isValid'
import {getFeatureTier} from '../../types/helpers/getFeatureTier'

const resolveSelectedTemplate =
(fallbackTemplateId: string) =>
async (
source: MeetingSettingsPoker | MeetingSettingsRetrospective,
_args: unknown,
{authToken, dataLoader}: GQLContext
{dataLoader}: GQLContext
) => {
const viewerId = getUserId(authToken)
const {id: settingsId, selectedTemplateId, teamId} = source
const [team, template, viewer] = await Promise.all([
dataLoader.get('teams').loadNonNull(teamId),
dataLoader.get('meetingTemplates').load(selectedTemplateId),
dataLoader.get('users').loadNonNull(viewerId)
])
const {id: settingsId, selectedTemplateId} = source
const template = await dataLoader.get('meetingTemplates').load(selectedTemplateId)
if (template) {
if (
template.isFree ||
template.scope !== 'PUBLIC' ||
getFeatureTier(team) !== 'starter' ||
viewer.featureFlags.includes('noTemplateLimit')
) {
return template
}
// if anyone on the team has the noTemplateLimit flag, they might have selected a non-starter template
const teamMembers = await dataLoader.get('teamMembersByTeamId').load(teamId)
const userIds = teamMembers.map(({userId}) => userId)
const users = (await dataLoader.get('users').loadMany(userIds)).filter(isValid)
if (users.some(({featureFlags}) => featureFlags.includes('noTemplateLimit'))) {
return template
}
return template
}
// there may be holes in our template deletion or reselection logic, so doing this to be safe
source.selectedTemplateId = fallbackTemplateId
Expand Down
1 change: 0 additions & 1 deletion packages/server/graphql/types/UserFlagEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const UserFlagEnum = new GraphQLEnumType({
noAISummary: {},
noMeetingHistoryLimit: {},
adHocTeams: {},
noTemplateLimit: {},
signUpDestinationTeam: {}
}
})
Expand Down

0 comments on commit b9dbfae

Please sign in to comment.