diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-22 15:11:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-22 15:11:32 +0300 |
commit | f7b08f4264cfe86b35051778699dafc55efdbf5d (patch) | |
tree | 60b70334489f2631096271c85a01b8ff9eaa7653 /app/assets/javascripts/analytics | |
parent | a48f9b5872853f31f6a46ddf58117390e788b776 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/analytics')
3 files changed, 22 insertions, 27 deletions
diff --git a/app/assets/javascripts/analytics/cycle_analytics/bundle.js b/app/assets/javascripts/analytics/cycle_analytics/bundle.js new file mode 100644 index 00000000000..9fe31620938 --- /dev/null +++ b/app/assets/javascripts/analytics/cycle_analytics/bundle.js @@ -0,0 +1 @@ +export { default } from '~/analytics/cycle_analytics'; diff --git a/app/assets/javascripts/analytics/cycle_analytics/utils.js b/app/assets/javascripts/analytics/cycle_analytics/utils.js index 9265ff952e0..939378a463e 100644 --- a/app/assets/javascripts/analytics/cycle_analytics/utils.js +++ b/app/assets/javascripts/analytics/cycle_analytics/utils.js @@ -1,3 +1,4 @@ +import { extractVSAFeaturesFromGON } from '~/analytics/shared/utils'; import { parseSeconds } from '~/lib/utils/datetime_utility'; import { formatTimeAsSummary } from '~/lib/utils/datetime/date_format_utility'; import { joinPaths } from '~/lib/utils/url_utility'; @@ -64,28 +65,6 @@ export const filterStagesByHiddenStatus = (stages = [], isHidden = true) => stages.filter(({ hidden = false }) => hidden === isHidden); /** - * @typedef {Object} MetricData - * @property {String} title - Title of the metric measured - * @property {String} value - String representing the decimal point value, e.g '1.5' - * @property {String} [unit] - String representing the decimal point value, e.g '1.5' - * - * @typedef {Object} TransformedMetricData - * @property {String} label - Title of the metric measured - * @property {String} value - String representing the decimal point value, e.g '1.5' - * @property {String} identifier - Slugified string based on the 'title' or the provided 'identifier' attribute - * @property {String} description - String to display for a description - * @property {String} unit - String representing the decimal point value, e.g '1.5' - */ - -const extractFeatures = (gon) => ({ - // licensed feature toggles - cycleAnalyticsForGroups: Boolean(gon?.licensed_features?.cycleAnalyticsForGroups), - groupLevelAnalyticsDashboard: Boolean(gon?.licensed_features?.groupLevelAnalyticsDashboard), - // feature flags - groupAnalyticsDashboardsPage: Boolean(gon?.features?.groupAnalyticsDashboardsPage), -}); - -/** * Builds the initial data object for Value Stream Analytics with data loaded from the backend * * @param {Object} dataset - dataset object paseed to the frontend via data-* properties @@ -99,7 +78,6 @@ export const buildCycleAnalyticsInitialData = ({ createdBefore, namespaceName, namespaceFullPath, - gon, } = {}) => { return { projectId: parseInt(projectId, 10), @@ -111,7 +89,7 @@ export const buildCycleAnalyticsInitialData = ({ createdAfter: new Date(createdAfter), createdBefore: new Date(createdBefore), selectedStage: stage ? JSON.parse(stage) : null, - features: extractFeatures(gon), + features: extractVSAFeaturesFromGON(), }; }; diff --git a/app/assets/javascripts/analytics/shared/utils.js b/app/assets/javascripts/analytics/shared/utils.js index a85f3fb3730..88a0f6f30cb 100644 --- a/app/assets/javascripts/analytics/shared/utils.js +++ b/app/assets/javascripts/analytics/shared/utils.js @@ -129,12 +129,28 @@ export const fetchMetricsData = (requests = [], requestPath, params) => { * @param {Array} projectPaths - Array of project paths to include in the `query` parameter * @returns a URL or blank string if there is no groupPath set */ -export const generateValueStreamsDashboardLink = (groupPath, projectPaths = []) => { - if (groupPath.length) { +export const generateValueStreamsDashboardLink = (namespacePath, projectPaths = []) => { + if (namespacePath.length) { const query = projectPaths.length ? `?query=${projectPaths.join(',')}` : ''; const dashboardsSlug = '/-/analytics/dashboards/value_streams_dashboard'; - const segments = [gon.relative_url_root || '', '/', groupPath, dashboardsSlug]; + const segments = [gon.relative_url_root || '', '/', namespacePath, dashboardsSlug]; return joinPaths(...segments).concat(query); } return ''; }; + +/** + * Extracts the relevant feature and license flags needed for VSA + * + * @param {Object} gon the global `window.gon` object populated when the page loads + * @returns an object containing the extracted feature flags and their boolean status + */ +export const extractVSAFeaturesFromGON = () => ({ + // licensed feature toggles + cycleAnalyticsForGroups: Boolean(gon?.licensed_features?.cycleAnalyticsForGroups), + cycleAnalyticsForProjects: Boolean(gon?.licensed_features?.cycleAnalyticsForProjects), + groupLevelAnalyticsDashboard: Boolean(gon?.licensed_features?.groupLevelAnalyticsDashboard), + // feature flags + groupAnalyticsDashboardsPage: Boolean(gon?.features?.groupAnalyticsDashboardsPage), + vsaGroupAndProjectParity: Boolean(gon?.features?.vsaGroupAndProjectParity), +}); |