-
Notifications
You must be signed in to change notification settings - Fork 5
EES-5934 Fixing Admin Public API Data Set Changelog page #5705
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AutoMapper; | ||
using GovUk.Education.ExploreEducationStatistics.Admin.Requests.Public.Data; | ||
using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces.Public.Data; | ||
using GovUk.Education.ExploreEducationStatistics.Admin.Services.Interfaces.Security; | ||
|
@@ -32,7 +33,8 @@ public class DataSetVersionService( | |
PublicDataDbContext publicDataDbContext, | ||
IProcessorClient processorClient, | ||
IPublicDataApiClient publicDataApiClient, | ||
IUserService userService) | ||
IUserService userService, | ||
IMapper mapper) | ||
: IDataSetVersionService | ||
{ | ||
public async Task<Either<ActionResult, PaginatedListViewModel<DataSetLiveVersionSummaryViewModel>>> | ||
|
@@ -73,6 +75,31 @@ public async Task<Either<ActionResult, PaginatedListViewModel<DataSetLiveVersion | |
}); | ||
} | ||
|
||
public async Task<Either<ActionResult, DataSetVersionInfoViewModel>> GetDataSetVersion( | ||
Guid dataSetVersionId, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
return await userService.CheckIsBauUser() | ||
.OnSuccess(async () => await GetVersion( | ||
dataSetVersionId: dataSetVersionId, | ||
cancellationToken: cancellationToken)) | ||
.OnSuccess(mapper.Map<DataSetVersionInfoViewModel>); | ||
} | ||
|
||
public async Task<Either<ActionResult, DataSetVersion>> GetDataSetVersion( | ||
Guid dataSetId, | ||
SemVersion version, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
return await publicDataDbContext.DataSetVersions | ||
.AsNoTracking() | ||
.Include(dsv => dsv.DataSet) | ||
.Where(dsv => dsv.DataSetId == dataSetId) | ||
.Where(dsv => dsv.VersionMajor == version.Major) | ||
.Where(dsv => dsv.VersionMinor == version.Minor) | ||
.SingleOrNotFoundAsync(cancellationToken); | ||
} | ||
|
||
public async Task<List<DataSetVersionStatusSummary>> GetStatusesForReleaseVersion( | ||
Guid releaseVersionId, | ||
CancellationToken cancellationToken = default) | ||
|
@@ -129,20 +156,6 @@ public async Task<Either<ActionResult, DataSetVersionSummaryViewModel>> Complete | |
.OnSuccess(async dataSetVersion => await MapDraftVersionSummary(dataSetVersion, cancellationToken)); | ||
} | ||
|
||
public async Task<Either<ActionResult, DataSetVersion>> GetDataSetVersion( | ||
Guid dataSetId, | ||
SemVersion version, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
return await publicDataDbContext.DataSetVersions | ||
.AsNoTracking() | ||
.Include(dsv => dsv.DataSet) | ||
.Where(dsv => dsv.DataSetId == dataSetId) | ||
.Where(dsv => dsv.VersionMajor == version.Major) | ||
.Where(dsv => dsv.VersionMinor == version.Minor) | ||
.SingleOrNotFoundAsync(cancellationToken); | ||
} | ||
|
||
public async Task<Either<ActionResult, Unit>> DeleteVersion( | ||
Guid dataSetVersionId, | ||
CancellationToken cancellationToken = default) | ||
|
@@ -175,7 +188,7 @@ public async Task<Either<ActionResult, DataSetDraftVersionViewModel>> UpdateVers | |
CancellationToken cancellationToken = default) | ||
{ | ||
return await userService.CheckIsBauUser() | ||
.OnSuccess(async () => await GetDataSetVersion( | ||
.OnSuccess(async () => await GetVersion( | ||
dataSetVersionId: dataSetVersionId, | ||
cancellationToken: cancellationToken)) | ||
.OnSuccessDo(dataSetVersion => CheckCanUpdateVersion(dataSetVersion, updateRequest)) | ||
|
@@ -267,7 +280,7 @@ private async Task<DataSetVersionSummaryViewModel> MapDraftVersionSummary( | |
}; | ||
} | ||
|
||
private async Task<Either<ActionResult, DataSetVersion>> GetDataSetVersion( | ||
private async Task<Either<ActionResult, DataSetVersion>> GetVersion( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this naming makes sense as it isn't returning a version. |
||
Guid dataSetVersionId, | ||
CancellationToken cancellationToken) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ import { useQuery } from '@tanstack/react-query'; | |
import { generatePath, useParams } from 'react-router-dom'; | ||
import React, { useEffect } from 'react'; | ||
import WarningMessage from '@common/components/WarningMessage'; | ||
import { DataSetVersionStatus } from '@admin/services/apiDataSetService'; | ||
|
||
const dataSetVersionIsDraft = (dataSetVersionStatus: DataSetVersionStatus) => | ||
dataSetVersionStatus === 'Draft'; | ||
Comment on lines
+25
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: seems a bit verbose, where we set isDraft this is fine |
||
|
||
export default function ReleaseApiDataSetChangelogPage() { | ||
const { dataSetId, dataSetVersionId, releaseVersionId, publicationId } = | ||
|
@@ -31,18 +35,20 @@ export default function ReleaseApiDataSetChangelogPage() { | |
refetch: refetchDataSet, | ||
} = useQuery(apiDataSetQueries.get(dataSetId)); | ||
|
||
const { data: dataSetVersion, isLoading: isLoadingDataSetVersion } = useQuery( | ||
apiDataSetVersionQueries.getVersion(dataSetVersionId), | ||
); | ||
|
||
const { data: changes, isLoading: isLoadingChanges } = useQuery( | ||
apiDataSetVersionQueries.getChanges(dataSetVersionId), | ||
); | ||
|
||
const isDraft = dataSet?.draftVersion?.id === dataSetVersionId; | ||
const isDraft = dataSetVersion | ||
? dataSetVersionIsDraft(dataSetVersion.status) | ||
: false; | ||
|
||
const [showForm, toggleShowForm] = useToggle(false); | ||
|
||
const dataSetVersion = isDraft | ||
? dataSet?.draftVersion | ||
: dataSet?.latestLiveVersion; | ||
|
||
useEffect(() => { | ||
if (isDraft && !dataSetVersion?.notes) { | ||
toggleShowForm.on(); | ||
|
@@ -76,7 +82,11 @@ export default function ReleaseApiDataSetChangelogPage() { | |
Back to API data set details | ||
</Link> | ||
|
||
<LoadingSpinner loading={isLoadingDataSet || isLoadingChanges}> | ||
<LoadingSpinner | ||
loading={ | ||
isLoadingDataSet || isLoadingDataSetVersion || isLoadingChanges | ||
} | ||
> | ||
{dataSet && dataSetVersion ? ( | ||
<> | ||
<div className="govuk-grid-row"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't want to call this
GetDataSetVersionInfo
?