debian-mirror-gitlab/app/assets/javascripts/sidebar/constants.js

321 lines
12 KiB
JavaScript
Raw Normal View History

2022-01-26 12:08:38 +05:30
import { s__, sprintf } from '~/locale';
2021-12-11 22:18:48 +05:30
import updateIssueLabelsMutation from '~/boards/graphql/issue_set_labels.mutation.graphql';
2022-05-07 20:08:51 +05:30
import userSearchQuery from '~/graphql_shared/queries/users_search.query.graphql';
import userSearchWithMRPermissionsQuery from '~/graphql_shared/queries/users_search_with_mr_permissions.graphql';
2022-01-26 12:08:38 +05:30
import { IssuableType, WorkspaceType } from '~/issues/constants';
2021-04-17 20:07:23 +05:30
import epicConfidentialQuery from '~/sidebar/queries/epic_confidential.query.graphql';
2021-06-08 01:23:25 +05:30
import epicDueDateQuery from '~/sidebar/queries/epic_due_date.query.graphql';
import epicParticipantsQuery from '~/sidebar/queries/epic_participants.query.graphql';
2021-09-30 23:02:18 +05:30
import epicReferenceQuery from '~/sidebar/queries/epic_reference.query.graphql';
2021-06-08 01:23:25 +05:30
import epicStartDateQuery from '~/sidebar/queries/epic_start_date.query.graphql';
import epicSubscribedQuery from '~/sidebar/queries/epic_subscribed.query.graphql';
2021-09-30 23:02:18 +05:30
import epicTodoQuery from '~/sidebar/queries/epic_todo.query.graphql';
2021-06-08 01:23:25 +05:30
import issuableAssigneesSubscription from '~/sidebar/queries/issuable_assignees.subscription.graphql';
2021-04-17 20:07:23 +05:30
import issueConfidentialQuery from '~/sidebar/queries/issue_confidential.query.graphql';
2021-04-29 21:17:54 +05:30
import issueDueDateQuery from '~/sidebar/queries/issue_due_date.query.graphql';
2021-04-17 20:07:23 +05:30
import issueReferenceQuery from '~/sidebar/queries/issue_reference.query.graphql';
2021-06-08 01:23:25 +05:30
import issueSubscribedQuery from '~/sidebar/queries/issue_subscribed.query.graphql';
2021-09-04 01:27:46 +05:30
import issueTimeTrackingQuery from '~/sidebar/queries/issue_time_tracking.query.graphql';
2021-09-30 23:02:18 +05:30
import issueTodoQuery from '~/sidebar/queries/issue_todo.query.graphql';
import mergeRequestMilestone from '~/sidebar/queries/merge_request_milestone.query.graphql';
2021-04-17 20:07:23 +05:30
import mergeRequestReferenceQuery from '~/sidebar/queries/merge_request_reference.query.graphql';
2021-06-08 01:23:25 +05:30
import mergeRequestSubscribed from '~/sidebar/queries/merge_request_subscribed.query.graphql';
2021-09-04 01:27:46 +05:30
import mergeRequestTimeTrackingQuery from '~/sidebar/queries/merge_request_time_tracking.query.graphql';
2021-09-30 23:02:18 +05:30
import mergeRequestTodoQuery from '~/sidebar/queries/merge_request_todo.query.graphql';
import todoCreateMutation from '~/sidebar/queries/todo_create.mutation.graphql';
import todoMarkDoneMutation from '~/sidebar/queries/todo_mark_done.mutation.graphql';
2021-06-08 01:23:25 +05:30
import updateEpicConfidentialMutation from '~/sidebar/queries/update_epic_confidential.mutation.graphql';
import updateEpicDueDateMutation from '~/sidebar/queries/update_epic_due_date.mutation.graphql';
import updateEpicStartDateMutation from '~/sidebar/queries/update_epic_start_date.mutation.graphql';
import updateEpicSubscriptionMutation from '~/sidebar/queries/update_epic_subscription.mutation.graphql';
2021-04-17 20:07:23 +05:30
import updateIssueConfidentialMutation from '~/sidebar/queries/update_issue_confidential.mutation.graphql';
2021-04-29 21:17:54 +05:30
import updateIssueDueDateMutation from '~/sidebar/queries/update_issue_due_date.mutation.graphql';
2021-06-08 01:23:25 +05:30
import updateIssueSubscriptionMutation from '~/sidebar/queries/update_issue_subscription.mutation.graphql';
2021-09-30 23:02:18 +05:30
import mergeRequestMilestoneMutation from '~/sidebar/queries/update_merge_request_milestone.mutation.graphql';
2021-12-11 22:18:48 +05:30
import updateMergeRequestLabelsMutation from '~/sidebar/queries/update_merge_request_labels.mutation.graphql';
2021-06-08 01:23:25 +05:30
import updateMergeRequestSubscriptionMutation from '~/sidebar/queries/update_merge_request_subscription.mutation.graphql';
2021-09-04 01:27:46 +05:30
import updateAlertAssigneesMutation from '~/vue_shared/alert_details/graphql/mutations/alert_set_assignees.mutation.graphql';
2021-11-18 22:05:49 +05:30
import epicLabelsQuery from '~/vue_shared/components/sidebar/labels_select_widget/graphql/epic_labels.query.graphql';
2021-12-11 22:18:48 +05:30
import updateEpicLabelsMutation from '~/vue_shared/components/sidebar/labels_select_widget/graphql/epic_update_labels.mutation.graphql';
2021-11-18 22:05:49 +05:30
import groupLabelsQuery from '~/vue_shared/components/sidebar/labels_select_widget/graphql/group_labels.query.graphql';
import issueLabelsQuery from '~/vue_shared/components/sidebar/labels_select_widget/graphql/issue_labels.query.graphql';
2021-12-11 22:18:48 +05:30
import mergeRequestLabelsQuery from '~/vue_shared/components/sidebar/labels_select_widget/graphql/merge_request_labels.query.graphql';
2021-11-18 22:05:49 +05:30
import projectLabelsQuery from '~/vue_shared/components/sidebar/labels_select_widget/graphql/project_labels.query.graphql';
2021-09-04 01:27:46 +05:30
import getAlertAssignees from '~/vue_shared/components/sidebar/queries/get_alert_assignees.query.graphql';
2021-06-08 01:23:25 +05:30
import getIssueAssignees from '~/vue_shared/components/sidebar/queries/get_issue_assignees.query.graphql';
import issueParticipantsQuery from '~/vue_shared/components/sidebar/queries/get_issue_participants.query.graphql';
import getIssueTimelogsQuery from '~/vue_shared/components/sidebar/queries/get_issue_timelogs.query.graphql';
import getMergeRequestAssignees from '~/vue_shared/components/sidebar/queries/get_mr_assignees.query.graphql';
2021-03-11 19:13:27 +05:30
import getMergeRequestParticipants from '~/vue_shared/components/sidebar/queries/get_mr_participants.query.graphql';
2021-06-08 01:23:25 +05:30
import getMrTimelogsQuery from '~/vue_shared/components/sidebar/queries/get_mr_timelogs.query.graphql';
import updateIssueAssigneesMutation from '~/vue_shared/components/sidebar/queries/update_issue_assignees.mutation.graphql';
import updateMergeRequestAssigneesMutation from '~/vue_shared/components/sidebar/queries/update_mr_assignees.mutation.graphql';
2022-05-07 20:08:51 +05:30
import getEscalationStatusQuery from '~/sidebar/queries/escalation_status.query.graphql';
import updateEscalationStatusMutation from '~/sidebar/queries/update_escalation_status.mutation.graphql';
2021-09-04 01:27:46 +05:30
import projectIssueMilestoneMutation from './queries/project_issue_milestone.mutation.graphql';
import projectIssueMilestoneQuery from './queries/project_issue_milestone.query.graphql';
import projectMilestonesQuery from './queries/project_milestones.query.graphql';
2021-03-11 19:13:27 +05:30
2021-09-30 23:02:18 +05:30
export const defaultEpicSort = 'TITLE_ASC';
2021-04-17 20:07:23 +05:30
2021-10-27 15:23:28 +05:30
export const epicIidPattern = /^&(?<iid>\d+)$/;
2021-03-11 19:13:27 +05:30
export const assigneesQueries = {
[IssuableType.Issue]: {
2021-06-08 01:23:25 +05:30
query: getIssueAssignees,
subscription: issuableAssigneesSubscription,
mutation: updateIssueAssigneesMutation,
},
[IssuableType.MergeRequest]: {
query: getMergeRequestAssignees,
mutation: updateMergeRequestAssigneesMutation,
},
2021-09-04 01:27:46 +05:30
[IssuableType.Alert]: {
query: getAlertAssignees,
mutation: updateAlertAssigneesMutation,
},
2021-06-08 01:23:25 +05:30
};
export const participantsQueries = {
[IssuableType.Issue]: {
query: issueParticipantsQuery,
2021-03-11 19:13:27 +05:30
},
[IssuableType.MergeRequest]: {
query: getMergeRequestParticipants,
2021-06-08 01:23:25 +05:30
},
[IssuableType.Epic]: {
query: epicParticipantsQuery,
2021-03-11 19:13:27 +05:30
},
2021-09-04 01:27:46 +05:30
[IssuableType.Alert]: {
query: '',
skipQuery: true,
},
2021-03-11 19:13:27 +05:30
};
2021-04-17 20:07:23 +05:30
2022-05-07 20:08:51 +05:30
export const userSearchQueries = {
[IssuableType.Issue]: {
query: userSearchQuery,
},
[IssuableType.MergeRequest]: {
query: userSearchWithMRPermissionsQuery,
},
};
2021-04-17 20:07:23 +05:30
export const confidentialityQueries = {
[IssuableType.Issue]: {
query: issueConfidentialQuery,
mutation: updateIssueConfidentialMutation,
},
[IssuableType.Epic]: {
query: epicConfidentialQuery,
2021-06-08 01:23:25 +05:30
mutation: updateEpicConfidentialMutation,
2021-04-17 20:07:23 +05:30
},
};
export const referenceQueries = {
[IssuableType.Issue]: {
query: issueReferenceQuery,
},
[IssuableType.MergeRequest]: {
query: mergeRequestReferenceQuery,
},
2021-09-30 23:02:18 +05:30
[IssuableType.Epic]: {
query: epicReferenceQuery,
},
2021-04-17 20:07:23 +05:30
};
2021-04-29 21:17:54 +05:30
2021-12-11 22:18:48 +05:30
export const workspaceLabelsQueries = {
[WorkspaceType.project]: {
query: projectLabelsQuery,
},
[WorkspaceType.group]: {
query: groupLabelsQuery,
},
};
export const issuableLabelsQueries = {
2021-11-18 22:05:49 +05:30
[IssuableType.Issue]: {
issuableQuery: issueLabelsQuery,
2021-12-11 22:18:48 +05:30
mutation: updateIssueLabelsMutation,
mutationName: 'updateIssue',
},
[IssuableType.MergeRequest]: {
issuableQuery: mergeRequestLabelsQuery,
mutation: updateMergeRequestLabelsMutation,
mutationName: 'mergeRequestSetLabels',
2021-11-18 22:05:49 +05:30
},
[IssuableType.Epic]: {
issuableQuery: epicLabelsQuery,
2021-12-11 22:18:48 +05:30
mutation: updateEpicLabelsMutation,
mutationName: 'updateEpic',
2021-11-18 22:05:49 +05:30
},
};
2021-06-08 01:23:25 +05:30
export const dateTypes = {
start: 'startDate',
due: 'dueDate',
};
export const dateFields = {
[dateTypes.start]: {
isDateFixed: 'startDateIsFixed',
dateFixed: 'startDateFixed',
dateFromMilestones: 'startDateFromMilestones',
},
[dateTypes.due]: {
isDateFixed: 'dueDateIsFixed',
dateFixed: 'dueDateFixed',
dateFromMilestones: 'dueDateFromMilestones',
},
};
export const subscribedQueries = {
[IssuableType.Issue]: {
query: issueSubscribedQuery,
mutation: updateIssueSubscriptionMutation,
},
[IssuableType.Epic]: {
query: epicSubscribedQuery,
mutation: updateEpicSubscriptionMutation,
},
[IssuableType.MergeRequest]: {
query: mergeRequestSubscribed,
mutation: updateMergeRequestSubscriptionMutation,
},
};
2021-09-30 23:02:18 +05:30
export const Tracking = {
editEvent: 'click_edit_button',
rightSidebarLabel: 'right_sidebar',
};
2021-09-04 01:27:46 +05:30
export const timeTrackingQueries = {
[IssuableType.Issue]: {
query: issueTimeTrackingQuery,
},
[IssuableType.MergeRequest]: {
query: mergeRequestTimeTrackingQuery,
},
};
2021-04-29 21:17:54 +05:30
export const dueDateQueries = {
[IssuableType.Issue]: {
query: issueDueDateQuery,
mutation: updateIssueDueDateMutation,
},
2021-06-08 01:23:25 +05:30
[IssuableType.Epic]: {
query: epicDueDateQuery,
mutation: updateEpicDueDateMutation,
},
};
export const startDateQueries = {
[IssuableType.Epic]: {
query: epicStartDateQuery,
mutation: updateEpicStartDateMutation,
},
};
export const timelogQueries = {
[IssuableType.Issue]: {
query: getIssueTimelogsQuery,
},
[IssuableType.MergeRequest]: {
query: getMrTimelogsQuery,
},
2021-04-29 21:17:54 +05:30
};
2021-09-04 01:27:46 +05:30
export const noAttributeId = null;
export const issuableMilestoneQueries = {
[IssuableType.Issue]: {
query: projectIssueMilestoneQuery,
mutation: projectIssueMilestoneMutation,
},
2021-09-30 23:02:18 +05:30
[IssuableType.MergeRequest]: {
query: mergeRequestMilestone,
mutation: mergeRequestMilestoneMutation,
},
2021-09-04 01:27:46 +05:30
};
export const milestonesQueries = {
[IssuableType.Issue]: {
query: projectMilestonesQuery,
},
2021-09-30 23:02:18 +05:30
[IssuableType.MergeRequest]: {
query: projectMilestonesQuery,
},
2021-09-04 01:27:46 +05:30
};
export const IssuableAttributeType = {
Milestone: 'milestone',
};
export const IssuableAttributeState = {
[IssuableAttributeType.Milestone]: 'active',
};
export const issuableAttributesQueries = {
[IssuableAttributeType.Milestone]: {
current: issuableMilestoneQueries,
list: milestonesQueries,
},
};
2021-09-30 23:02:18 +05:30
export const todoQueries = {
[IssuableType.Epic]: {
query: epicTodoQuery,
},
[IssuableType.Issue]: {
query: issueTodoQuery,
},
[IssuableType.MergeRequest]: {
query: mergeRequestTodoQuery,
},
};
export const TodoMutationTypes = {
Create: 'create',
MarkDone: 'mark-done',
};
export const todoMutations = {
[TodoMutationTypes.Create]: todoCreateMutation,
[TodoMutationTypes.MarkDone]: todoMarkDoneMutation,
};
2022-01-26 12:08:38 +05:30
export function dropdowni18nText(issuableAttribute, issuableType) {
return {
noAttribute: sprintf(s__('DropdownWidget|No %{issuableAttribute}'), {
issuableAttribute,
}),
assignAttribute: sprintf(s__('DropdownWidget|Assign %{issuableAttribute}'), {
issuableAttribute,
}),
noAttributesFound: sprintf(s__('DropdownWidget|No %{issuableAttribute} found'), {
issuableAttribute,
}),
updateError: sprintf(
s__(
'DropdownWidget|Failed to set %{issuableAttribute} on this %{issuableType}. Please try again.',
),
{ issuableAttribute, issuableType },
),
listFetchError: sprintf(
s__(
'DropdownWidget|Failed to fetch the %{issuableAttribute} for this %{issuableType}. Please try again.',
),
{ issuableAttribute, issuableType },
),
currentFetchError: sprintf(
s__(
'DropdownWidget|An error occurred while fetching the assigned %{issuableAttribute} of the selected %{issuableType}.',
),
{ issuableAttribute, issuableType },
),
};
}
2022-05-07 20:08:51 +05:30
export const escalationStatusQuery = getEscalationStatusQuery;
export const escalationStatusMutation = updateEscalationStatusMutation;