diff --git a/frontend/web/components/NewVersionWarning.tsx b/frontend/web/components/NewVersionWarning.tsx new file mode 100644 index 000000000000..409f3cd663b1 --- /dev/null +++ b/frontend/web/components/NewVersionWarning.tsx @@ -0,0 +1,39 @@ +import { FC, useMemo } from 'react' +import { useGetFeatureVersionsQuery } from 'common/services/useFeatureVersion' +import moment from 'moment' +import ErrorMessage from './ErrorMessage' // we need this to make JSX compile + +type NewVersionWarningType = { + date: string + featureId: number + environmentId: string +} + +const NewVersionWarning: FC = ({ + date, + environmentId, + featureId, +}) => { + const { data } = useGetFeatureVersionsQuery( + { environmentId, featureId, is_live: true, page_size: 1 }, + { refetchOnMountOrArgChange: true, skip: !environmentId || !featureId }, + ) + const compareDate = data?.results?.[0]?.live_from + const isNewVersion = useMemo(() => { + if (compareDate && date) { + if (moment(compareDate).valueOf() > moment(date).valueOf()) { + return true + } + } + return false + }, [compareDate, date]) + return isNewVersion ? ( +
+ +
+ ) : null +} + +export default NewVersionWarning diff --git a/frontend/web/components/pages/ChangeRequestPage.js b/frontend/web/components/pages/ChangeRequestPage.js index 579b3cc6c581..39a45eb455c4 100644 --- a/frontend/web/components/pages/ChangeRequestPage.js +++ b/frontend/web/components/pages/ChangeRequestPage.js @@ -21,6 +21,7 @@ import { IonIcon } from '@ionic/react' import Breadcrumb from 'components/Breadcrumb' import SettingsButton from 'components/SettingsButton' import DiffChangeRequest from 'components/diff/DiffChangeRequest' +import NewVersionWarning from 'components/NewVersionWarning' const ChangeRequestsPage = class extends Component { static displayName = 'ChangeRequestsPage' @@ -159,7 +160,13 @@ const ChangeRequestsPage = class extends Component { const changeRequest = ChangeRequestStore.model[id] const scheduledDate = this.getScheduledDate(changeRequest) const isScheduled = scheduledDate > moment() - + const featureId = + changeRequest && + changeRequest.feature_states[0] && + changeRequest.feature_states[0].feature + const environment = ProjectStore.getEnvironment( + this.props.match.params.environmentId, + ) openConfirm({ body: (
@@ -169,6 +176,11 @@ const ChangeRequestsPage = class extends Component { ? ` for ${scheduledDate.format('Do MMM YYYY hh:mma')}` : ''} ? This will adjust the feature for your environment. +
), onYes: () => { @@ -481,6 +493,12 @@ const ChangeRequestsPage = class extends Component { + + ( @@ -257,7 +257,7 @@ const ChangeRequestsPage = class extends Component { AppActions.getChangeRequests( this.props.match.params.environmentId, { committed: true }, - `${Project.api}environments/${environmentId}/list-change-requests/?page=${page}`, + `${Project.api}environments/${environmentId}/list-change-requests/?page=${page}&committed=1`, ) } renderFooter={() => ( diff --git a/frontend/web/components/pages/FeatureHistoryDetailPage.tsx b/frontend/web/components/pages/FeatureHistoryDetailPage.tsx index b57bbd0cac64..104892fba65d 100644 --- a/frontend/web/components/pages/FeatureHistoryDetailPage.tsx +++ b/frontend/web/components/pages/FeatureHistoryDetailPage.tsx @@ -50,6 +50,7 @@ const FeatureHistoryPage: FC = ({ match, router }) => { isLoading: versionsLoading, } = useGetFeatureVersionsQuery( { + is_live: true, environmentId, featureId: featureId as any, },