Skip to content

Commit

Permalink
EZP-31070: Missing message in Browse tab in UDW when starting locatio…
Browse files Browse the repository at this point in the history
…n is empty (#284)
  • Loading branch information
Michał Grabowski authored Mar 31, 2020
1 parent 7db1c4a commit 8ca89ab
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
padding-top: calculateRem(15px);
padding-left: calculateRem(20px);
font-size: calculateRem(25px);
color: #a6a6a6;
color: $ez-color-base-light;
}

&__loading-spinner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@
margin-left: calculateRem(16px);
}
}

&__no-content-info {
padding-top: calculateRem(39px);
padding-left: calculateRem(36px);
font-size: calculateRem(25px);
color: $ez-color-base-light;
}
}
41 changes: 41 additions & 0 deletions Resources/translations/search.en.xliff
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<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>
</header>
<body>
<trans-unit id="8c11cc36acf58db9ff898f3a4cf02fd0fc293f67" resname="search.no_result">
<source>Sorry, no results were found for "%query%".</source>
<target state="new">Sorry, no results were found for "%query%".</target>
<note>key: search.no_result</note>
</trans-unit>
<trans-unit id="777cc1ef279096d5a978aa3553e9434d828f8248" resname="search.tips.check_spelling">
<source>Check spelling of keywords.</source>
<target state="new">Check spelling of keywords.</target>
<note>key: search.tips.check_spelling</note>
</trans-unit>
<trans-unit id="d89a8ff5c4b03f1dd7bd1ce3e3306862e1855751" resname="search.tips.different_keywords">
<source>Try different keywords.</source>
<target state="new">Try different keywords.</target>
<note>key: search.tips.different_keywords</note>
</trans-unit>
<trans-unit id="013ced9a3284ecebf5a5356397dc9a79eaf76496" resname="search.tips.fewer_keywords">
<source>Try fewer keywords. Reducing keywords result in more matches.</source>
<target state="new">Try fewer keywords. Reducing keywords result in more matches.</target>
<note>key: search.tips.fewer_keywords</note>
</trans-unit>
<trans-unit id="4af1e76946070e5f61320621d12a171f4206e06c" resname="search.tips.headline">
<source>Some helpful search tips:</source>
<target state="new">Some helpful search tips:</target>
<note>key: search.tips.headline</note>
</trans-unit>
<trans-unit id="dd61516edc919235a13e3cfadb5d961b8614b744" resname="search.tips.more_general_keywords">
<source>Try more general keywords.</source>
<target state="new">Try more general keywords.</target>
<note>key: search.tips.more_general_keywords</note>
</trans-unit>
</body>
</file>
</xliff>
5 changes: 5 additions & 0 deletions Resources/translations/universal_discovery_widget.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
<target state="new">Load more</target>
<note>key: finder.branch.load_more.label</note>
</trans-unit>
<trans-unit id="542b481fc08d900847ee1107c576cd6b4678a52c" resname="finder.no_content.message">
<source>No content items.</source>
<target state="new">No content items.</target>
<note>key: finder.no_content.message</note>
</trans-unit>
<trans-unit id="fa6baf070f27f737433a162bd6411f4a216d46c0" resname="pagination.first">
<source>First</source>
<target state="new">First</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default class FinderComponent extends Component {
this.loadBranchLeaves = this.loadBranchLeaves.bind(this);
this.onLoadMore = this.onLoadMore.bind(this);
this.renderBranch = this.renderBranch.bind(this);
this.renderActiveLocations = this.renderActiveLocations.bind(this);
this.renderBranches = this.renderBranches.bind(this);
this.setBranchContainerRef = this.setBranchContainerRef.bind(this);
this.setPreselectedState = this.getPreselectedState.bind(this);

Expand Down Expand Up @@ -450,6 +452,53 @@ export default class FinderComponent extends Component {
);
}

renderActiveLocations() {
const { activeLocations, locationsMap } = this.state;

return activeLocations.map((location, index) => {
const locationId = location ? location.id : this.props.startingLocationId;
const branchActiveLocation = activeLocations[index + 1];
const branchActiveLocationId = branchActiveLocation ? branchActiveLocation.id : null;
const isBranchActiveLocationLoading = branchActiveLocationId && !locationsMap[branchActiveLocationId];
const locationData = locationsMap[locationId];

return this.renderBranch(locationData, branchActiveLocationId, isBranchActiveLocationLoading);
});
}

renderEmptyContent() {
const noContentMessage = Translator.trans(
/*@Desc("No content items.")*/ 'finder.no_content.message',
{},
'universal_discovery_widget'
);

return <div className="c-finder__no-content-info">{noContentMessage}</div>;
}

renderBranches() {
const { activeLocations } = this.state;
const branches = [
this.renderStartingLocationBranch(),
...this.renderActiveLocations(),
];
const hasActiveLocations = activeLocations.some((location) => location);
const hasNonEmptyBranches = branches.every((branch) => !branch);

if (hasActiveLocations && hasNonEmptyBranches) {
const noContentMessage = Translator.trans(
/*@Desc("No content items.")*/ 'finder.no_content.message',
{},
'universal_discovery_widget'
);

return <div className="c-finder__no-content-info">{noContentMessage}</div>;
}

return branches;

}

setBranchContainerRef(ref) {
this._refBranchesContainer = ref;
}
Expand All @@ -461,21 +510,10 @@ export default class FinderComponent extends Component {
return null;
}

const { locationsMap } = this.state;

return (
<div className="c-finder">
<div className="c-finder__branches" style={{ height: `${this.props.maxHeight}px` }} ref={this.setBranchContainerRef}>
{this.renderStartingLocationBranch()}
{activeLocations.map((location, index) => {
const locationId = location ? location.id : this.props.startingLocationId;
const branchActiveLocation = activeLocations[index + 1];
const branchActiveLocationId = branchActiveLocation ? branchActiveLocation.id : null;
const isBranchActiveLocationLoading = branchActiveLocationId && !locationsMap[branchActiveLocationId];
const locationData = locationsMap[locationId];

return this.renderBranch(locationData, branchActiveLocationId, isBranchActiveLocationLoading);
})}
{this.renderBranches()}
</div>
</div>
);
Expand Down

0 comments on commit 8ca89ab

Please sign in to comment.