Skip to content

Commit 1456d38

Browse files
committed
Sync styles with guidelines
1 parent 091f1a1 commit 1456d38

File tree

8 files changed

+51
-16
lines changed

8 files changed

+51
-16
lines changed

components/ipfs/ipfs_onboarding_page.cc

+13-8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ constexpr int kConnectedPeersRetryLimitSec = 120;
4242
// The period in seconds between requests to get connected peers information.
4343
constexpr int kConnectedPeersRetryStepSec = 1;
4444

45+
// The period in seconds when we alert user about error.
46+
constexpr int kConnectedPeersAlertTimeoutSec = 10;
4547
} // namespace
4648
namespace ipfs {
4749

@@ -71,7 +73,7 @@ void IPFSOnboardingPage::UseLocalNode() {
7173
auto* prefs = user_prefs::UserPrefs::Get(context);
7274
prefs->SetInteger(kIPFSResolveMethod,
7375
static_cast<int>(ipfs::IPFSResolveMethodTypes::IPFS_LOCAL));
74-
76+
start_time_ticks_ = base::TimeTicks::Now();
7577
if (!ipfs_service_->IsDaemonLaunched()) {
7678
ipfs_service_->LaunchDaemon(base::NullCallback());
7779
} else {
@@ -98,12 +100,13 @@ void IPFSOnboardingPage::OnGetConnectedPeers(
98100
if (!success || peers.empty()) {
99101
base::TimeDelta delta = base::TimeTicks::Now() - start_time_ticks_;
100102
if (delta.InSeconds() < kConnectedPeersRetryLimitSec) {
101-
int retries = (kConnectedPeersRetryLimitSec - delta.InSeconds()) /
102-
kConnectedPeersRetryStepSec;
103-
RespondToPage(NO_PEERS_AVAILABLE, l10n_util::GetStringFUTF16(
104-
IDS_IPFS_ONBOARDING_PEERS_ERROR,
105-
base::NumberToString16(retries)));
106-
103+
if (delta.InSeconds() > kConnectedPeersAlertTimeoutSec) {
104+
int retries = (kConnectedPeersRetryLimitSec - delta.InSeconds()) /
105+
kConnectedPeersRetryStepSec;
106+
RespondToPage(NO_PEERS_AVAILABLE, l10n_util::GetStringFUTF16(
107+
IDS_IPFS_ONBOARDING_PEERS_ERROR,
108+
base::NumberToString16(retries)));
109+
}
107110
base::SequencedTaskRunnerHandle::Get()->PostDelayedTask(
108111
FROM_HERE,
109112
base::BindOnce(&IPFSOnboardingPage::GetConnectedPeers,
@@ -137,7 +140,6 @@ bool IPFSOnboardingPage::IsLocalNodeMode() {
137140
}
138141

139142
void IPFSOnboardingPage::OnIpfsLaunched(bool result, int64_t pid) {
140-
start_time_ticks_ = base::TimeTicks::Now();
141143
if (!result) {
142144
ReportDaemonStopped();
143145
return;
@@ -235,6 +237,9 @@ void IPFSOnboardingPage::PopulateInterstitialStrings(
235237
load_time_data->SetString(
236238
"retryLimitPeersText",
237239
l10n_util::GetStringUTF16(IDS_IPFS_ONBOARDING_PEERS_LIMIT_ERROR));
240+
load_time_data->SetString(
241+
"tryAgainText", l10n_util::GetStringUTF16(IDS_IPFS_ONBOARDING_TRY_AGAIN));
242+
238243
load_time_data->SetString(
239244
"braveTheme", GetThemeType(ui::NativeTheme::GetInstanceForNativeUi()));
240245
}

components/ipfs/ipfs_onboarding_page.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class IPFSOnboardingPage
5252
OPEN_SETTINGS = 3,
5353
};
5454

55-
// In case of an error when starting a local node, we notify a page.
55+
// Commands to send to the page to provide feedback to the user.
5656
enum IPFSOnboardingResponse {
5757
LOCAL_NODE_ERROR = 0,
5858
THEME_CHANGED = 1,

components/ipfs/ipfs_service.cc

-2
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,6 @@ void IpfsService::OnGetConnectedPeers(
265265
if (url_loader->ResponseInfo() && url_loader->ResponseInfo()->headers)
266266
response_code = url_loader->ResponseInfo()->headers->response_code();
267267
url_loaders_.erase(iter);
268-
LOG(ERROR) << "On get connected peers, error_code = " << error_code
269-
<< " response_code = " << response_code;
270268

271269
std::vector<std::string> peers;
272270
bool success = (error_code == net::OK && response_code == net::HTTP_OK);
Loading
Loading

components/ipfs/resources/onboarding/ipfs_onboarding.css

+24-4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ body {
4747
margin-top: 20px;
4848
display: flex;
4949
align-items: center;
50+
height: 100px;
5051
}
5152

5253
.button-wrapper {
@@ -56,15 +57,26 @@ body {
5657

5758
.button {
5859
border-radius: 100px;
59-
font-weight: bold;
60+
font-weight: 600;
6061
font-size: 13px;
62+
width: 200px;
63+
word-wrap: break-word;
64+
cursor: pointer;
65+
}
66+
67+
.button-retry {
68+
background-image: url('./assets/retry.svg');
69+
background-repeat: no-repeat;
70+
background-size: 18px;
71+
background-position: left 20% top 50%;
72+
cursor: pointer;
6173
}
6274

6375
#local-node-button {
6476
color: #fff;
6577
border: none;
66-
background: #4C54D2;
67-
padding: 10px 40px;
78+
background-color: #FB542B;
79+
padding: 10px 30px;
6880
}
6981

7082
#public-gateway-button {
@@ -130,7 +142,15 @@ body.dark {
130142
}
131143

132144
.error-container-visible {
145+
background-image: url('./assets/error.svg');
146+
background-repeat: no-repeat;
147+
background-position: left 25px top 2px;
148+
133149
display: block;
134150
color: red;
135151
margin-top: 10px;
136-
}
152+
padding: 0px 40px;
153+
padding-left: 45px;
154+
text-align: left;
155+
}
156+

components/ipfs/resources/onboarding/ipfs_onboarding.js

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function setupEvents() {
3030
$('local-node-button').addEventListener('click', function() {
3131
$('local-node-button').textContent = '$i18nRaw{installationText}'
3232
$('error-container').className = 'error-container-hidden'
33+
$('local-node-button').className = 'button'
3334
sendCommand(IPFSOnboardingCommandId.USE_LOCAL_NODE);
3435
});
3536

@@ -65,6 +66,8 @@ function handleCommand(code, text) {
6566
showErrorMessage(text)
6667
} else if (code == IPFSOnboardingResponse.NO_PEERS_LIMIT) {
6768
showErrorMessage('$i18nRaw{retryLimitPeersText}')
69+
$('local-node-button').textContent = '$i18nRaw{tryAgainText}'
70+
$('local-node-button').className = 'button button-retry'
6871
}
6972
}
7073

components/resources/ipfs_strings.grdp

+4-1
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,14 @@
9797
<message name="IDS_IPFS_ONBOARDING_WAITING_PEERS_STATUS" desc="Title of button for IPFS interstitial page.">
9898
Waiting for peers...
9999
</message>
100+
<message name="IDS_IPFS_ONBOARDING_TRY_AGAIN" desc="Retry button text for IPFS interstitial page.">
101+
Try again
102+
</message>
100103
<message name="IDS_IPFS_ONBOARDING_PEERS_ERROR" desc="Error message about no peers for IPFS interstitial page.">
101104
No peers available, retrying... (<ph name="ATTEMPTS_NUMBER">$1<ex>5</ex></ph> attemps left)
102105
</message>
103106
<message name="IDS_IPFS_ONBOARDING_PEERS_LIMIT_ERROR" desc="Error message about no peers for IPFS interstitial page.">
104-
No peers available, we have exceeded the limit of attemps, you can try again later.
107+
We have exceeded the limit of attemps, try again later.
105108
</message>
106109
</if>
107110
</grit-part>

0 commit comments

Comments
 (0)