Skip to content

Commit 683b9c1

Browse files
committed
Changed What's New from banner into modal dialog.
1 parent ce72b5a commit 683b9c1

File tree

10 files changed

+85
-137
lines changed

10 files changed

+85
-137
lines changed

locales/eng/translation.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ Object.assign(Locales['eng'], {
223223
'Rectangle example': 'Rectangle example',
224224
'Redo last change': 'Redo last change',
225225
'Refresh preview': 'Refresh preview',
226-
'released, check out the new features!': 'released, check out the new features!',
227226
'Reload preview': 'Reload preview',
228227
'Rename variable...': 'Rename variable...',
229228
'Render': 'Render',

src/ui/help/help.gss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright 2019 The Coding with Chrome Authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#{$prefix}help-whats_new-show {
18+
display: flex;
19+
}

src/ui/help/help.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
goog.provide('cwc.ui.Help');
2121

2222
goog.require('cwc.soy.Help');
23+
goog.require('cwc.userConfigType');
24+
goog.require('cwc.utils.Events');
2325

26+
goog.require('goog.dom');
27+
goog.require('goog.events.EventType');
2428

2529
/**
2630
* @param {!cwc.utils.Helper} helper
@@ -39,6 +43,9 @@ cwc.ui.Help = function(helper) {
3943

4044
/** @private {boolean} */
4145
this.chromeApp_ = this.helper.checkChromeFeature('app');
46+
47+
/** @private {!cwc.utils.Events} */
48+
this.events_ = new cwc.utils.Events(this.name, this.prefix, this);
4249
};
4350

4451

@@ -87,6 +94,23 @@ cwc.ui.Help.prototype.showChangelog = function() {
8794
noticeWebview.addEventListener('contentload', function() {
8895
noticeWebview['insertCSS']({'code': 'html {overflow-y: scroll;}'});
8996
});
97+
this.initWhatsNewControl_();
98+
};
99+
100+
101+
cwc.ui.Help.prototype.initWhatsNewControl_ = function() {
102+
let showWhatsNew = goog.dom.getElement(this.prefix + 'whats_new-checkbox');
103+
let userConfigInstance = this.helper.getInstance('userConfig');
104+
if (userConfigInstance.get(cwc.userConfigType.GENERAL,
105+
cwc.userConfigName.SKIP_WHATS_NEW)) {
106+
showWhatsNew.parentNode['MaterialCheckbox']['uncheck']();
107+
} else {
108+
showWhatsNew.parentNode['MaterialCheckbox']['check']();
109+
}
110+
this.events_.listen(showWhatsNew, goog.events.EventType.CHANGE, () => {
111+
userConfigInstance.set(cwc.userConfigType.GENERAL,
112+
cwc.userConfigName.SKIP_WHATS_NEW, !showWhatsNew.checked);
113+
});
90114
};
91115

92116

src/ui/help/help.soy

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,11 @@
136136
<iframe id="{$prefix}webview-notice"
137137
src="../CHANGELOG.html" style="width: 600px; height: 500px;"></iframe>
138138
{/if}
139+
140+
<label id="{$prefix}whats_new-show" for="{$prefix}whats_new-checkbox" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
141+
<input type="checkbox" id="{$prefix}whats_new-checkbox" class="mdl-checkbox__input"/>
142+
<div class="mdl-checkbox__label">
143+
{msg desc="Checkbox to enable/disable showing a notification when a new release is installed."}@@SELECT_SCREEN__ENABLE_WHATS_NEW{/msg}
144+
</div>
145+
</label>
139146
{/template}

src/ui/select_screen/advanced/advanced.soy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626
{template .template}
2727
{@param prefix: string}
28-
{@param version: string}
2928

3029
<div class="{$prefix}overview mdl-layout mdl-js-layout">
3130

@@ -90,7 +89,6 @@
9089
{param active: true /}
9190
{param id: 'overview' /}
9291
{param content kind="html"}
93-
{call cwc.soy.SelectScreen.whatsNew data="all" /}
9492
{call .overview data="all" /}
9593
{/param}
9694
{/call}

src/ui/select_screen/normal/normal.soy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
*/
2626
{template .template}
2727
{@param prefix: string}
28-
{@param version: string}
2928

3029
<div class="{$prefix}overview mdl-layout mdl-js-layout">
3130

@@ -66,7 +65,6 @@
6665
{param active: true /}
6766
{param id: 'overview' /}
6867
{param content kind="html"}
69-
{call cwc.soy.SelectScreen.whatsNew data="all" /}
7068
{call .overview data="all" /}
7169
{/param}
7270
{/call}

src/ui/select_screen/select_screen.gss

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -295,28 +295,3 @@
295295
left: 15%;
296296
background-color: rgb(255,64,129);
297297
}
298-
299-
#{$prefix}select-screen-whats_new .mdl-button {
300-
width: 95%;
301-
}
302-
303-
#{$prefix}select-screen-whats_new-close {
304-
float: right;
305-
max-width: fit-content;
306-
}
307-
308-
#{$prefix}select-screen-whats_new .mdl-grid {
309-
max-width: fit-content;
310-
padding: 0;
311-
}
312-
313-
#{$prefix}select-screen-whats_new label {
314-
max-width: fit-content;
315-
margin: auto;
316-
}
317-
318-
#{$prefix}select-screen-whats_new .mdl-checkbox__label {
319-
font-size: 1rem;
320-
color: rgba(0,0,0,.54);
321-
}
322-

src/ui/select_screen/select_screen.js

Lines changed: 34 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,6 @@ cwc.ui.SelectScreen.prototype.addFileHandler_ = function() {
277277
* @param {!Function} template
278278
*/
279279
cwc.ui.SelectScreen.prototype.showTemplate_ = function(template) {
280-
let skipWhatsNew = false;
281-
let lastWhatsNewVersion = null;
282-
let userConfigInstance = this.helper.getInstance('userConfig');
283-
if (userConfigInstance) {
284-
skipWhatsNew = userConfigInstance.get(cwc.userConfigType.GENERAL,
285-
cwc.userConfigName.SKIP_WHATS_NEW);
286-
lastWhatsNewVersion = userConfigInstance.get(cwc.userConfigType.GENERAL,
287-
cwc.userConfigName.LAST_WHATS_NEW_VERSION);
288-
}
289-
let version = this.helper.getAppVersion();
290-
291280
if (this.nodeContent && template) {
292281
goog.soy.renderElement(this.nodeContent, template, {
293282
bluetooth: Feature.hasBluetooth(),
@@ -298,8 +287,7 @@ cwc.ui.SelectScreen.prototype.showTemplate_ = function(template) {
298287
modules: this.modules,
299288
online: this.helper.checkFeature('online'),
300289
prefix: this.prefix,
301-
showWhatsNew: (!skipWhatsNew) && (version != lastWhatsNewVersion),
302-
version: version,
290+
version: this.helper.getAppVersion(),
303291
});
304292
this.addFileHandler_();
305293
cwc.ui.Helper.mdlRefresh();
@@ -308,63 +296,12 @@ cwc.ui.SelectScreen.prototype.showTemplate_ = function(template) {
308296
// Event Handling
309297
this.eventTarget_.dispatchEvent(
310298
cwc.ui.SelectScreen.Events.changeView(this.nodeContent));
311-
this.initWhatsNew_(version);
299+
this.showWhatsNew_();
312300
} else {
313301
console.error('Unable to render template', template);
314302
}
315303
};
316304

317-
/**
318-
* @private
319-
* @param {!string} version
320-
*/
321-
cwc.ui.SelectScreen.prototype.initWhatsNew_ = function(version) {
322-
let prefix = this.prefix + 'whats_new';
323-
let whats_new = goog.dom.getElement(prefix);
324-
if (!whats_new) {
325-
return;
326-
}
327-
let userConfigInstance = this.helper.getInstance('userConfig');
328-
329-
// Flag tha we've show What's New for this version
330-
if (userConfigInstance) {
331-
userConfigInstance.set(cwc.userConfigType.GENERAL,
332-
cwc.userConfigName.LAST_WHATS_NEW_VERSION, version);
333-
}
334-
335-
let whatsNewLink = goog.dom.getElement(prefix + '-link');
336-
if (whatsNewLink) {
337-
this.events_.listen(whatsNewLink, goog.events.EventType.CLICK, () => {
338-
let helpInstance = this.helper.getInstance('help');
339-
if (!helpInstance) {
340-
console.error('Failed to get helper instance');
341-
return;
342-
}
343-
helpInstance.showChangelog();
344-
});
345-
}
346-
347-
let whatsNewClose = goog.dom.getElement(prefix + '-close');
348-
if (whatsNewClose) {
349-
this.events_.listen(whatsNewClose, goog.events.EventType.CLICK, () => {
350-
goog.style.setElementShown(whats_new, false);
351-
});
352-
}
353-
354-
let whatsNewShow = goog.dom.getElement(prefix + '-show');
355-
if (whatsNewShow && userConfigInstance) {
356-
if (userConfigInstance.get(cwc.userConfigType.GENERAL,
357-
cwc.userConfigName.SKIP_WHATS_NEW)) {
358-
whatsNewShow.parentNode['MaterialCheckbox']['uncheck']();
359-
} else {
360-
whatsNewShow.parentNode['MaterialCheckbox']['check']();
361-
}
362-
this.events_.listen(whatsNewShow, goog.events.EventType.CHANGE, () => {
363-
userConfigInstance.set(cwc.userConfigType.GENERAL,
364-
cwc.userConfigName.SKIP_WHATS_NEW, !whatsNewShow.checked);
365-
});
366-
}
367-
};
368305

369306
/**
370307
* @param {string} title
@@ -431,12 +368,38 @@ cwc.ui.SelectScreen.prototype.handleFileClick_ = function(e) {
431368
};
432369

433370
/**
434-
* Displays list of new features
371+
* @private
435372
*/
436-
cwc.ui.SelectScreen.prototype.showWhatsNew = function() {
437-
let dialogInstance = this.helper.getInstance('dialog');
438-
dialogInstance.showTemplate('What\'s New', cwc.soy.SelectScreen.whatsNew, {
439-
prefix: this.prefix,
440-
});
373+
cwc.ui.SelectScreen.prototype.showWhatsNew_ = function() {
374+
let version = this.helper.getAppVersion();
375+
376+
let userConfigInstance = this.helper.getInstance('userConfig');
377+
if (!userConfigInstance) {
378+
console.error('Failed to get user config instance');
379+
return;
380+
}
381+
382+
if (userConfigInstance.get(cwc.userConfigType.GENERAL,
383+
cwc.userConfigName.SKIP_WHATS_NEW)) {
384+
return;
385+
}
386+
387+
if (userConfigInstance.get(cwc.userConfigType.GENERAL,
388+
cwc.userConfigName.LAST_WHATS_NEW_VERSION) == version) {
389+
return;
390+
}
391+
392+
let helpInstance = this.helper.getInstance('help');
393+
if (!helpInstance) {
394+
console.error('Failed to help instance');
395+
return;
396+
}
397+
398+
// Flag that we've show What's New for this version
399+
if (userConfigInstance) {
400+
userConfigInstance.set(cwc.userConfigType.GENERAL,
401+
cwc.userConfigName.LAST_WHATS_NEW_VERSION, version);
402+
}
403+
helpInstance.showChangelog(true);
441404
};
442405
});

src/ui/select_screen/select_screen.soy

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,6 @@
3131
</div>
3232
{/template}
3333

34-
/**
35-
* Notification of new release
36-
*/
37-
{template .whatsNew}
38-
{@param prefix: string}
39-
{@param version: string}
40-
{@param showWhatsNew: bool}
41-
42-
{if $showWhatsNew}
43-
<div id="{$prefix}whats_new" class='mdl-color--yellow'>
44-
45-
<button id="{$prefix}whats_new-close" class="mdl-button mdl-js-button mdl-button--icon" title="close">
46-
<i class="material-icons">close</i>
47-
</button>
48-
49-
<div class="mdl-grid">
50-
51-
<a id="{$prefix}whats_new-link" class="mdl-button mdl-js-button">
52-
{$version}&nbsp;{msg desc="Link to description of features in a newly installed version."}released, check out the new features!{/msg}
53-
<i class="material-icons">chevron_right</i>
54-
</a>
55-
56-
<label for="{$prefix}whats_new-show" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
57-
<input type="checkbox" id="{$prefix}whats_new-show" class="mdl-checkbox__input"/>
58-
<div class="mdl-checkbox__label">
59-
{msg desc="Checkbox to enable/disable showing a notification when a new release is installed."}@@SELECT_SCREEN__ENABLE_WHATS_NEW{/msg}
60-
</div>
61-
</label>
62-
</div>
63-
</div>
64-
{/if}
65-
{/template}
6634

6735
/**
6836
* Connect devices template.
@@ -123,5 +91,3 @@ for (let i = 0; i < 10; i++) {
12391
{/literal}
12492
</textarea>
12593
{/template}
126-
127-

src/ui/select_screen/welcome/welcome.soy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
{/call}
3939

4040
{call .banner_ data="all" /}
41-
{call cwc.soy.SelectScreen.whatsNew data="all" /}
42-
41+
4342
{call cwc.soy.SelectScreenTemplate.header}
4443
{param title: '@@WELCOME_SCREEN__HEADER' /}
4544
{param opt_text: '@@WELCOME_SCREEN__CHOOSE' /}

0 commit comments

Comments
 (0)