Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apps: React-related fixes #9344

Merged
merged 1 commit into from
Jul 6, 2018
Merged

Conversation

mareklibra
Copy link
Contributor

@mareklibra mareklibra commented Jun 8, 2018

Part of #9263 PR-split, see individual commits for more info.

The DBus-related issue was observed in tests when working on #9263.

@mareklibra mareklibra mentioned this pull request Jun 8, 2018
44 tasks
@mareklibra mareklibra changed the title apps: Fix detection of DBus error apps: React-related fixes Jun 8, 2018
<td>{refresh_progress}</td>
<td>{refresh_button}</td>
</tr>
<tbody>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, is a tbody really always required in React? That sounds strange, it's entirely optional in HTML and only really useful if one needs to shove in additional things next to the tr?

@@ -80,11 +80,11 @@ class Application extends React.Component {

return description.map(paragraph => {
if (paragraph.tag == 'ul') {
return <ul>{paragraph.items.map(item => <li>{item}</li>)}</ul>;
return <ul key={paragraph}>{paragraph.items.map(item => <li key={item}>{item}</li>)}</ul>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would repeat the entire paragraph text in the HTML, which seems rather useless and wasteful? What is the purpose of all these keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed in #9339 , the long paragraph text will not make it to the HTML

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But paragraph is not a string...

Copy link
Contributor Author

@mareklibra mareklibra Jun 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing it with string paragraph-${index}. Use of indexes is not preferred, but not anti-pattern and working.

@mareklibra
Copy link
Contributor Author

mareklibra commented Jun 11, 2018

It's a good practice to explicitly use the <tbody>. Discussed i.e. here: facebook/react#5652

For that reason, I'll need to fix a few CSS selectors within check-* scripts, since the DOM structure is changed. Anyway, it's already done within #9263 , so it will get into these "split" PRs when relevant.

@martinpitt martinpitt added the blocked Don't land until something else happens first (see task list) label Jun 11, 2018
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM then. I marked it as blocked, AFAIUI the check-storage PR has to land first, right?

@mareklibra
Copy link
Contributor Author

Files under pkg/apps are modified only in this PR, so I think the storage fixes are unrelated.
For storage, some of the fixes will be just similar to this one.

@@ -91,7 +91,7 @@ export const show_error = ex => {
if (ex.code == "cancelled")
return;

if (ex.code == "not-found")
if (ex.code == "not-found" || ex.problem == "not-found")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this more? ex.code is from PackageKit, and ex.problem is from cockpit-bridge. The first is "not-found" when the package was not known to PackageKit, the latter is "not-found" when PackageKit itself isn't there.

Let's move this out into its own PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I did not dig into details of this. Test was failing here and while debugging I watched for content of the ex. I will need to start over to give proper answer to your question.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this out here, then.

@@ -140,18 +140,20 @@ class ApplicationList extends React.Component {
tbody = <tr className="app-list-empty"><td>{empty_caption}</td></tr>;
} else {
table_classes += " table-hover";
tbody = comps.map((c) => <ApplicationRow comp={c} />);
tbody = comps.map((c) => <ApplicationRow comp={c} key={c} />);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c is not a string. c.id should work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -62,7 +62,7 @@ class Application extends React.Component {
function render_homepage_link(urls) {
return urls.map(url => {
if (url.type == 'homepage') {
return (<div className="app-links">
return (<div className="app-links" key={url}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url.link should work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

} else if (paragraph.tag == 'ol') {
return <ol>{paragraph.items.map(item => <li>{item}</li>)}</ol>;
return <ol key={paragraph}>{paragraph.items.map(item => <li key={item}>{item}</li>)}</ol>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key is not a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed via indexes. Or anything better (natural key)?

@@ -127,7 +127,7 @@ class Application extends React.Component {
{render_homepage_link(comp.urls)}
<div className="app-description">{render_description(comp.description)}</div>
<center>
{ comp.screenshots.map(s => <img className="app-screenshot" role="presentation" src={s.full} />) }
{ comp.screenshots.map(s => <img key={s} className="app-screenshot" role="presentation" src={s.full} />) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key is not a string.

} else {
return <p>{paragraph}</p>;
return <p key={paragraph}>{paragraph}</p>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key is not a string.

@mareklibra
Copy link
Contributor Author

Fixed, can you have a look, please? I'm using array indexes to build the key string value. I believe, this might be ok in this case. If concerned, I can replace by either natural key (need to be found) or generally unique (using counter).

@mvollmer
Copy link
Member

React related changes look good to me now, thanks!

The D-Bus fix should not be in this PR. It might or might not be a good fix, but it's unclear what it is fixing, and not related to React.

@mvollmer mvollmer removed the blocked Don't land until something else happens first (see task list) label Jul 6, 2018
And fix <table><tbody> hierarchy for React.
@mvollmer
Copy link
Member

mvollmer commented Jul 6, 2018

I have removed the D-Bus fix from this PR.

@martinpitt martinpitt merged commit 5046833 into cockpit-project:master Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants