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

feat/image-quality-playback #1161

Merged
merged 29 commits into from
Dec 1, 2023
Merged

feat/image-quality-playback #1161

merged 29 commits into from
Dec 1, 2023

Conversation

ziggy-cyb
Copy link
Collaborator

Description

With new support for image quality checking for file upload, research suggests that users don't respond well to hard stops. To mitigate this, this feature implements a playback screen so the user has autonomy in deciding whether they want to continue and risk delaying their application or not.

How to enable

To use the new upload page controller, add a reference to the controller on the upload page in your form configuration, by adding "controller": "UploadPageController".

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce
the testing if necessary.

  • Manual testing with document upload api

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and versioning
  • I have updated the architecture diagrams as per Contribute.md OR added an architectural decision record entry

export function FileUploadFieldEdit() {
const { state, dispatch } = useContext(ComponentContext);
const { selectedComponent } = state;
const { options = {} } = selectedComponent;
const { options = defaultOptions } = selectedComponent;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd do

const options = { ...defaultOptions, ...selectedComponent.options }

e.g. if the default options were (truthy values is a better example)

{
   multiple: true,
   imageQualityPlayback: true,
}

and someone configured only

{
  multiple: false
}

you'd expect the options to be

{
   multiple: false,
   imageQualityPlayback: true,
}

but since options are no longer undefined, const { options = defaultOptions } = selectedComponent, = defaultOptions won't be applied, and imageQualityPlayback will evaluate to falsy in this case.

It's fine in this case since the defaults are both falsy, but when you have more options or options with a mixture of defined/truthy values this wont work as intended.

savedState
);

if (request?.pre?.warningFromApi === "qualityWarning") {
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this set? should the pre handler just do a response takeover and return the response itself?

@ziggy-cyb ziggy-cyb force-pushed the feat/image-quality-playback branch from 06477e6 to ab3aab9 Compare November 24, 2023 14:27
Comment on lines 791 to 804
viewModel.backLink = progress[progress.length - 2];
viewModel.backLink = progress[progress.length - 2] ?? this.backLinkFallback;
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need to declare twice?

let error: string | undefined;
let location: string | undefined;
console.log("This is the payload", warningFromApi);
Copy link
Contributor

Choose a reason for hiding this comment

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

console.log

@@ -16,6 +16,8 @@ export function optionsReducer(state, action: OptionsActions) {
const { type, payload } = action;
const { selectedComponent } = state;
const { options } = selectedComponent;
console.log("reducer type: ", type);
Copy link
Contributor

Choose a reason for hiding this comment

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

logs

}

buildRadioViewModel(error?: string) {
const standardViewModel = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably set this to the class itself, otherwise it's going to create this object every time buildRadioViewModel is called

@@ -95,6 +95,7 @@ export class UploadService {
return {
location,
error,
warningFromApi,
Copy link
Contributor

Choose a reason for hiding this comment

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

fromApi is already implied for the other values, just warning is fine

@ziggy-cyb ziggy-cyb force-pushed the feat/image-quality-playback branch from eadc583 to a72660a Compare November 27, 2023 15:54
import { HapiRequest, HapiResponseToolkit } from "server/types";
export class PlaybackUploadPageController extends PageController {
inputComponent: FormComponent;
standardViewModel = {
Copy link
Contributor

Choose a reason for hiding this comment

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

retryUploadViewModel - standardViewModel/standard by itself doesn't convey enough information

const state = await cacheService.getState(request);
const { progress = [] } = state;
const payload = request.payload;
if (!payload.retryUpload) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we do a joi validation here?

@ziggy-cyb ziggy-cyb merged commit 0b3c792 into main Dec 1, 2023
12 checks passed
@ziggy-cyb ziggy-cyb deleted the feat/image-quality-playback branch December 1, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants