Skip to content

Commit

Permalink
revert: CCS 3861 , hold for release (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
rednitish authored Mar 2, 2021
1 parent 2a0166b commit 94c58d1
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
30 changes: 22 additions & 8 deletions pantheon-bundle/frontend/src/app/contentDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl
attributesFilePath={this.state.attributesFilePath}
assemblies={this.state.assemblyData}
updateDate={this.updateDate}
onGetUrl={this.onGetUrl}
onGetProduct={this.getProduct}
onGetVersion={this.getVersion}
onPublishEvent={this.onPublishEvent}
/>
</Card>

Expand All @@ -238,8 +238,8 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl
releaseVersion,
})
}


private fetchModuleDetails = async (data) => {
console.log(data)
await this.getVariantParam()
Expand Down Expand Up @@ -324,11 +324,11 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl
this.setState({ versionValue: version })
}

private onGetUrl = (url) => {
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) =>{
Expand Down Expand Up @@ -407,6 +407,13 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl
for (const productVersion of productChild.__children__) {
if (productVersion[Fields.JCR_UUID] === uuid) {
this.setState({ productValue: product.name, versionValue: productVersion.name, productUrlFragment: product.urlFragment, versionUrlFragment: productVersion.urlFragment })
const isGuideOrTopic = this.isAssembly ? '/guide/' : '/topic/'
const url = this.state.portalHostUrl + '/documentation/'+this.state.locale.toLocaleLowerCase()+'/' + this.state.productUrlFragment + '/' + this.state.versionUrlFragment + isGuideOrTopic + this.state.variantUUID
console.log("Constructed url="+url)
if(this.state.productUrlFragment!==""){
this.setState({ portalUrl: url})
}
break
}
}
}
Expand Down Expand Up @@ -441,8 +448,15 @@ class ContentDisplay extends Component<any, IModuleDisplayState | IAssemblyDispl
// get portal url from api and set it only if it is not empty
if(text.trim() !== "") {
this.setState({portalUrl: text})
}else{
// if portal url is empty, assemble the URL at client side
console.log("GetPortalURI API returned empty URI. Falling back to url construction at UI")
this.getVersionUUID(this.props.location.pathname)
}
})
}else {
console.log("GetPortalURI API returned error. Falling back to url construction at UI")
this.getVersionUUID(this.props.location.pathname)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions pantheon-bundle/frontend/src/app/versions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ const props = {
modulePath: "/modules/test",
onGetProduct: (productValue) => 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", () => {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -277,4 +277,4 @@ describe("Versions tests", () => {
inst.setAlertTitle()
sinon.assert.called(spy)
})
})
})
7 changes: 4 additions & 3 deletions pantheon-bundle/frontend/src/app/versions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -511,11 +511,13 @@ class Versions extends Component<IProps, IState> {
// 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",
Expand All @@ -530,13 +532,12 @@ class Versions extends Component<IProps, IState> {
}).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 })
Expand Down

0 comments on commit 94c58d1

Please sign in to comment.