diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-05 12:18:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-05 12:18:51 +0300 |
commit | 01625f2465779254cfdd08697c4955cf3af05a1f (patch) | |
tree | c1610ee26e9ce2e2313f42103c9134f82d575e4e /app/assets/javascripts | |
parent | 0e31e4396d76a8d723a26354278295fd0c51d9c7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts')
7 files changed, 94 insertions, 3 deletions
diff --git a/app/assets/javascripts/analytics/shared/constants.js b/app/assets/javascripts/analytics/shared/constants.js index 93f7f800fd0..e48281a7453 100644 --- a/app/assets/javascripts/analytics/shared/constants.js +++ b/app/assets/javascripts/analytics/shared/constants.js @@ -6,6 +6,7 @@ import { getDateInPast, getCurrentUtcDate, nWeeksBefore, + nYearsBefore, } from '~/lib/utils/datetime_utility'; import { s__, __, sprintf, n__ } from '~/locale'; import { helpPagePath } from '~/helpers/help_page_helper'; @@ -251,3 +252,43 @@ export const METRICS_POPOVER_CONTENT = { ), }, }; + +export const USAGE_OVERVIEW_NO_DATA_ERROR = s__( + 'ValueStreamAnalytics|Failed to load usage overview data', +); + +export const USAGE_OVERVIEW_DEFAULT_DATE_RANGE = { + endDate: TODAY, + startDate: nYearsBefore(TODAY, 1), +}; + +export const USAGE_OVERVIEW_IDENTIFIER_GROUPS = 'groups'; +export const USAGE_OVERVIEW_IDENTIFIER_PROJECTS = 'projects'; +export const USAGE_OVERVIEW_IDENTIFIER_ISSUES = 'issues'; +export const USAGE_OVERVIEW_IDENTIFIER_MERGE_REQUESTS = 'merge_requests'; +export const USAGE_OVERVIEW_IDENTIFIER_PIPELINES = 'pipelines'; + +// Defines the constants used for querying the API as well as the order they appear +export const USAGE_OVERVIEW_METADATA = { + [USAGE_OVERVIEW_IDENTIFIER_GROUPS]: { options: { title: __('Groups'), titleIcon: 'group' } }, + [USAGE_OVERVIEW_IDENTIFIER_PROJECTS]: { + options: { title: __('Projects'), titleIcon: 'project' }, + }, + [USAGE_OVERVIEW_IDENTIFIER_ISSUES]: { + options: { title: __('Issues'), titleIcon: 'issues' }, + }, + [USAGE_OVERVIEW_IDENTIFIER_MERGE_REQUESTS]: { + options: { title: __('Merge requests'), titleIcon: 'merge-request' }, + }, + [USAGE_OVERVIEW_IDENTIFIER_PIPELINES]: { + options: { title: __('Pipelines'), titleIcon: 'pipeline' }, + }, +}; + +export const USAGE_OVERVIEW_QUERY_INCLUDE_KEYS = { + [USAGE_OVERVIEW_IDENTIFIER_GROUPS]: 'includeGroups', + [USAGE_OVERVIEW_IDENTIFIER_PROJECTS]: 'includeProjects', + [USAGE_OVERVIEW_IDENTIFIER_ISSUES]: 'includeIssues', + [USAGE_OVERVIEW_IDENTIFIER_MERGE_REQUESTS]: 'includeMergeRequests', + [USAGE_OVERVIEW_IDENTIFIER_PIPELINES]: 'includePipelines', +}; diff --git a/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js b/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js index 4e0d19f2c2a..6484fcff769 100644 --- a/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js +++ b/app/assets/javascripts/lib/utils/datetime/date_calculation_utility.js @@ -413,6 +413,15 @@ export const nYearsAfter = (date, numberOfYears) => { }; /** + * Returns the date `n` years before the date provided. + * + * @param {Date} date the initial date + * @param {Number} numberOfYears number of years before + * @return {Date} A `Date` object `n` years before the provided `Date` + */ +export const nYearsBefore = (date, numberOfYears) => nYearsAfter(date, -numberOfYears); + +/** * Returns the date after the date provided * * @param {Date} date the initial date diff --git a/app/assets/javascripts/work_items/components/notes/work_item_note_actions.vue b/app/assets/javascripts/work_items/components/notes/work_item_note_actions.vue index cb9a560f9e1..445938ad56a 100644 --- a/app/assets/javascripts/work_items/components/notes/work_item_note_actions.vue +++ b/app/assets/javascripts/work_items/components/notes/work_item_note_actions.vue @@ -33,6 +33,7 @@ export default { directives: { GlTooltip: GlTooltipDirective, }, + inject: ['isGroup'], props: { fullPath: { type: String, @@ -152,6 +153,7 @@ export default { note: this.note, name, fullPath: this.fullPath, + isGroup: this.isGroup, workItemIid: this.workItemIid, }), }); diff --git a/app/assets/javascripts/work_items/components/notes/work_item_note_awards_list.vue b/app/assets/javascripts/work_items/components/notes/work_item_note_awards_list.vue index 75a8a7b29c0..c3b3c0e6db7 100644 --- a/app/assets/javascripts/work_items/components/notes/work_item_note_awards_list.vue +++ b/app/assets/javascripts/work_items/components/notes/work_item_note_awards_list.vue @@ -8,6 +8,7 @@ export default { components: { AwardsList, }, + inject: ['isGroup'], props: { fullPath: { type: String, @@ -73,6 +74,7 @@ export default { note: this.note, name, fullPath: this.fullPath, + isGroup: this.isGroup, workItemIid: this.workItemIid, }), }); diff --git a/app/assets/javascripts/work_items/components/work_item_notes.vue b/app/assets/javascripts/work_items/components/work_item_notes.vue index 6756acd4495..83958ee4ef3 100644 --- a/app/assets/javascripts/work_items/components/work_item_notes.vue +++ b/app/assets/javascripts/work_items/components/work_item_notes.vue @@ -28,6 +28,7 @@ import workItemNoteCreatedSubscription from '~/work_items/graphql/notes/work_ite import workItemNoteUpdatedSubscription from '~/work_items/graphql/notes/work_item_note_updated.subscription.graphql'; import workItemNoteDeletedSubscription from '~/work_items/graphql/notes/work_item_note_deleted.subscription.graphql'; import deleteNoteMutation from '../graphql/notes/delete_work_item_notes.mutation.graphql'; +import groupWorkItemNotesByIidQuery from '../graphql/notes/group_work_item_notes_by_iid.query.graphql'; import workItemNotesByIidQuery from '../graphql/notes/work_item_notes_by_iid.query.graphql'; import WorkItemAddNote from './notes/work_item_add_note.vue'; @@ -46,6 +47,7 @@ export default { WorkItemNotesActivityHeader, WorkItemHistoryOnlyFilterNote, }, + inject: ['isGroup'], props: { fullPath: { type: String, @@ -169,7 +171,9 @@ export default { }, apollo: { workItemNotes: { - query: workItemNotesByIidQuery, + query() { + return this.isGroup ? groupWorkItemNotesByIidQuery : workItemNotesByIidQuery; + }, variables() { return { fullPath: this.fullPath, diff --git a/app/assets/javascripts/work_items/graphql/notes/group_work_item_notes_by_iid.query.graphql b/app/assets/javascripts/work_items/graphql/notes/group_work_item_notes_by_iid.query.graphql new file mode 100644 index 00000000000..f86176b2836 --- /dev/null +++ b/app/assets/javascripts/work_items/graphql/notes/group_work_item_notes_by_iid.query.graphql @@ -0,0 +1,32 @@ +#import "~/graphql_shared/fragments/page_info.fragment.graphql" +#import "ee_else_ce/work_items/graphql/notes/work_item_note.fragment.graphql" + +query groupWorkItemNotesByIid($fullPath: ID!, $iid: String, $after: String, $pageSize: Int) { + workspace: group(fullPath: $fullPath) { + id + workItems(iid: $iid) { + nodes { + id + iid + widgets { + ... on WorkItemWidgetNotes { + type + discussions(first: $pageSize, after: $after, filter: ALL_NOTES) { + pageInfo { + ...PageInfo + } + nodes { + id + notes { + nodes { + ...WorkItemNote + } + } + } + } + } + } + } + } + } +} diff --git a/app/assets/javascripts/work_items/notes/award_utils.js b/app/assets/javascripts/work_items/notes/award_utils.js index 5351a22d593..4f35b06a685 100644 --- a/app/assets/javascripts/work_items/notes/award_utils.js +++ b/app/assets/javascripts/work_items/notes/award_utils.js @@ -5,6 +5,7 @@ import { updateCacheAfterAddingAwardEmojiToNote, updateCacheAfterRemovingAwardEmojiFromNote, } from '~/work_items/graphql/cache_utils'; +import groupWorkItemNotesByIidQuery from '../graphql/notes/group_work_item_notes_by_iid.query.graphql'; import workItemNotesByIidQuery from '../graphql/notes/work_item_notes_by_iid.query.graphql'; import addAwardEmojiMutation from '../graphql/notes/work_item_note_add_award_emoji.mutation.graphql'; import removeAwardEmojiMutation from '../graphql/notes/work_item_note_remove_award_emoji.mutation.graphql'; @@ -32,7 +33,7 @@ export function getMutation({ note, name }) { }; } -export function optimisticAwardUpdate({ note, name, fullPath, workItemIid }) { +export function optimisticAwardUpdate({ note, name, fullPath, isGroup, workItemIid }) { const { mutation } = getMutation({ note, name }); const currentUserId = window.gon.current_user_id; @@ -40,7 +41,7 @@ export function optimisticAwardUpdate({ note, name, fullPath, workItemIid }) { return (store) => { store.updateQuery( { - query: workItemNotesByIidQuery, + query: isGroup ? groupWorkItemNotesByIidQuery : workItemNotesByIidQuery, variables: { fullPath, iid: workItemIid }, }, (sourceData) => { |