diff --git a/static/js/publisher/listing/components/ListingForm/ListingForm.tsx b/static/js/publisher/listing/components/ListingForm/ListingForm.tsx index 1f2dd2ba53..23ee90fca0 100644 --- a/static/js/publisher/listing/components/ListingForm/ListingForm.tsx +++ b/static/js/publisher/listing/components/ListingForm/ListingForm.tsx @@ -44,6 +44,9 @@ function ListingForm({ data, refetch }: Props): JSX.Element { const [showSuccessNotification, setShowSuccessNotification] = useState(false); + const [showUpdateMetadataMessage, setShowUpdateMetadataMessage] = + useState(false); + const [updateMetadataOnRelease, setUpdateMetadataOnRelease] = useState(data.update_metadata_on_release); @@ -51,7 +54,7 @@ function ListingForm({ data, refetch }: Props): JSX.Element { useState(false); const [formValues, setFormValues] = useState<{ [key: string]: any } | null>( - null + null, ); const { mutate, isLoading } = useMutateListingData({ @@ -64,11 +67,12 @@ function ListingForm({ data, refetch }: Props): JSX.Element { setUpdateMetadataOnRelease, shouldShowUpdateMetadataWarning, snapName, + setShowUpdateMetadataMessage, }); useEffect(() => { const tourContainer = document.getElementById( - "tour-container" + "tour-container", ) as HTMLElement; if (snapName) { @@ -157,6 +161,14 @@ function ListingForm({ data, refetch }: Props): JSX.Element { )} + {showUpdateMetadataMessage && ( + + + Metadata updates will be processed and applied shortly + + + )} + { setUpdateMetadataOnRelease: jest.fn(), shouldShowUpdateMetadataWarning: jest.fn(), snapName: "test-snap", - }) + setShowUpdateMetadataMessage: jest.fn(), + }), ); expect(ReactQuery.useMutation).toHaveBeenCalled(); }); diff --git a/static/js/publisher/listing/hooks/useMutateListingData.ts b/static/js/publisher/listing/hooks/useMutateListingData.ts index 441940653c..47ad1f6d18 100644 --- a/static/js/publisher/listing/hooks/useMutateListingData.ts +++ b/static/js/publisher/listing/hooks/useMutateListingData.ts @@ -14,6 +14,7 @@ type Options = { setUpdateMetadataOnRelease: Function; shouldShowUpdateMetadataWarning: Function; snapName: string | undefined; + setShowUpdateMetadataMessage: Function; }; function useMutateListingData({ @@ -26,6 +27,7 @@ function useMutateListingData({ setUpdateMetadataOnRelease, shouldShowUpdateMetadataWarning, snapName, + setShowUpdateMetadataMessage, }: Options) { return useMutation({ mutationFn: async (values: any) => { @@ -53,7 +55,7 @@ function useMutateListingData({ formData.append("screenshots", newFile); const imageIndex = changes.images.findIndex( - (image: any) => image.name === oldName + (image: any) => image.name === oldName, ); changes.images[imageIndex].name = newFile.name; changes.images[imageIndex].url = URL.createObjectURL(newFile); @@ -75,6 +77,12 @@ function useMutateListingData({ if (!response.ok) { throw new Error("There was a problem saving listing data"); } + + const responseData = await response.json(); + + if (!responseData.data.text_fields_updated) { + setShowUpdateMetadataMessage(true); + } }, onSuccess: async () => { setShowSuccessNotification(true); diff --git a/webapp/publisher/snaps/listing_views.py b/webapp/publisher/snaps/listing_views.py index 38dde97413..59c160e357 100644 --- a/webapp/publisher/snaps/listing_views.py +++ b/webapp/publisher/snaps/listing_views.py @@ -174,6 +174,7 @@ def get_listing_snap(snap_name): @login_required def post_listing_data(snap_name): + res = {} changes = None changed_fields = flask.request.form.get("changes") @@ -230,7 +231,11 @@ def post_listing_data(snap_name): ) try: - publisher_api.snap_metadata(snap_id, flask.session, body_json) + response = publisher_api.snap_metadata( + snap_id, flask.session, body_json + ) + res["success"] = True + res["data"] = response except StoreApiResponseErrorList as api_response_error_list: if api_response_error_list.status_code != 404: error_list = error_list + api_response_error_list.errors @@ -266,7 +271,7 @@ def post_listing_data(snap_name): return flask.make_response(res, 200) - return flask.make_response({}, 200) + return flask.make_response(res, 200) @login_required