Skip to content

Commit 73e244f

Browse files
authored
[UI] Render new lines in package description (loic-sharma#374)
Addresses loic-sharma#327
1 parent c937096 commit 73e244f

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

src/BaGet.UI/src/DisplayPackage/Dependents.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class Dependents extends React.Component<IDependentsProps, IDependentsState> {
3535
fetch(url, {signal: this.controller.signal}).then(response => {
3636
return response.json();
3737
}).then(json => {
38-
// tslint:disable-next-line:no-console
39-
console.log(json as IDependentsState);
4038
this.setState(json as IDependentsState);
4139
// tslint:disable-next-line:no-console
4240
}).catch((e) => console.log("Failed to load dependents.", e));
@@ -58,7 +56,7 @@ class Dependents extends React.Component<IDependentsProps, IDependentsState> {
5856
<div>
5957
<h3>Dependents</h3>
6058

61-
<div>No packages depend on {this.props.packageId}</div>
59+
<div>No packages depend on {this.props.packageId}.</div>
6260
</div>
6361
);
6462
}

src/BaGet.UI/src/DisplayPackage/DisplayPackage.css

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
font-size: 45%;
1313
}
1414

15+
.display-package .package-description {
16+
white-space: pre-wrap;
17+
}
18+
1519
.package-details-info {
1620
margin-top: -25px;
1721
}

src/BaGet.UI/src/DisplayPackage/DisplayPackage.tsx

+16-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ interface IDisplayPackageProps {
2525
interface IPackage {
2626
id: string;
2727
latestVersion: string;
28+
hasReadme: boolean;
29+
description: string;
2830
readme: string;
2931
lastUpdate: Date;
3032
iconUrl: string;
@@ -137,10 +139,6 @@ class DisplayPackage extends React.Component<IDisplayPackageProps, IDisplayPacka
137139

138140
if (currentItem && lastUpdate) {
139141
let readme = "";
140-
if (!currentItem.catalogEntry.hasReadme) {
141-
readme = currentItem.catalogEntry.description;
142-
}
143-
144142
const isDotnetTool = (currentItem.catalogEntry.packageTypes &&
145143
currentItem.catalogEntry.packageTypes.indexOf("DotnetTool") !== -1);
146144

@@ -205,8 +203,20 @@ class DisplayPackage extends React.Component<IDisplayPackageProps, IDisplayPacka
205203

206204
<InstallationInfo id={this.state.package.id} version={this.state.package.normalizedVersion} isDotnetTool={this.state.package.isDotnetTool} />
207205

208-
{/* TODO: Fix this */}
209-
<div dangerouslySetInnerHTML={{ __html: this.state.package.readme }} />
206+
{(() => {
207+
if (this.state.package.hasReadme) {
208+
// TODO: Fix this
209+
return (
210+
<div dangerouslySetInnerHTML={{ __html: this.state.package.readme }} />
211+
);
212+
} else {
213+
return (
214+
<div className="package-description">
215+
{this.state.package.description}
216+
</div>
217+
);
218+
}
219+
})()}
210220

211221
<Dependents packageId={this.id} />
212222
<Dependencies dependencyGroups={this.state.package.dependencyGroups} />

src/BaGet.UI/src/DisplayPackage/InstallationInfo.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class InstallationInfo extends React.Component<IInstallationInfoProps, IInstalla
2929
constructor(props: IInstallationInfoProps) {
3030
super(props);
3131

32-
// tslint:disable-next-line:no-console
33-
console.log(props);
3432
this.state = props.isDotnetTool
3533
? this.buildState(Tab.DotnetTool)
3634
: this.buildState(Tab.Dotnet);

0 commit comments

Comments
 (0)