Skip to content

Commit 8ca89ab

Browse files
author
Michał Grabowski
authored
EZP-31070: Missing message in Browse tab in UDW when starting location is empty (#284)
1 parent 7db1c4a commit 8ca89ab

File tree

5 files changed

+104
-13
lines changed

5 files changed

+104
-13
lines changed

Resources/public/scss/modules/universal-discovery/_bookmarks.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
padding-top: calculateRem(15px);
88
padding-left: calculateRem(20px);
99
font-size: calculateRem(25px);
10-
color: #a6a6a6;
10+
color: $ez-color-base-light;
1111
}
1212

1313
&__loading-spinner {

Resources/public/scss/modules/universal-discovery/_finder.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@
88
margin-left: calculateRem(16px);
99
}
1010
}
11+
12+
&__no-content-info {
13+
padding-top: calculateRem(39px);
14+
padding-left: calculateRem(36px);
15+
font-size: calculateRem(25px);
16+
color: $ez-color-base-light;
17+
}
1118
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
3+
<file source-language="en" target-language="en" datatype="plaintext" original="not.available">
4+
<header>
5+
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
6+
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
7+
</header>
8+
<body>
9+
<trans-unit id="8c11cc36acf58db9ff898f3a4cf02fd0fc293f67" resname="search.no_result">
10+
<source>Sorry, no results were found for "%query%".</source>
11+
<target state="new">Sorry, no results were found for "%query%".</target>
12+
<note>key: search.no_result</note>
13+
</trans-unit>
14+
<trans-unit id="777cc1ef279096d5a978aa3553e9434d828f8248" resname="search.tips.check_spelling">
15+
<source>Check spelling of keywords.</source>
16+
<target state="new">Check spelling of keywords.</target>
17+
<note>key: search.tips.check_spelling</note>
18+
</trans-unit>
19+
<trans-unit id="d89a8ff5c4b03f1dd7bd1ce3e3306862e1855751" resname="search.tips.different_keywords">
20+
<source>Try different keywords.</source>
21+
<target state="new">Try different keywords.</target>
22+
<note>key: search.tips.different_keywords</note>
23+
</trans-unit>
24+
<trans-unit id="013ced9a3284ecebf5a5356397dc9a79eaf76496" resname="search.tips.fewer_keywords">
25+
<source>Try fewer keywords. Reducing keywords result in more matches.</source>
26+
<target state="new">Try fewer keywords. Reducing keywords result in more matches.</target>
27+
<note>key: search.tips.fewer_keywords</note>
28+
</trans-unit>
29+
<trans-unit id="4af1e76946070e5f61320621d12a171f4206e06c" resname="search.tips.headline">
30+
<source>Some helpful search tips:</source>
31+
<target state="new">Some helpful search tips:</target>
32+
<note>key: search.tips.headline</note>
33+
</trans-unit>
34+
<trans-unit id="dd61516edc919235a13e3cfadb5d961b8614b744" resname="search.tips.more_general_keywords">
35+
<source>Try more general keywords.</source>
36+
<target state="new">Try more general keywords.</target>
37+
<note>key: search.tips.more_general_keywords</note>
38+
</trans-unit>
39+
</body>
40+
</file>
41+
</xliff>

Resources/translations/universal_discovery_widget.en.xliff

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136
<target state="new">Load more</target>
137137
<note>key: finder.branch.load_more.label</note>
138138
</trans-unit>
139+
<trans-unit id="542b481fc08d900847ee1107c576cd6b4678a52c" resname="finder.no_content.message">
140+
<source>No content items.</source>
141+
<target state="new">No content items.</target>
142+
<note>key: finder.no_content.message</note>
143+
</trans-unit>
139144
<trans-unit id="fa6baf070f27f737433a162bd6411f4a216d46c0" resname="pagination.first">
140145
<source>First</source>
141146
<target state="new">First</target>

src/modules/universal-discovery/components/finder/finder.component.js

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export default class FinderComponent extends Component {
2424
this.loadBranchLeaves = this.loadBranchLeaves.bind(this);
2525
this.onLoadMore = this.onLoadMore.bind(this);
2626
this.renderBranch = this.renderBranch.bind(this);
27+
this.renderActiveLocations = this.renderActiveLocations.bind(this);
28+
this.renderBranches = this.renderBranches.bind(this);
2729
this.setBranchContainerRef = this.setBranchContainerRef.bind(this);
2830
this.setPreselectedState = this.getPreselectedState.bind(this);
2931

@@ -450,6 +452,53 @@ export default class FinderComponent extends Component {
450452
);
451453
}
452454

455+
renderActiveLocations() {
456+
const { activeLocations, locationsMap } = this.state;
457+
458+
return activeLocations.map((location, index) => {
459+
const locationId = location ? location.id : this.props.startingLocationId;
460+
const branchActiveLocation = activeLocations[index + 1];
461+
const branchActiveLocationId = branchActiveLocation ? branchActiveLocation.id : null;
462+
const isBranchActiveLocationLoading = branchActiveLocationId && !locationsMap[branchActiveLocationId];
463+
const locationData = locationsMap[locationId];
464+
465+
return this.renderBranch(locationData, branchActiveLocationId, isBranchActiveLocationLoading);
466+
});
467+
}
468+
469+
renderEmptyContent() {
470+
const noContentMessage = Translator.trans(
471+
/*@Desc("No content items.")*/ 'finder.no_content.message',
472+
{},
473+
'universal_discovery_widget'
474+
);
475+
476+
return <div className="c-finder__no-content-info">{noContentMessage}</div>;
477+
}
478+
479+
renderBranches() {
480+
const { activeLocations } = this.state;
481+
const branches = [
482+
this.renderStartingLocationBranch(),
483+
...this.renderActiveLocations(),
484+
];
485+
const hasActiveLocations = activeLocations.some((location) => location);
486+
const hasNonEmptyBranches = branches.every((branch) => !branch);
487+
488+
if (hasActiveLocations && hasNonEmptyBranches) {
489+
const noContentMessage = Translator.trans(
490+
/*@Desc("No content items.")*/ 'finder.no_content.message',
491+
{},
492+
'universal_discovery_widget'
493+
);
494+
495+
return <div className="c-finder__no-content-info">{noContentMessage}</div>;
496+
}
497+
498+
return branches;
499+
500+
}
501+
453502
setBranchContainerRef(ref) {
454503
this._refBranchesContainer = ref;
455504
}
@@ -461,21 +510,10 @@ export default class FinderComponent extends Component {
461510
return null;
462511
}
463512

464-
const { locationsMap } = this.state;
465-
466513
return (
467514
<div className="c-finder">
468515
<div className="c-finder__branches" style={{ height: `${this.props.maxHeight}px` }} ref={this.setBranchContainerRef}>
469-
{this.renderStartingLocationBranch()}
470-
{activeLocations.map((location, index) => {
471-
const locationId = location ? location.id : this.props.startingLocationId;
472-
const branchActiveLocation = activeLocations[index + 1];
473-
const branchActiveLocationId = branchActiveLocation ? branchActiveLocation.id : null;
474-
const isBranchActiveLocationLoading = branchActiveLocationId && !locationsMap[branchActiveLocationId];
475-
const locationData = locationsMap[locationId];
476-
477-
return this.renderBranch(locationData, branchActiveLocationId, isBranchActiveLocationLoading);
478-
})}
516+
{this.renderBranches()}
479517
</div>
480518
</div>
481519
);

0 commit comments

Comments
 (0)