Skip to content

Commit

Permalink
address UI issue on Pre-live url (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
xdavidson authored May 24, 2021
1 parent 1515a53 commit 7d0e7f0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ exports[`ContentDisplay tests for Assembly should render ContentDisplay componen
<Versions
assemblies={Array []}
attributesFilePath=""
canRegeneratePortalUrl={[Function]}
contentType="module"
modulePath=""
onGetProduct={[Function]}
Expand Down Expand Up @@ -289,6 +290,7 @@ exports[`ContentDisplay tests for Module should render ModuleDisplay component 1
<Versions
assemblies={Array []}
attributesFilePath=""
canRegeneratePortalUrl={[Function]}
contentType="module"
modulePath=""
onGetProduct={[Function]}
Expand Down
18 changes: 17 additions & 1 deletion pantheon-bundle/frontend/src/app/contentDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IContentDisplayState {
assemblyData: any
firstPublishDate: string
lastPublishDate: string
regeneratePortalUrl: boolean
}

export interface IModuleDisplayState extends IContentDisplayState {
Expand Down Expand Up @@ -68,7 +69,8 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl
versionUrlFragment: "",
locale: "",
firstPublishDate: "",
lastPublishDate: ""
lastPublishDate: "",
regeneratePortalUrl: false
}
}

Expand All @@ -83,6 +85,15 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl

}

public componentDidUpdate(prevProps, prevState) {
if (prevState.regeneratePortalUrl !== this.state.regeneratePortalUrl) {
this.getPortalUrl(this.state.modulePath, this.state.variant)
if(this.state.regeneratePortalUrl === true){
this.setState({regeneratePortalUrl: false})
}
}
}

public render() {
return (
<React.Fragment>
Expand Down Expand Up @@ -222,6 +233,7 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl
onGetUrl={this.onGetUrl}
onGetProduct={this.getProduct}
onGetVersion={this.getVersion}
canRegeneratePortalUrl={this.canRegeneratePortalUrl}
/>
</Card>

Expand Down Expand Up @@ -511,6 +523,10 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl
})
}

private canRegeneratePortalUrl = (regeneratePortalUrl: boolean) => {
this.setState({regeneratePortalUrl})
}

}

export { ContentDisplay }
2 changes: 2 additions & 0 deletions pantheon-bundle/frontend/src/app/versions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const props = {
variant: "test",
variantUUID: "abcd-1234",
versionModulePath: "/modules/test_module/en_US/variants/test/draft",
canRegeneratePortalUrl: (regeneratePortalUrl) => anymatch
}

describe("Versions tests", () => {
Expand Down Expand Up @@ -199,6 +200,7 @@ describe("Versions tests", () => {
variant: "DEFAULT",
variantUUID: "abcd-1234",
versionModulePath: "versionPath",
canRegeneratePortalUrl:(regeneratePortalUrl) => anymatch
}
state.updateDate(1, "1234")
expect(state.modulePath).toEqual("somePath")
Expand Down
5 changes: 3 additions & 2 deletions pantheon-bundle/frontend/src/app/versions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface IProps {
updateDate: (releaseVersion, variantUUID) => any
onGetProduct: (productValue) => any
onGetVersion: (versionValue) => any
canRegeneratePortalUrl: (regeneratePortalUrl) => any
}

// Define properties in Metadata
Expand Down Expand Up @@ -562,7 +563,7 @@ class Versions extends Component<IProps, IState> {
canChangePublishState: true,
publishAlertVisible: false,
showMetadataAlertIcon: false
})
}, () => this.props.canRegeneratePortalUrl(true))
} else {
console.log(buttonText + " failed " + response.status)
this.setState({ publishAlertVisible: true })
Expand Down Expand Up @@ -638,7 +639,7 @@ class Versions extends Component<IProps, IState> {
canChangePublishState: true,
publishAlertVisible: false,
successAlertVisible: true,
})
}, () => this.props.canRegeneratePortalUrl(true))
if (this.state.metadataPath.endsWith("/draft")) {
this.setState({ showMetadataAlertIcon: false })
this.fetchVersions()
Expand Down

0 comments on commit 7d0e7f0

Please sign in to comment.