debian-mirror-gitlab/app/assets/javascripts/work_items/utils.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-04-23 21:23:45 +05:30
import { WIDGET_TYPE_HIERARCHY } from '~/work_items/constants';
2023-01-13 00:05:48 +05:30
import workItemQuery from './graphql/work_item.query.graphql';
import workItemByIidQuery from './graphql/work_item_by_iid.query.graphql';
2023-04-23 21:23:45 +05:30
import workItemNotesIdQuery from './graphql/notes/work_item_notes.query.graphql';
import workItemNotesByIidQuery from './graphql/notes/work_item_notes_by_iid.query.graphql';
2023-01-13 00:05:48 +05:30
export function getWorkItemQuery(isFetchedByIid) {
return isFetchedByIid ? workItemByIidQuery : workItemQuery;
}
2023-03-04 22:38:38 +05:30
export function getWorkItemNotesQuery(isFetchedByIid) {
return isFetchedByIid ? workItemNotesByIidQuery : workItemNotesIdQuery;
}
2023-04-23 21:23:45 +05:30
export const findHierarchyWidgetChildren = (workItem) =>
workItem.widgets.find((widget) => widget.type === WIDGET_TYPE_HIERARCHY).children.nodes;
const autocompleteSourcesPath = (autocompleteType, fullPath, workItemIid) => {
return `${
gon.relative_url_root || ''
}/${fullPath}/-/autocomplete_sources/${autocompleteType}?type=WorkItem&type_id=${workItemIid}`;
};
export const autocompleteDataSources = (fullPath, iid) => ({
labels: autocompleteSourcesPath('labels', fullPath, iid),
members: autocompleteSourcesPath('members', fullPath, iid),
commands: autocompleteSourcesPath('commands', fullPath, iid),
});
export const markdownPreviewPath = (fullPath, iid) =>
`${
gon.relative_url_root || ''
}/${fullPath}/preview_markdown?target_type=WorkItem&target_id=${iid}`;