Skip to content
Open
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
18 changes: 18 additions & 0 deletions frontend/common/services/useChangeRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ export const changeRequestService = service
}),
transformResponse: (res, _, req) => transformCorePaging(req, res),
}),
getScheduledChangeRequests: builder.query<
Res['changeRequests'],
Req['getScheduledChangeRequests']
>({
providesTags: [{ id: 'LIST', type: 'ChangeRequest' }],
// Read the time per request, so a refetch after a commit uses the current time
query: ({ environmentId, ...rest }) => ({
url: `environments/${environmentId}/list-change-requests/?${Utils.toParam(
{
...rest,
committed: true,
live_from_after: new Date().toISOString(),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
},
)}`,
}),
transformResponse: (res, _, req) => transformCorePaging(req, res),
}),
updateChangeRequest: builder.mutation<
Res['updateChangeRequest'],
Req['updateChangeRequest']
Expand Down Expand Up @@ -112,6 +129,7 @@ export const {
useCreateEnvironmentChangeRequestMutation,
useDeleteChangeRequestMutation,
useGetChangeRequestsQuery,
useGetScheduledChangeRequestsQuery,
useUpdateChangeRequestMutation,
// END OF EXPORTS
} = changeRequestService
Expand Down
3 changes: 3 additions & 0 deletions frontend/common/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,9 @@ export type Req = {
live_from_after?: string
committed?: boolean
}>
getScheduledChangeRequests: PagedRequest<{
environmentId: string
}>
updateChangeRequest: ChangeRequest
getGroupSummaries: {
orgId: number
Expand Down
5 changes: 5 additions & 0 deletions frontend/e2e/tests/change-request-test.pw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ test.describe('Change Request Tests', () => {
log('Close modal')
await closeModal()

log('Verify the Scheduling link has no badge')
await expect(page.getByRole('link', { name: 'Scheduling' })).toHaveText(
'Scheduling',
)
Comment thread
talissoncosta marked this conversation as resolved.
Resolved

Comment thread
talissoncosta marked this conversation as resolved.
Resolved
log('Verify value has NOW changed (change request published)')
await gotoFeatures()
await page.reload({ waitUntil: 'domcontentloaded' })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React, { FC, useRef } from 'react'
import React, { FC } from 'react'
import Utils from 'common/utils/utils'
import Permission from 'common/providers/Permission'
import classNames from 'classnames'
import { useGetEnvironmentsQuery } from 'common/services/useEnvironment'
import SidebarLink from 'components/navigation/SidebarLink'
import { useGetChangeRequestsQuery } from 'common/services/useChangeRequest'
import {
useGetChangeRequestsQuery,
useGetScheduledChangeRequestsQuery,
} from 'common/services/useChangeRequest'
import { useExperimentationEnabled } from 'common/hooks/useExperimentationEnabled'

type EnvironmentNavType = {
Expand All @@ -20,19 +23,15 @@ const EnvironmentNavbar: FC<EnvironmentNavType> = ({
mobile,
projectId,
}) => {
const date = useRef(moment().toISOString())

const { data: environments } = useGetEnvironmentsQuery(
{
projectId: `${projectId}`,
},
{ skip: !projectId },
)

const { data: scheduledData } = useGetChangeRequestsQuery({
committed: true,
const { data: scheduledData } = useGetScheduledChangeRequestsQuery({
environmentId,
live_from_after: date.current,
page_size: 1,
})

Expand Down
23 changes: 11 additions & 12 deletions frontend/web/components/pages/ScheduledChangesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC, useEffect, useMemo, useState } from 'react'
import { FC, useEffect, useState } from 'react'
import moment from 'moment/moment'
import { useGetChangeRequestsQuery } from 'common/services/useChangeRequest'
import { useGetScheduledChangeRequestsQuery } from 'common/services/useChangeRequest'
import { RouterChildContext } from 'react-router'
import AccountStore from 'common/stores/account-store'
import { ChangeRequestSummary, User } from 'common/types/responses'
Expand Down Expand Up @@ -37,16 +37,15 @@ const ScheduledChangesPage: FC<ScheduledChangesPageType> = ({ match }) => {
const organisation = OrganisationStore.model as any
const users = organisation?.users as User[]

const live_from_after = useMemo(() => {
return new Date().toISOString()
}, [])
const { data: dataScheduled, isLoading } = useGetChangeRequestsQuery({
committed: true,
environmentId,
live_from_after,
page,
page_size: 50,
})
const { data: dataScheduled, isLoading } = useGetScheduledChangeRequestsQuery(
{
environmentId,
page,
page_size: 50,
},
// Same args on every visit, so refetch to drop changes that went live meanwhile
{ refetchOnMountOrArgChange: true },
Comment thread
talissoncosta marked this conversation as resolved.
Resolved
)
useEffect(() => {
AppActions.getOrganisation(organisationId)
}, [organisationId])
Expand Down
Loading