Renamed `activeTimezone` setting to `timezone`

refs https://github.com/TryGhost/Ghost/issues/10318

- API has been updated to still work with `active_timezone` for backwards compatibility but it makes sense for the client to match the underlying settings keys
This commit is contained in:
Kevin Ansfield 2020-06-24 15:34:59 +01:00
parent 9f9273fafc
commit 3da8815759
13 changed files with 38 additions and 38 deletions

View File

@ -30,7 +30,7 @@ export default Component.extend({
// actions // actions
setTypedDateError() {}, setTypedDateError() {},
blogTimezone: reads('settings.activeTimezone'), blogTimezone: reads('settings.timezone'),
hasError: or('dateError', 'timeError'), hasError: or('dateError', 'timeError'),
dateValue: computed('_date', '_scratchDate', function () { dateValue: computed('_date', '_scratchDate', function () {

View File

@ -1,7 +1,7 @@
<span class="gh-select" data-select-text="{{this.selectedTimezone.label}}" tabindex="0"> <span class="gh-select" data-select-text="{{this.selectedTimezone.label}}" tabindex="0">
<OneWaySelect <OneWaySelect
@id="activeTimezone" @id="timezone"
@name="general[activeTimezone]" @name="general[timezone]"
@options={{this.selectableTimezones}} @options={{this.selectableTimezones}}
@optionValuePath="name" @optionValuePath="name"
@optionLabelPath="label" @optionLabelPath="label"
@ -11,6 +11,6 @@
{{svg-jar "arrow-down-small"}} {{svg-jar "arrow-down-small"}}
</span> </span>
{{#if this.hasTimezoneOverride}} {{#if this.hasTimezoneOverride}}
<p>Your timezone has been automatically set to {{this.activeTimezone}}.</p> <p>Your timezone has been automatically set to {{this.timezone}}.</p>
{{/if}} {{/if}}
<p>The local time here is currently {{this.localTime}}</p> <p>The local time here is currently {{this.localTime}}</p>

View File

@ -9,7 +9,7 @@ export default Component.extend({
classNames: ['form-group', 'for-select'], classNames: ['form-group', 'for-select'],
activeTimezone: null, timezone: null,
availableTimezones: null, availableTimezones: null,
// Allowed actions // Allowed actions
@ -17,16 +17,16 @@ export default Component.extend({
availableTimezoneNames: mapBy('availableTimezones', 'name'), availableTimezoneNames: mapBy('availableTimezones', 'name'),
hasTimezoneOverride: computed('activeTimezone', 'availableTimezoneNames', function () { hasTimezoneOverride: computed('timezone', 'availableTimezoneNames', function () {
let activeTimezone = this.activeTimezone; let timezone = this.timezone;
let availableTimezoneNames = this.availableTimezoneNames; let availableTimezoneNames = this.availableTimezoneNames;
return !availableTimezoneNames.includes(activeTimezone); return !availableTimezoneNames.includes(timezone);
}), }),
selectedTimezone: computed('activeTimezone', 'availableTimezones', 'hasTimezoneOverride', function () { selectedTimezone: computed('timezone', 'availableTimezones', 'hasTimezoneOverride', function () {
let hasTimezoneOverride = this.hasTimezoneOverride; let hasTimezoneOverride = this.hasTimezoneOverride;
let activeTimezone = this.activeTimezone; let timezone = this.timezone;
let availableTimezones = this.availableTimezones; let availableTimezones = this.availableTimezones;
if (hasTimezoneOverride) { if (hasTimezoneOverride) {
@ -34,7 +34,7 @@ export default Component.extend({
} }
return availableTimezones return availableTimezones
.filterBy('name', activeTimezone) .filterBy('name', timezone)
.get('firstObject'); .get('firstObject');
}), }),
@ -49,9 +49,9 @@ export default Component.extend({
return availableTimezones; return availableTimezones;
}), }),
localTime: computed('hasTimezoneOverride', 'activeTimezone', 'selectedTimezone', 'clock.second', function () { localTime: computed('hasTimezoneOverride', 'timezone', 'selectedTimezone', 'clock.second', function () {
let hasTimezoneOverride = this.hasTimezoneOverride; let hasTimezoneOverride = this.hasTimezoneOverride;
let timezone = hasTimezoneOverride ? this.activeTimezone : this.get('selectedTimezone.name'); let timezone = hasTimezoneOverride ? this.timezone : this.get('selectedTimezone.name');
this.get('clock.second'); this.get('clock.second');
return timezone ? moment().tz(timezone).format('HH:mm:ss') : moment().utc().format('HH:mm:ss'); return timezone ? moment().tz(timezone).format('HH:mm:ss') : moment().utc().format('HH:mm:ss');

View File

@ -69,7 +69,7 @@ export default Controller.extend({
}, },
setTimezone(timezone) { setTimezone(timezone) {
this.set('settings.activeTimezone', timezone.name); this.set('settings.timezone', timezone.name);
}, },
removeImage(image) { removeImage(image) {

View File

@ -14,7 +14,7 @@ export default Helper.extend({
return moment(timeago).from(moment.utc()); return moment(timeago).from(moment.utc());
} }
let timezone = this.get('settings.activeTimezone'); let timezone = this.get('settings.timezone');
let time = moment.tz(timeago, timezone); let time = moment.tz(timeago, timezone);
let now = moment.tz(moment.utc(), timezone); let now = moment.tz(moment.utc(), timezone);

View File

@ -177,7 +177,7 @@ export default Model.extend(Comparable, ValidationEngine, {
} }
}), }),
publishedAtBlogTZ: computed('publishedAtBlogDate', 'publishedAtBlogTime', 'settings.activeTimezone', { publishedAtBlogTZ: computed('publishedAtBlogDate', 'publishedAtBlogTime', 'settings.timezone', {
get() { get() {
return this._getPublishedAtBlogTZ(); return this._getPublishedAtBlogTZ();
}, },
@ -192,7 +192,7 @@ export default Model.extend(Comparable, ValidationEngine, {
let publishedAtUTC = this.publishedAtUTC; let publishedAtUTC = this.publishedAtUTC;
let publishedAtBlogDate = this.publishedAtBlogDate; let publishedAtBlogDate = this.publishedAtBlogDate;
let publishedAtBlogTime = this.publishedAtBlogTime; let publishedAtBlogTime = this.publishedAtBlogTime;
let blogTimezone = this.get('settings.activeTimezone'); let blogTimezone = this.get('settings.timezone');
if (!publishedAtUTC && isBlank(publishedAtBlogDate) && isBlank(publishedAtBlogTime)) { if (!publishedAtUTC && isBlank(publishedAtBlogDate) && isBlank(publishedAtBlogTime)) {
return null; return null;
@ -226,14 +226,14 @@ export default Model.extend(Comparable, ValidationEngine, {
// TODO: is there a better way to handle this? // TODO: is there a better way to handle this?
// eslint-disable-next-line ghost/ember/no-observers // eslint-disable-next-line ghost/ember/no-observers
_setPublishedAtBlogTZ: on('init', observer('publishedAtUTC', 'settings.activeTimezone', function () { _setPublishedAtBlogTZ: on('init', observer('publishedAtUTC', 'settings.timezone', function () {
let publishedAtUTC = this.publishedAtUTC; let publishedAtUTC = this.publishedAtUTC;
this._setPublishedAtBlogStrings(publishedAtUTC); this._setPublishedAtBlogStrings(publishedAtUTC);
})), })),
_setPublishedAtBlogStrings(momentDate) { _setPublishedAtBlogStrings(momentDate) {
if (momentDate) { if (momentDate) {
let blogTimezone = this.get('settings.activeTimezone'); let blogTimezone = this.get('settings.timezone');
let publishedAtBlog = moment.tz(momentDate, blogTimezone); let publishedAtBlog = moment.tz(momentDate, blogTimezone);
this.set('publishedAtBlogDate', publishedAtBlog.format('YYYY-MM-DD')); this.set('publishedAtBlogDate', publishedAtBlog.format('YYYY-MM-DD'));

View File

@ -12,7 +12,7 @@ export default Model.extend(ValidationEngine, {
icon: attr('string'), icon: attr('string'),
accentColor: attr('string'), accentColor: attr('string'),
lang: attr('string'), lang: attr('string'),
activeTimezone: attr('string', {defaultValue: 'Etc/UTC'}), timezone: attr('string', {defaultValue: 'Etc/UTC'}),
codeinjectionHead: attr('string'), codeinjectionHead: attr('string'),
codeinjectionFoot: attr('string'), codeinjectionFoot: attr('string'),
facebook: attr('facebook-url-user'), facebook: attr('facebook-url-user'),

View File

@ -62,7 +62,7 @@
{{#liquid-if this.timezoneOpen}} {{#liquid-if this.timezoneOpen}}
<div class="gh-setting-content-extended"> <div class="gh-setting-content-extended">
<GhTimezoneSelect <GhTimezoneSelect
@activeTimezone={{this.settings.activeTimezone}} @timezone={{this.settings.timezone}}
@availableTimezones={{this.availableTimezones}} @availableTimezones={{this.availableTimezones}}
@update={{action "setTimezone"}} /> @update={{action "setTimezone"}} />
</div> </div>

View File

@ -147,7 +147,7 @@ export default [
id: 19, id: 19,
created_at: '2015-09-11T09:44:30.810Z', created_at: '2015-09-11T09:44:30.810Z',
created_by: 1, created_by: 1,
key: 'active_timezone', key: 'timezone',
group: 'site', group: 'site',
updated_at: '2015-09-23T13:32:49.868Z', updated_at: '2015-09-23T13:32:49.868Z',
updated_by: 1, updated_by: 1,

View File

@ -266,17 +266,17 @@ describe('Acceptance: Editor', function () {
expect(currentURL(), 'currentURL for settings') expect(currentURL(), 'currentURL for settings')
.to.equal('/settings/general'); .to.equal('/settings/general');
expect(find('#activeTimezone option:checked').textContent.trim(), 'default timezone') expect(find('#timezone option:checked').textContent.trim(), 'default timezone')
.to.equal('(GMT) UTC'); .to.equal('(GMT) UTC');
// select a new timezone // select a new timezone
find('#activeTimezone option[value="Pacific/Kwajalein"]').selected = true; find('#timezone option[value="Pacific/Kwajalein"]').selected = true;
await triggerEvent('#activeTimezone', 'change'); await triggerEvent('#timezone', 'change');
// save the settings // save the settings
await click('.gh-btn.gh-btn-blue'); await click('.gh-btn.gh-btn-blue');
expect(find('#activeTimezone option:checked').textContent.trim(), 'new timezone after saving') expect(find('#timezone option:checked').textContent.trim(), 'new timezone after saving')
.to.equal('(GMT +12:00) International Date Line West'); .to.equal('(GMT +12:00) International Date Line West');
// and now go back to the editor // and now go back to the editor
@ -526,7 +526,7 @@ describe('Acceptance: Editor', function () {
let compareDateString = compareDate.format('YYYY-MM-DD'); let compareDateString = compareDate.format('YYYY-MM-DD');
let compareTimeString = compareDate.format('HH:mm'); let compareTimeString = compareDate.format('HH:mm');
this.server.create('post', {publishedAt: moment.utc().add(4, 'minutes'), status: 'scheduled', authors: [author]}); this.server.create('post', {publishedAt: moment.utc().add(4, 'minutes'), status: 'scheduled', authors: [author]});
this.server.create('setting', {activeTimezone: 'Europe/Dublin'}); this.server.create('setting', {timezone: 'Europe/Dublin'});
clock.restore(); clock.restore();
await visit('/editor/post/1'); await visit('/editor/post/1');

View File

@ -311,13 +311,13 @@ describe('Acceptance: Settings - General', function () {
expect(currentURL(), 'currentURL').to.equal('/settings/general'); expect(currentURL(), 'currentURL').to.equal('/settings/general');
expect(findAll('#activeTimezone option').length, 'available timezones').to.equal(66); expect(findAll('#timezone option').length, 'available timezones').to.equal(66);
expect(find('#activeTimezone option:checked').textContent.trim()).to.equal('(GMT) UTC'); expect(find('#timezone option:checked').textContent.trim()).to.equal('(GMT) UTC');
find('#activeTimezone option[value="Africa/Cairo"]').selected = true; find('#timezone option[value="Africa/Cairo"]').selected = true;
await triggerEvent('#activeTimezone', 'change'); await triggerEvent('#timezone', 'change');
await click('[data-test-save-button]'); await click('[data-test-save-button]');
expect(find('#activeTimezone option:checked').textContent.trim()).to.equal('(GMT +2:00) Cairo, Egypt'); expect(find('#timezone option:checked').textContent.trim()).to.equal('(GMT +2:00) Cairo, Egypt');
}); });
it('handles private blog settings correctly', async function () { it('handles private blog settings correctly', async function () {

View File

@ -14,13 +14,13 @@ describe('Integration: Component: gh-timezone-select', function () {
{name: 'Etc/UTC', label: '(GMT) UTC'}, {name: 'Etc/UTC', label: '(GMT) UTC'},
{name: 'Pacific/Kwajalein', label: '(GMT +12:00) International Date Line West'} {name: 'Pacific/Kwajalein', label: '(GMT +12:00) International Date Line West'}
]); ]);
this.set('activeTimezone', 'Etc/UTC'); this.set('timezone', 'Etc/UTC');
}); });
it('renders', async function () { it('renders', async function () {
await render(hbs`{{gh-timezone-select await render(hbs`{{gh-timezone-select
availableTimezones=availableTimezones availableTimezones=availableTimezones
activeTimezone=activeTimezone}}`); timezone=timezone}}`);
expect(this.element, 'top-level elements').to.exist; expect(this.element, 'top-level elements').to.exist;
expect(findAll('option'), 'number of options').to.have.length(3); expect(findAll('option'), 'number of options').to.have.length(3);
@ -28,11 +28,11 @@ describe('Integration: Component: gh-timezone-select', function () {
}); });
it('handles an unknown timezone', async function () { it('handles an unknown timezone', async function () {
this.set('activeTimezone', 'Europe/London'); this.set('timezone', 'Europe/London');
await render(hbs`{{gh-timezone-select await render(hbs`{{gh-timezone-select
availableTimezones=availableTimezones availableTimezones=availableTimezones
activeTimezone=activeTimezone}}`); timezone=timezone}}`);
// we have an additional blank option at the top // we have an additional blank option at the top
expect(findAll('option'), 'number of options').to.have.length(4); expect(findAll('option'), 'number of options').to.have.length(4);
@ -48,7 +48,7 @@ describe('Integration: Component: gh-timezone-select', function () {
await render(hbs`{{gh-timezone-select await render(hbs`{{gh-timezone-select
availableTimezones=availableTimezones availableTimezones=availableTimezones
activeTimezone=activeTimezone timezone=timezone
update=(action update)}}`); update=(action update)}}`);
await fillIn('select', 'Pacific/Pago_Pago'); await fillIn('select', 'Pacific/Pago_Pago');

View File

@ -17,7 +17,7 @@ describe('Integration: Helper: gh-format-post-time', function () {
beforeEach(function () { beforeEach(function () {
let settings = this.owner.lookup('service:settings'); let settings = this.owner.lookup('service:settings');
settings.content = {}; settings.content = {};
settings.set('activeTimezone', timezoneForTest); settings.set('timezone', timezoneForTest);
}); });
afterEach(function () { afterEach(function () {