Skip to content
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

chore: Make meeting series naming consistent #9928

Merged
merged 6 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import clsx from 'clsx'
import React, {useEffect, useRef, useState} from 'react'
import {useFragment} from 'react-relay'
import {useHistory} from 'react-router'
import {RRule} from 'rrule'
import {ActivityDetailsSidebar_teams$key} from '~/__generated__/ActivityDetailsSidebar_teams.graphql'
import {ActivityDetailsSidebar_template$key} from '~/__generated__/ActivityDetailsSidebar_template.graphql'
import StartRetrospectiveMutation from '~/mutations/StartRetrospectiveMutation'
import StartSprintPokerMutation from '~/mutations/StartSprintPokerMutation'
import UpdateReflectTemplateScopeMutation from '~/mutations/UpdateReflectTemplateScopeMutation'
import {MeetingTypeEnum} from '../../__generated__/ActivityDetailsQuery.graphql'
import {
CreateGcalEventInput,
RecurrenceSettingsInput
} from '../../__generated__/StartRetrospectiveMutation.graphql'
import {CreateGcalEventInput} from '../../__generated__/StartRetrospectiveMutation.graphql'
import useAtmosphere from '../../hooks/useAtmosphere'
import useMutationProps from '../../hooks/useMutationProps'
import SelectTemplateMutation from '../../mutations/SelectTemplateMutation'
Expand Down Expand Up @@ -116,23 +114,16 @@ const ActivityDetailsSidebar = (props: Props) => {
const {onError, onCompleted, submitting, submitMutation, error} = mutationProps
const history = useHistory()

const handleStartActivity = (
gcalInput?: CreateGcalEventInput,
recurrenceSettings?: RecurrenceSettingsInput
) => {
const handleStartActivity = (name?: string, rrule?: RRule, gcalInput?: CreateGcalEventInput) => {
Dschoordsch marked this conversation as resolved.
Show resolved Hide resolved
if (submitting) return
submitMutation()
if (type === 'teamPrompt') {
StartTeamPromptMutation(
atmosphere,
{
teamId: selectedTeam.id,
recurrenceSettings: recurrenceSettings
? {
rrule: recurrenceSettings.rrule?.toString(),
name: recurrenceSettings.name
}
: undefined,
name,
rrule: rrule?.toString(),
gcalInput
},
{history, onError, onCompleted}
Expand All @@ -155,12 +146,8 @@ const ActivityDetailsSidebar = (props: Props) => {
atmosphere,
{
teamId: selectedTeam.id,
recurrenceSettings: recurrenceSettings
? {
rrule: recurrenceSettings.rrule?.toString(),
name: recurrenceSettings.name
}
: undefined,
name,
rrule: rrule?.toString(),
gcalInput
},
{history, onError, onCompleted}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import graphql from 'babel-plugin-relay/macro'
import React from 'react'
import {useFragment} from 'react-relay'
import {RRule} from 'rrule'
import {ScheduleMeetingButton_team$key} from '~/__generated__/ScheduleMeetingButton_team.graphql'
import {
CreateGcalEventInput,
RecurrenceSettingsInput
} from '../../__generated__/StartRetrospectiveMutation.graphql'
import {CreateGcalEventInput} from '../../__generated__/StartRetrospectiveMutation.graphql'
import useModal from '../../hooks/useModal'
import {MenuMutationProps} from '../../hooks/useMutationProps'
import DialogContainer from '../DialogContainer'
Expand All @@ -14,10 +12,7 @@ import SecondaryButton from '../SecondaryButton'

type Props = {
mutationProps: MenuMutationProps
handleStartActivity: (
gcalInput?: CreateGcalEventInput,
recurrenceInput?: RecurrenceSettingsInput
) => void
handleStartActivity: (name?: string, rrule?: RRule, gcalInput?: CreateGcalEventInput) => void
Dschoordsch marked this conversation as resolved.
Show resolved Hide resolved
teamRef: ScheduleMeetingButton_team$key
placeholder: string
withRecurrence?: boolean
Expand Down Expand Up @@ -60,11 +55,8 @@ const ScheduleMeetingButton = (props: Props) => {
const handleClick = () => {
toggleModal()
}
const onStartActivity = (
gcalInput?: CreateGcalEventInput,
recurrenceInput?: RecurrenceSettingsInput
) => {
handleStartActivity(gcalInput, recurrenceInput)
const onStartActivity = (name?: string, rrule?: RRule, gcalInput?: CreateGcalEventInput) => {
handleStartActivity(name, rrule, gcalInput)
closeModal()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const EndRecurringMeetingModal = (props: Props) => {
if (!isMeetingOnly) {
UpdateRecurrenceSettingsMutation(
atmosphere,
{meetingId, recurrenceSettings: {name: null, rrule: null}},
{meetingId, name: null, rrule: null},
{onError, onCompleted}
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export const RecurrenceSettings = (props: Props) => {
<Description>
The next meeting in this series will be called{' '}
<span className='font-semibold'>
"{title} - {dayjs(recurrenceStartTime).format('MMM DD')}"
"{title} - {dayjs(new Date()).format('MMM DD')}"
</span>
</Description>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,8 @@ export const UpdateRecurrenceSettingsModal = (props: Props) => {
atmosphere,
{
meetingId: meeting.id,
recurrenceSettings: {
rrule: rrule?.toString(),
name: title
}
rrule: rrule?.toString(),
name: title
},
{onError, onCompleted: onRecurrenceSettingsUpdated}
)
Expand All @@ -190,7 +188,7 @@ export const UpdateRecurrenceSettingsModal = (props: Props) => {

UpdateRecurrenceSettingsMutation(
atmosphere,
{meetingId: meeting.id, recurrenceSettings: {rrule: null}},
{meetingId: meeting.id, rrule: null},
{onError, onCompleted: onRecurrenceSettingsUpdated}
)
}
Expand Down
24 changes: 12 additions & 12 deletions packages/client/components/ScheduleDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import React, {ChangeEvent, useState} from 'react'
import {useFragment} from 'react-relay'
import {RRule} from 'rrule'
import {ScheduleDialog_team$key} from '~/__generated__/ScheduleDialog_team.graphql'
import {
CreateGcalEventInput,
RecurrenceSettingsInput
} from '../__generated__/StartRetrospectiveMutation.graphql'
import {CreateGcalEventInput} from '../__generated__/StartRetrospectiveMutation.graphql'
import useAtmosphere from '../hooks/useAtmosphere'
import useForm from '../hooks/useForm'
import {MenuMutationProps} from '../hooks/useMutationProps'
Expand All @@ -34,7 +31,7 @@ const validateTitle = (title: string) =>
new Legitity(title).trim().min(2, `C’mon, you call that a title?`)

interface Props {
onStartActivity: (gcalInput?: CreateGcalEventInput, recurrence?: RecurrenceSettingsInput) => void
onStartActivity: (name?: string, rrule?: RRule, gcalInput?: CreateGcalEventInput) => void
placeholder: string
teamRef: ScheduleDialog_team$key
onCancel: () => void
Expand Down Expand Up @@ -101,24 +98,23 @@ export const ScheduleDialog = (props: Props) => {
}

const handleSubmit = () => {
const title = fields.title.value || placeholder
const titleRes = validateTitle(title)
if (titleRes.error) {
fields.title.setError(titleRes.error)
const name = fields.title.value || placeholder
const nameRes = validateTitle(name)
if (nameRes.error) {
fields.title.setError(nameRes.error)
return
}

const gcalEventInput = addedInvite
? {
title,
startTimestamp: gcalInput.start.unix(),
endTimestamp: gcalInput.end.unix(),
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
invitees: gcalInput.invitees,
videoType: gcalInput.videoType ?? undefined
}
: undefined
props.onStartActivity(gcalEventInput, rrule ? {rrule} : undefined)
props.onStartActivity(name, rrule ?? undefined, gcalEventInput)
}

const onAddInvite = () => {
Expand Down Expand Up @@ -201,7 +197,11 @@ export const ScheduleDialog = (props: Props) => {
<ExpandMore className={clsx(openRecurrence && 'rotate-180')} />
</Collapsible.Trigger>
<Collapsible.Content className='space-y-4'>
<RecurrenceSettings title={title} rrule={rrule} onRruleUpdated={setRrule} />
<RecurrenceSettings
title={title || placeholder}
rrule={rrule}
onRruleUpdated={setRrule}
/>
</Collapsible.Content>
</Collapsible.Root>
)}
Expand Down
9 changes: 3 additions & 6 deletions packages/client/mutations/StartRetrospectiveMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ graphql`
const mutation = graphql`
mutation StartRetrospectiveMutation(
$teamId: ID!
$recurrenceSettings: RecurrenceSettingsInput
$name: String
$rrule: RRule
$gcalInput: CreateGcalEventInput
) {
startRetrospective(
teamId: $teamId
recurrenceSettings: $recurrenceSettings
gcalInput: $gcalInput
) {
startRetrospective(teamId: $teamId, name: $name, rrule: $rrule, gcalInput: $gcalInput) {
... on ErrorPayload {
error {
message
Expand Down
9 changes: 3 additions & 6 deletions packages/client/mutations/StartTeamPromptMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@ graphql`
const mutation = graphql`
mutation StartTeamPromptMutation(
$teamId: ID!
$recurrenceSettings: RecurrenceSettingsInput
$name: String
$rrule: RRule
$gcalInput: CreateGcalEventInput
) {
startTeamPrompt(
teamId: $teamId
recurrenceSettings: $recurrenceSettings
gcalInput: $gcalInput
) {
startTeamPrompt(teamId: $teamId, name: $name, rrule: $rrule, gcalInput: $gcalInput) {
... on ErrorPayload {
error {
message
Expand Down
7 changes: 2 additions & 5 deletions packages/client/mutations/UpdateRecurrenceSettingsMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ graphql`
`

const mutation = graphql`
mutation UpdateRecurrenceSettingsMutation(
$meetingId: ID!
$recurrenceSettings: RecurrenceSettingsInput!
) {
updateRecurrenceSettings(meetingId: $meetingId, recurrenceSettings: $recurrenceSettings) {
mutation UpdateRecurrenceSettingsMutation($meetingId: ID!, $name: String, $rrule: RRule) {
updateRecurrenceSettings(meetingId: $meetingId, name: $name, rrule: $rrule) {
... on ErrorPayload {
error {
message
Expand Down
58 changes: 49 additions & 9 deletions packages/server/__tests__/startRetrospective.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ test('Retro is named Retro #1 by default', async () => {

const newRetro = await sendPublic({
query: `
mutation StartRetrospectiveMutation($teamId: ID!, $recurrenceSettings: RecurrenceSettingsInput, $gcalInput: CreateGcalEventInput) {
startRetrospective(teamId: $teamId, recurrenceSettings: $recurrenceSettings, gcalInput: $gcalInput) {
mutation StartRetrospectiveMutation($teamId: ID!, $name: String, $rrule: RRule, $gcalInput: CreateGcalEventInput) {
startRetrospective(teamId: $teamId, name: $name, rrule: $rrule, gcalInput: $gcalInput) {
Dschoordsch marked this conversation as resolved.
Show resolved Hide resolved
... on ErrorPayload {
error {
message
Expand All @@ -34,7 +34,49 @@ test('Retro is named Retro #1 by default', async () => {
startRetrospective: {
meeting: {
id: expect.anything(),
name: 'Retro 1'
name: 'Retro #1'
}
}
}
})
})

test('Single Retro can be named', async () => {
await getRethink()
const {userId, authToken} = await signUp()
const {id: teamId} = (await getUserTeams(userId))[0]

const name = 'My Retro'
const newRetro = await sendPublic({
query: `
mutation StartRetrospectiveMutation($teamId: ID!, $name: String, $rrule: RRule, $gcalInput: CreateGcalEventInput) {
startRetrospective(teamId: $teamId, name: $name, rrule: $rrule, gcalInput: $gcalInput) {
... on ErrorPayload {
error {
message
}
}
... on StartRetrospectiveSuccess {
meeting {
id
name
}
}
}
}
`,
variables: {
teamId,
name
},
authToken
})
expect(newRetro).toMatchObject({
data: {
startRetrospective: {
meeting: {
id: expect.anything(),
name
}
}
}
Expand All @@ -49,8 +91,8 @@ test('Recurring retro is named like RetroSeries Jan 1', async () => {
const now = new Date()
const newRetro = await sendPublic({
query: `
mutation StartRetrospectiveMutation($teamId: ID!, $recurrenceSettings: RecurrenceSettingsInput, $gcalInput: CreateGcalEventInput) {
startRetrospective(teamId: $teamId, recurrenceSettings: $recurrenceSettings, gcalInput: $gcalInput) {
mutation StartRetrospectiveMutation($teamId: ID!, $name: String, $rrule: RRule, $gcalInput: CreateGcalEventInput) {
startRetrospective(teamId: $teamId, name: $name, rrule: $rrule, gcalInput: $gcalInput) {
... on ErrorPayload {
error {
message
Expand All @@ -67,10 +109,8 @@ test('Recurring retro is named like RetroSeries Jan 1', async () => {
`,
variables: {
teamId,
recurrenceSettings: {
rrule: 'DTSTART;TZID=Europe/Berlin:20240117T060000\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE',
name: 'RetroSeries'
}
rrule: 'DTSTART;TZID=Europe/Berlin:20240117T060000\nRRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE',
name: 'RetroSeries'
},
authToken
})
Expand Down
4 changes: 2 additions & 2 deletions packages/server/database/types/MeetingAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Input {
id?: string
teamId: string
meetingCount: number
name?: string
name: string
phases: [CheckInMeetingPhase, ...CheckInMeetingPhase[]]
facilitatorUserId: string
}
Expand All @@ -32,7 +32,7 @@ export default class MeetingAction extends Meeting {
phases,
facilitatorUserId,
meetingType: 'action',
name: name ?? `Check-in #${meetingCount + 1}`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think naming an instance is not part of the data type, but belongs into the mutation, so I moved it out consistently.

name
})
}
}
4 changes: 2 additions & 2 deletions packages/server/database/types/MeetingPoker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface Input {
id: string
teamId: string
meetingCount: number
name?: string
name: string
phases: [PokerPhase, ...PokerPhase[]]
facilitatorUserId: string
templateId: string
Expand All @@ -35,7 +35,7 @@ export default class MeetingPoker extends Meeting {
phases,
facilitatorUserId,
meetingType: 'poker',
name: name ?? `Sprint Poker #${meetingCount + 1}`
name
})
this.templateId = templateId
this.templateRefId = templateRefId
Expand Down
Loading
Loading