From f1c788bb1836083e4f5ed91c1c7494244e6e13ee Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 21 Nov 2023 15:13:27 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../javascripts/graphql_shared/issuable_client.js | 2 +- .../javascripts/graphql_shared/possible_types.json | 1 + .../lib/utils/datetime/locale_dateformat.js | 58 ++++++++++++++++++---- .../lib/utils/datetime/timeago_utility.js | 3 +- .../sidebar/components/archived_filter/index.vue | 4 +- .../search/sidebar/components/filters_template.vue | 6 ++- .../sidebar/components/label_filter/index.vue | 6 +-- .../sidebar/components/language_filter/index.vue | 4 +- .../search/sidebar/components/radio_filter.vue | 4 +- .../javascripts/vue_shared/mixins/timeago.js | 4 +- app/graphql/mutations/projects/star.rb | 39 +++++++++++++++ app/graphql/types/current_user_type.rb | 12 +++++ app/graphql/types/mutation_type.rb | 1 + app/graphql/types/query_type.rb | 2 +- app/graphql/types/user_interface.rb | 2 - app/graphql/types/user_type.rb | 2 + app/models/merge_request.rb | 10 +--- app/models/merge_request_diff.rb | 11 ++++ 18 files changed, 134 insertions(+), 37 deletions(-) create mode 100644 app/graphql/mutations/projects/star.rb create mode 100644 app/graphql/types/current_user_type.rb (limited to 'app') diff --git a/app/assets/javascripts/graphql_shared/issuable_client.js b/app/assets/javascripts/graphql_shared/issuable_client.js index 9537c9ef8a6..d0ba34b6127 100644 --- a/app/assets/javascripts/graphql_shared/issuable_client.js +++ b/app/assets/javascripts/graphql_shared/issuable_client.js @@ -146,7 +146,7 @@ export const config = { }, IssueConnection: { merge(existing = { nodes: [] }, incoming, { args }) { - if (!args.after) { + if (!args?.after) { return incoming; } return { diff --git a/app/assets/javascripts/graphql_shared/possible_types.json b/app/assets/javascripts/graphql_shared/possible_types.json index ee5f8c2ac2f..4ef0d067030 100644 --- a/app/assets/javascripts/graphql_shared/possible_types.json +++ b/app/assets/javascripts/graphql_shared/possible_types.json @@ -150,6 +150,7 @@ "User": [ "AddOnUser", "AutocompletedUser", + "CurrentUser", "MergeRequestAssignee", "MergeRequestAuthor", "MergeRequestParticipant", diff --git a/app/assets/javascripts/lib/utils/datetime/locale_dateformat.js b/app/assets/javascripts/lib/utils/datetime/locale_dateformat.js index 81922c4da1d..f1446fa5ac4 100644 --- a/app/assets/javascripts/lib/utils/datetime/locale_dateformat.js +++ b/app/assets/javascripts/lib/utils/datetime/locale_dateformat.js @@ -3,25 +3,36 @@ import { createDateTimeFormat } from '~/locale'; /** * Format a Date with the help of {@link DateTimeFormat.asDateTime} * - * Note: In case you can use localDateFormat.asDateTime directly, please do that. + * Note: In case you can use localeDateFormat.asDateTime directly, please do that. * * @example - * localDateFormat[DATE_WITH_TIME_FORMAT].format(date) // returns 'Jul 6, 2020, 2:43 PM' - * localDateFormat[DATE_WITH_TIME_FORMAT].formatRange(date, date) // returns 'Jul 6, 2020, 2:45PM – 8:43 PM' + * localeDateFormat[DATE_WITH_TIME_FORMAT].format(date) // returns 'Jul 6, 2020, 2:43 PM' + * localeDateFormat[DATE_WITH_TIME_FORMAT].formatRange(date, date) // returns 'Jul 6, 2020, 2:45PM – 8:43 PM' */ export const DATE_WITH_TIME_FORMAT = 'asDateTime'; + +/** + * Format a Date with the help of {@link DateTimeFormat.asDateTimeFull} + * + * Note: In case you can use localeDateFormat.asDateTimeFull directly, please do that. + * + * @example + * localeDateFormat[DATE_TIME_FULL_FORMAT].format(date) // returns 'July 6, 2020 at 2:43:12 PM GMT' + */ +export const DATE_TIME_FULL_FORMAT = 'asDateTimeFull'; + /** * Format a Date with the help of {@link DateTimeFormat.asDate} * - * Note: In case you can use localDateFormat.asDate directly, please do that. + * Note: In case you can use localeDateFormat.asDate directly, please do that. * * @example - * localDateFormat[DATE_ONLY_FORMAT].format(date) // returns 'Jul 05, 2023' - * localDateFormat[DATE_ONLY_FORMAT].formatRange(date, date) // returns 'Jul 05 - Jul 07, 2023' + * localeDateFormat[DATE_ONLY_FORMAT].format(date) // returns 'Jul 05, 2023' + * localeDateFormat[DATE_ONLY_FORMAT].formatRange(date, date) // returns 'Jul 05 - Jul 07, 2023' */ export const DATE_ONLY_FORMAT = 'asDate'; export const DEFAULT_DATE_TIME_FORMAT = DATE_WITH_TIME_FORMAT; -export const DATE_TIME_FORMATS = [DATE_WITH_TIME_FORMAT, DATE_ONLY_FORMAT]; +export const DATE_TIME_FORMATS = [DATE_WITH_TIME_FORMAT, DATE_TIME_FULL_FORMAT, DATE_ONLY_FORMAT]; /** * The DateTimeFormat utilities support formatting a number of types, @@ -54,7 +65,7 @@ class DateTimeFormat { * @example * // en-US: returns something like Jul 6, 2020, 2:43 PM * // en-GB: returns something like 6 Jul 2020, 14:43 - * localDateFormat.asDateTime.format(date) + * localeDateFormat.asDateTime.format(date) * * @returns {DateTimeFormatter} */ @@ -68,6 +79,32 @@ class DateTimeFormat { }) ); } + /** + * Locale aware formatter to a complete date time. + * + * This is needed if you need to convey a full timestamp including timezone and seconds. + * + * This is mainly used in tooltips. Use {@link DateTimeFormat.asDateTime} + * if you don't need to show all the information. + * + * + * @example + * // en-US: returns something like July 6, 2020 at 2:43:12 PM GMT + * // en-GB: returns something like 6 July 2020 at 14:43:12 GMT + * localeDateFormat.asDateTimeFull.format(date) + * + * @returns {DateTimeFormatter} + */ + get asDateTimeFull() { + return ( + this.#formatters[DATE_TIME_FULL_FORMAT] || + this.#createFormatter(DATE_TIME_FULL_FORMAT, { + dateStyle: 'long', + timeStyle: 'long', + hourCycle: DateTimeFormat.#hourCycle, + }) + ); + } /** * Locale aware formatter to display a only the date. @@ -77,12 +114,12 @@ class DateTimeFormat { * @example * // en-US: returns something like Jul 6, 2020 * // en-GB: returns something like 6 Jul 2020 - * localDateFormat.asDate.format(date) + * localeDateFormat.asDate.format(date) * * @example * // en-US: returns something like Jul 6 – 7, 2020 * // en-GB: returns something like 6-7 Jul 2020 - * localDateFormat.asDate.formatRange(date, date2) + * localeDateFormat.asDate.formatRange(date, date2) * * @returns {DateTimeFormatter} */ @@ -177,6 +214,7 @@ class DateTimeFormat { * * DateTime (showing both date and times): * - {@link DateTimeFormat.asDateTime localeDateFormat.asDateTime} - the default format for date times + * - {@link DateTimeFormat.asDateTimeFull localeDateFormat.asDateTimeFull} - full format, including timezone and seconds * * Date (showing date only): * - {@link DateTimeFormat.asDate localeDateFormat.asDate} - the default format for a date diff --git a/app/assets/javascripts/lib/utils/datetime/timeago_utility.js b/app/assets/javascripts/lib/utils/datetime/timeago_utility.js index a25acd5c711..3a94b26ee35 100644 --- a/app/assets/javascripts/lib/utils/datetime/timeago_utility.js +++ b/app/assets/javascripts/lib/utils/datetime/timeago_utility.js @@ -1,7 +1,6 @@ import * as timeago from 'timeago.js'; import { languageCode, s__ } from '~/locale'; import { DEFAULT_DATE_TIME_FORMAT, localeDateFormat } from '~/lib/utils/datetime/locale_dateformat'; -import { formatDate } from './date_format_utility'; /** * Timeago uses underscores instead of dashes to separate language from country code. @@ -130,7 +129,7 @@ export const localTimeAgo = (elements, updateTooltip = true) => { function addTimeAgoTooltip() { elements.forEach((el) => { // Recreate with custom template - el.setAttribute('title', formatDate(el.dateTime)); + el.setAttribute('title', localeDateFormat.asDateTimeFull.format(el.dateTime)); }); } diff --git a/app/assets/javascripts/search/sidebar/components/archived_filter/index.vue b/app/assets/javascripts/search/sidebar/components/archived_filter/index.vue index 914ff99075b..0308db17dc4 100644 --- a/app/assets/javascripts/search/sidebar/components/archived_filter/index.vue +++ b/app/assets/javascripts/search/sidebar/components/archived_filter/index.vue @@ -48,9 +48,9 @@ export default {