diff --git a/pantheon-bundle/frontend/src/app/__snapshots__/contentDisplay.test.tsx.snap b/pantheon-bundle/frontend/src/app/__snapshots__/contentDisplay.test.tsx.snap index b8f1c51aa..6e59f179e 100644 --- a/pantheon-bundle/frontend/src/app/__snapshots__/contentDisplay.test.tsx.snap +++ b/pantheon-bundle/frontend/src/app/__snapshots__/contentDisplay.test.tsx.snap @@ -158,8 +158,8 @@ exports[`ContentDisplay tests for Assembly should render ContentDisplay componen contentType="module" modulePath="" onGetProduct={[Function]} - onGetUrl={[Function]} onGetVersion={[Function]} + onPublishEvent={[Function]} productInfo="" updateDate={[Function]} variant="DEFAULT" @@ -338,8 +338,8 @@ exports[`ContentDisplay tests for Module should render ModuleDisplay component 1 contentType="module" modulePath="" onGetProduct={[Function]} - onGetUrl={[Function]} onGetVersion={[Function]} + onPublishEvent={[Function]} productInfo="" updateDate={[Function]} variant="DEFAULT" diff --git a/pantheon-bundle/frontend/src/app/contentDisplay.tsx b/pantheon-bundle/frontend/src/app/contentDisplay.tsx index 1c151719d..b9397cecf 100644 --- a/pantheon-bundle/frontend/src/app/contentDisplay.tsx +++ b/pantheon-bundle/frontend/src/app/contentDisplay.tsx @@ -214,9 +214,9 @@ class ContentDisplay extends Component @@ -238,8 +238,8 @@ class ContentDisplay extends Component { console.log(data) await this.getVariantParam() @@ -324,11 +324,11 @@ class ContentDisplay extends Component { - console.log("Received url="+url) - if(this.state.productUrlFragment!==""){ - this.setState({ portalUrl: url}) - } + private onPublishEvent = () => { + // the published state cannot be ascertained correctly when moving from one page to another + const path = this.props.location.pathname.substring(this.isAssembly ? PathPrefixes.ASSEBMLY_PATH_PREFIX.length : PathPrefixes.MODULE_PATH_PREFIX.length) + this.getPortalUrl(path, this.state.variant) + } private getLocale = (path) =>{ @@ -407,6 +407,13 @@ class ContentDisplay extends Component anymatch, onGetVersion: (versionValue) => anymatch, - onGetUrl: (url) => anymatch, productInfo: "Red Hat Enterprise Linux", updateDate: (draftUpdateDate, releaseUpdateDate, releaseVersion, variantUUID) => anymatch, variant: "test", variantUUID: "abcd-1234", versionModulePath: "/modules/test_module/en_US/variants/test/draft", + onPublishEvent: () => anymatch } describe("Versions tests", () => { @@ -193,12 +193,12 @@ describe("Versions tests", () => { modulePath: "somePath", onGetProduct: (productValue) => anymatch, onGetVersion: (versionValue) => anymatch, - onGetUrl: (url) => anymatch, productInfo: "Red Hat Enterprise Linux", updateDate: (draftUpdateDate, releaseUpdateDate, releaseVersion, variantUUID) => anymatch, variant: "DEFAULT", variantUUID: "abcd-1234", versionModulePath: "versionPath", + onPublishEvent: () => anymatch } state.updateDate("-", "-", 1, "1234") expect(state.modulePath).toEqual("somePath") @@ -277,4 +277,4 @@ describe("Versions tests", () => { inst.setAlertTitle() sinon.assert.called(spy) }) -}) +}) \ No newline at end of file diff --git a/pantheon-bundle/frontend/src/app/versions.tsx b/pantheon-bundle/frontend/src/app/versions.tsx index 5c41b76f5..98de429fe 100644 --- a/pantheon-bundle/frontend/src/app/versions.tsx +++ b/pantheon-bundle/frontend/src/app/versions.tsx @@ -28,10 +28,10 @@ export interface IProps { variantUUID: string attributesFilePath: string assemblies?: any - onGetUrl: (url) => any updateDate: (draftUpdateDate, releaseUpdateDate, releaseVersion, variantUUID) => any onGetProduct: (productValue) => any onGetVersion: (versionValue) => any + onPublishEvent: () => void } // Define properties in Metadata @@ -511,11 +511,13 @@ class Versions extends Component { // console.log("Published file path:", this.props.modulePath) this.draft[0].version = ""; this.setState({ unpublishAlertForModuleVisible: false }) + this.props.onPublishEvent() } else { formData.append(":operation", "pant:unpublish"); // console.log("Unpublished file path:", this.props.modulePath); this.release[0].version = ""; this.setState({ unpublishAlertForModuleVisible: true }) + this.props.onPublishEvent() } const hdrs = { "Accept": "application/json", @@ -530,13 +532,12 @@ class Versions extends Component { }).then(response => { if (response.status === 201 || response.status === 200) { console.log(buttonText + " works: " + response.status) - console.log(" response is : " + response.url) - this.props.onGetUrl(response.url) this.setState({ canChangePublishState: true, publishAlertVisible: false, showMetadataAlertIcon: false }) + this.props.onPublishEvent() } else { console.log(buttonText + " failed " + response.status) this.setState({ publishAlertVisible: true })