Commit 0c215e38 authored by Clement Ho's avatar Clement Ho

Merge branch 'ee-58023-add-Saturday-to-localization-first-day-of-the-week' into 'master'

EE Port: Add Saturday to first day of the week

Closes gitlab-ce#58023

See merge request gitlab-org/gitlab-ee!9797
parents 3fc64000 8c644dcd
...@@ -10,6 +10,12 @@ import { __ } from '~/locale'; ...@@ -10,6 +10,12 @@ import { __ } from '~/locale';
const d3 = { select, scaleLinear, scaleThreshold }; const d3 = { select, scaleLinear, scaleThreshold };
const firstDayOfWeekChoices = Object.freeze({
sunday: 0,
monday: 1,
saturday: 6,
});
const LOADING_HTML = ` const LOADING_HTML = `
<div class="text-center"> <div class="text-center">
<i class="fa fa-spinner fa-spin user-calendar-activities-loading"></i> <i class="fa fa-spinner fa-spin user-calendar-activities-loading"></i>
...@@ -49,7 +55,7 @@ export default class ActivityCalendar { ...@@ -49,7 +55,7 @@ export default class ActivityCalendar {
timestamps, timestamps,
calendarActivitiesPath, calendarActivitiesPath,
utcOffset = 0, utcOffset = 0,
firstDayOfWeek = 0, firstDayOfWeek = firstDayOfWeekChoices.sunday,
monthsAgo = 12, monthsAgo = 12,
) { ) {
this.calendarActivitiesPath = calendarActivitiesPath; this.calendarActivitiesPath = calendarActivitiesPath;
...@@ -206,11 +212,16 @@ export default class ActivityCalendar { ...@@ -206,11 +212,16 @@ export default class ActivityCalendar {
}, },
]; ];
if (this.firstDayOfWeek === 1) { if (this.firstDayOfWeek === firstDayOfWeekChoices.monday) {
days.push({ days.push({
text: 'S', text: 'S',
y: 29 + this.dayYPos(7), y: 29 + this.dayYPos(7),
}); });
} else if (this.firstDayOfWeek === firstDayOfWeekChoices.saturday) {
days.push({
text: 'S',
y: 29 + this.dayYPos(6),
});
} }
this.svg this.svg
......
...@@ -46,7 +46,8 @@ module PreferencesHelper ...@@ -46,7 +46,8 @@ module PreferencesHelper
def first_day_of_week_choices def first_day_of_week_choices
[ [
[_('Sunday'), 0], [_('Sunday'), 0],
[_('Monday'), 1] [_('Monday'), 1],
[_('Saturday'), 6]
] ]
end end
......
...@@ -186,7 +186,7 @@ are listed in the descriptions of the relevant settings. ...@@ -186,7 +186,7 @@ are listed in the descriptions of the relevant settings.
| `external_authorization_service_timeout` | float | required by: `external_authorization_service_enabled` | **(Premium)** The timeout after which an authorization request is aborted, in seconds. When a request times out, access is denied to the user. (min: 0.001, max: 10, step: 0.001) | | `external_authorization_service_timeout` | float | required by: `external_authorization_service_enabled` | **(Premium)** The timeout after which an authorization request is aborted, in seconds. When a request times out, access is denied to the user. (min: 0.001, max: 10, step: 0.001) |
| `external_authorization_service_url` | string | required by: `external_authorization_service_enabled` | **(Premium)** URL to which authorization requests will be directed | | `external_authorization_service_url` | string | required by: `external_authorization_service_enabled` | **(Premium)** URL to which authorization requests will be directed |
| `file_template_project_id` | integer | no | **(Premium)** The ID of a project to load custom file templates from | | `file_template_project_id` | integer | no | **(Premium)** The ID of a project to load custom file templates from |
| `first_day_of_week` | integer | no | Start day of the week for calendar views and date pickers. Valid values are `0` (default) for Sunday and `1` for Monday. | | `first_day_of_week` | integer | no | Start day of the week for calendar views and date pickers. Valid values are `0` (default) for Sunday, `1` for Monday, and `6` for Saturday. |
| `geo_status_timeout` | integer | no | **(Premium)** The amount of seconds after which a request to get a secondary node status will time out. | | `geo_status_timeout` | integer | no | **(Premium)** The amount of seconds after which a request to get a secondary node status will time out. |
| `gitaly_timeout_default` | integer | no | Default Gitaly timeout, in seconds. This timeout is not enforced for git fetch/push operations or Sidekiq jobs. Set to `0` to disable timeouts. | | `gitaly_timeout_default` | integer | no | Default Gitaly timeout, in seconds. This timeout is not enforced for git fetch/push operations or Sidekiq jobs. Set to `0` to disable timeouts. |
| `gitaly_timeout_fast` | integer | no | Gitaly fast operation timeout, in seconds. Some Gitaly operations are expected to be fast. If they exceed this threshold, there may be a problem with a storage shard and 'failing fast' can help maintain the stability of the GitLab instance. Set to `0` to disable timeouts. | | `gitaly_timeout_fast` | integer | no | Gitaly fast operation timeout, in seconds. Some Gitaly operations are expected to be fast. If they exceed this threshold, there may be a problem with a storage shard and 'failing fast' can help maintain the stability of the GitLab instance. Set to `0` to disable timeouts. |
......
...@@ -103,4 +103,10 @@ Select your preferred language from a list of supported languages. ...@@ -103,4 +103,10 @@ Select your preferred language from a list of supported languages.
The first day of the week can be customised for calendar views and date pickers. The first day of the week can be customised for calendar views and date pickers.
You can choose **Sunday** or **Monday** as the first day of the week. If you select **System Default**, the system-wide default setting will be used. You can choose one of the following options as the first day of the week:
- Saturday
- Sunday
- Monday
If you select **System Default**, the system-wide default setting will be used.
...@@ -8519,6 +8519,9 @@ msgstr "" ...@@ -8519,6 +8519,9 @@ msgstr ""
msgid "SSL Verification" msgid "SSL Verification"
msgstr "" msgstr ""
msgid "Saturday"
msgstr ""
msgid "Save" msgid "Save"
msgstr "" msgstr ""
......
...@@ -36,10 +36,11 @@ describe PreferencesHelper do ...@@ -36,10 +36,11 @@ describe PreferencesHelper do
end end
describe '#first_day_of_week_choices' do describe '#first_day_of_week_choices' do
it 'returns Sunday and Monday as choices' do it 'returns Saturday, Sunday and Monday as choices' do
expect(helper.first_day_of_week_choices).to eq [ expect(helper.first_day_of_week_choices).to eq [
['Sunday', 0], ['Sunday', 0],
['Monday', 1] ['Monday', 1],
['Saturday', 6]
] ]
end end
end end
...@@ -47,14 +48,21 @@ describe PreferencesHelper do ...@@ -47,14 +48,21 @@ describe PreferencesHelper do
describe '#first_day_of_week_choices_with_default' do describe '#first_day_of_week_choices_with_default' do
it 'returns choices including system default' do it 'returns choices including system default' do
expect(helper.first_day_of_week_choices_with_default).to eq [ expect(helper.first_day_of_week_choices_with_default).to eq [
['System default (Sunday)', nil], ['Sunday', 0], ['Monday', 1] ['System default (Sunday)', nil], ['Sunday', 0], ['Monday', 1], ['Saturday', 6]
] ]
end end
it 'returns choices including system default set to Monday' do it 'returns choices including system default set to Monday' do
stub_application_setting(first_day_of_week: 1) stub_application_setting(first_day_of_week: 1)
expect(helper.first_day_of_week_choices_with_default).to eq [ expect(helper.first_day_of_week_choices_with_default).to eq [
['System default (Monday)', nil], ['Sunday', 0], ['Monday', 1] ['System default (Monday)', nil], ['Sunday', 0], ['Monday', 1], ['Saturday', 6]
]
end
it 'returns choices including system default set to Saturday' do
stub_application_setting(first_day_of_week: 6)
expect(helper.first_day_of_week_choices_with_default).to eq [
['System default (Saturday)', nil], ['Sunday', 0], ['Monday', 1], ['Saturday', 6]
] ]
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment