Skip to content

Commit

Permalink
feat: remove team template limit (#9424)
Browse files Browse the repository at this point in the history
* update error message and increase template limit

* remove max team template limits

* remove canClone prop from CloneTemplate

* remove unused threshold

* remove unused threshold
  • Loading branch information
nickoferrall committed Feb 19, 2024
1 parent c0a2fdf commit f042628
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export const TemplateDetails = (props: Props) => {
/>
</div>
<div className='rounded-full border border-solid border-slate-400'>
<CloneTemplate canClone={true} onClick={toggleTeamPickerPortal} />
<CloneTemplate onClick={toggleTeamPickerPortal} />
</div>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import graphql from 'babel-plugin-relay/macro'
import * as RadioGroup from '@radix-ui/react-radio-group'
import clsx from 'clsx'
import {Link} from 'react-router-dom'

import newTemplate from '../../../../../static/images/illustrations/newTemplate.png'
import estimatedEffortTemplate from '../../../../../static/images/illustrations/estimatedEffortTemplate.png'

import {CreateNewActivityQuery} from '~/__generated__/CreateNewActivityQuery.graphql'
import {ActivityCard, ActivityCardImage} from '../ActivityCard'
import {ActivityBadge} from '../ActivityBadge'

import IconLabel from '../../IconLabel'
import NewMeetingTeamPicker from '../../NewMeetingTeamPicker'
import sortByTier from '../../../utils/sortByTier'
Expand All @@ -20,7 +17,6 @@ import {AddReflectTemplateMutation$data} from '../../../__generated__/AddReflect
import useAtmosphere from '../../../hooks/useAtmosphere'
import useMutationProps from '../../../hooks/useMutationProps'
import AddReflectTemplateMutation from '../../../mutations/AddReflectTemplateMutation'
import {Threshold} from '../../../types/constEnums'
import useRouter from '../../../hooks/useRouter'
import {CATEGORY_ID_TO_NAME, CATEGORY_THEMES, CategoryID, DEFAULT_CARD_THEME} from '../Categories'
import BaseButton from '../../BaseButton'
Expand Down Expand Up @@ -111,15 +107,6 @@ const query = graphql`
...NewMeetingTeamPicker_selectedTeam
...NewMeetingTeamPicker_teams
}
availableTemplates(first: 2000) @connection(key: "ActivityLibrary_availableTemplates") {
edges {
node {
name
teamId
type
}
}
}
}
}
`
Expand Down Expand Up @@ -148,7 +135,7 @@ export const CreateNewActivity = (props: Props) => {
return selectedActivity
})
const {viewer} = data
const {teams, availableTemplates, preferredTeamId, featureFlags} = viewer
const {teams, preferredTeamId, featureFlags} = viewer
const [selectedTeam, setSelectedTeam] = useState(
teams.find((team) => team.id === preferredTeamId) ?? sortByTier(teams)[0]!
)
Expand All @@ -160,16 +147,6 @@ export const CreateNewActivity = (props: Props) => {
return
}

const teamTemplates = availableTemplates.edges.filter(
(template) =>
template.node.teamId === selectedTeam.id && template.node.type === 'retrospective'
)

if (teamTemplates.length >= Threshold.MAX_RETRO_TEAM_TEMPLATES) {
onError(new Error('You may only have 20 templates per team. Please remove one first.'))
return
}

submitMutation()
AddReflectTemplateMutation(
atmosphere,
Expand All @@ -195,15 +172,6 @@ export const CreateNewActivity = (props: Props) => {
return
}

const teamTemplates = availableTemplates.edges.filter(
(template) => template.node.teamId === selectedTeam.id && template.node.type === 'poker'
)

if (teamTemplates.length >= Threshold.MAX_POKER_TEAM_TEMPLATES) {
onError(new Error('You may only have 20 templates per team. Please remove one first.'))
return
}

submitMutation()
AddPokerTemplateMutation(
atmosphere,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import TooltipStyled from '../../../components/TooltipStyled'
import useAtmosphere from '../../../hooks/useAtmosphere'
import useMutationProps from '../../../hooks/useMutationProps'
import AddPokerTemplateMutation from '../../../mutations/AddPokerTemplateMutation'
import {Threshold} from '../../../types/constEnums'
import {AddNewPokerTemplate_pokerTemplates$key} from '../../../__generated__/AddNewPokerTemplate_pokerTemplates.graphql'
import {AddNewPokerTemplate_team$key} from '../../../__generated__/AddNewPokerTemplate_team.graphql'

Expand Down Expand Up @@ -79,17 +78,6 @@ const AddNewPokerTemplate = (props: Props) => {
displayUpgradeDetails()
return
}
if (pokerTemplates.length >= Threshold.MAX_RETRO_TEAM_TEMPLATES) {
onError(
new Error(
`You may only have ${Threshold.MAX_RETRO_TEAM_TEMPLATES} templates per team. Please remove one first.`
)
)
errorTimerId.current = window.setTimeout(() => {
onCompleted()
}, 8000)
return
}
if (pokerTemplates.find((template) => template.name.startsWith('*New Template'))) {
onError(new Error('You already have a new template. Try renaming that one first.'))
errorTimerId.current = window.setTimeout(() => {
Expand All @@ -106,7 +94,7 @@ const AddNewPokerTemplate = (props: Props) => {
template.name.startsWith('*New Template')
)

if (pokerTemplates.length > Threshold.MAX_POKER_TEAM_TEMPLATES || containsNewTemplate) return null
if (containsNewTemplate) return null
return (
<div>
{error && <ErrorLine>{error.message}</ErrorLine>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import TooltipStyled from '../../../components/TooltipStyled'
import useAtmosphere from '../../../hooks/useAtmosphere'
import useMutationProps from '../../../hooks/useMutationProps'
import AddReflectTemplateMutation from '../../../mutations/AddReflectTemplateMutation'
import {Threshold} from '../../../types/constEnums'
import {AddNewReflectTemplate_reflectTemplates$key} from '../../../__generated__/AddNewReflectTemplate_reflectTemplates.graphql'
import {AddNewReflectTemplate_team$key} from '../../../__generated__/AddNewReflectTemplate_team.graphql'

Expand Down Expand Up @@ -79,13 +78,6 @@ const AddNewReflectTemplate = (props: Props) => {
displayUpgradeDetails()
return
}
if (reflectTemplates.length >= Threshold.MAX_RETRO_TEAM_TEMPLATES) {
onError(new Error('You may only have 20 templates per team. Please remove one first.'))
errorTimerId.current = window.setTimeout(() => {
onCompleted()
}, 8000)
return
}
if (reflectTemplates.find((template) => template.name.startsWith('*New Template'))) {
onError(new Error('You already have a new template. Try renaming that one first.'))
errorTimerId.current = window.setTimeout(() => {
Expand All @@ -102,8 +94,7 @@ const AddNewReflectTemplate = (props: Props) => {
template.name.startsWith('*New Template')
)

if (reflectTemplates.length > Threshold.MAX_RETRO_TEAM_TEMPLATES || containsNewTemplate)
return null
if (containsNewTemplate) return null
return (
<div>
{error && <ErrorLine>{error.message}</ErrorLine>}
Expand Down
9 changes: 3 additions & 6 deletions packages/client/modules/meeting/components/CloneTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import React from 'react'
import DetailAction from '../../../components/DetailAction'

interface Props {
canClone: boolean
onClick: () => void
}

const CloneTemplate = (props: Props) => {
const {canClone, onClick} = props
const tooltip = canClone ? 'Clone & Edit Template' : 'Too many team templates! Remove one first'
return (
<DetailAction disabled={!canClone} icon={'content_copy'} tooltip={tooltip} onClick={onClick} />
)
const {onClick} = props
const tooltip = 'Clone & Edit Template'
return <DetailAction icon={'content_copy'} tooltip={tooltip} onClick={onClick} />
}
export default CloneTemplate
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import useAtmosphere from '../../../hooks/useAtmosphere'
import useMutationProps from '../../../hooks/useMutationProps'
import AddPokerTemplateMutation from '../../../mutations/AddPokerTemplateMutation'
import {PALETTE} from '../../../styles/paletteV3'
import {Threshold} from '../../../types/constEnums'
import getTemplateList from '../../../utils/getTemplateList'
import useTemplateDescription from '../../../utils/useTemplateDescription'
import {PokerTemplateDetails_settings$key} from '../../../__generated__/PokerTemplateDetails_settings.graphql'
Expand Down Expand Up @@ -108,12 +107,10 @@ const PokerTemplateDetails = (props: Props) => {
const lowestScope = getTemplateList(teamId, orgId, activeTemplate)
const isOwner = activeTemplate.teamId === teamId
const description = useTemplateDescription(lowestScope, activeTemplate, tier)
const templateCount = teamTemplates.length
const atmosphere = useAtmosphere()
const {onError, onCompleted, submitting, submitMutation} = useMutationProps()
const canClone = templateCount < Threshold.MAX_POKER_TEAM_TEMPLATES
const onClone = () => {
if (submitting || !canClone) return
if (submitting) return
submitMutation()
AddPokerTemplateMutation(
atmosphere,
Expand Down Expand Up @@ -145,7 +142,7 @@ const PokerTemplateDetails = (props: Props) => {
type='poker'
/>
)}
{showClone && <CloneTemplate onClick={onClone} canClone={canClone} />}
{showClone && <CloneTemplate onClick={onClone} />}
</FirstLine>
<Description>{description}</Description>
</TemplateHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import useAtmosphere from '../../../hooks/useAtmosphere'
import useMutationProps from '../../../hooks/useMutationProps'
import AddReflectTemplateMutation from '../../../mutations/AddReflectTemplateMutation'
import {PALETTE} from '../../../styles/paletteV3'
import {Threshold} from '../../../types/constEnums'
import getTemplateList from '../../../utils/getTemplateList'
import useTemplateDescription from '../../../utils/useTemplateDescription'
import {ReflectTemplateDetails_settings$key} from '../../../__generated__/ReflectTemplateDetails_settings.graphql'
Expand Down Expand Up @@ -116,12 +115,10 @@ const ReflectTemplateDetails = (props: Props) => {
const lowestScope = getTemplateList(teamId, orgId, activeTemplate)
const isOwner = activeTemplate.teamId === teamId
const description = useTemplateDescription(lowestScope, activeTemplate, tier)
const templateCount = teamTemplates.length
const atmosphere = useAtmosphere()
const {onError, onCompleted, submitting, submitMutation} = useMutationProps()
const canClone = templateCount < Threshold.MAX_RETRO_TEAM_TEMPLATES
const onClone = () => {
if (submitting || !canClone) return
if (submitting) return
submitMutation()
AddReflectTemplateMutation(
atmosphere,
Expand Down Expand Up @@ -153,7 +150,7 @@ const ReflectTemplateDetails = (props: Props) => {
type='retrospective'
/>
)}
{showClone && <CloneTemplate onClick={onClone} canClone={canClone} />}
{showClone && <CloneTemplate onClick={onClone} />}
</FirstLine>
<Description>{description}</Description>
</TemplateHeader>
Expand Down
2 changes: 0 additions & 2 deletions packages/client/types/constEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,6 @@ export const enum Threshold {
MAX_POKER_TEMPLATE_SCALES = 12,
MAX_POKER_SCALE_VALUES = 30,
POKER_SCALE_VALUE_MAX_LENGTH = 3,
MAX_RETRO_TEAM_TEMPLATES = 20,
MAX_POKER_TEAM_TEMPLATES = 20,
MAX_POKER_DIMENSION_NAME = 50,
MAX_QUAL_AI_MEETINGS = 3,
MAX_REACTJIS = 12,
Expand Down
5 changes: 1 addition & 4 deletions packages/server/graphql/mutations/addPokerTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {GraphQLID, GraphQLNonNull} from 'graphql'
import {SprintPokerDefaults, SubscriptionChannel, Threshold} from 'parabol-client/types/constEnums'
import {SprintPokerDefaults, SubscriptionChannel} from 'parabol-client/types/constEnums'
import getRethink from '../../database/rethinkDriver'
import PokerTemplate from '../../database/types/PokerTemplate'
import TemplateDimension from '../../database/types/TemplateDimension'
Expand Down Expand Up @@ -45,9 +45,6 @@ const addPokerTemplate = {
dataLoader.get('teams').load(teamId),
dataLoader.get('users').loadNonNull(viewerId)
])
if (allTemplates.length >= Threshold.MAX_RETRO_TEAM_TEMPLATES) {
return standardError(new Error('Too many templates'), {userId: viewerId})
}

if (!viewerTeam) {
return standardError(new Error('Team not found'), {userId: viewerId})
Expand Down
5 changes: 1 addition & 4 deletions packages/server/graphql/mutations/addReflectTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {GraphQLID, GraphQLNonNull} from 'graphql'
import {SubscriptionChannel, Threshold} from 'parabol-client/types/constEnums'
import {SubscriptionChannel} from 'parabol-client/types/constEnums'
import {PALETTE} from '../../../client/styles/paletteV3'
import getRethink from '../../database/rethinkDriver'
import ReflectTemplate from '../../database/types/ReflectTemplate'
Expand Down Expand Up @@ -47,9 +47,6 @@ const addReflectTemplate = {
dataLoader.get('users').loadNonNull(viewerId)
])

if (allTemplates.length >= Threshold.MAX_RETRO_TEAM_TEMPLATES) {
return standardError(new Error('Too many templates'), {userId: viewerId})
}
if (!viewerTeam) {
return standardError(new Error('Team not found'), {userId: viewerId})
}
Expand Down

0 comments on commit f042628

Please sign in to comment.