Commit 8c7225a3 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'led/340125-fix-pipelines-quota-pagination' into 'master'

Fix pipelines usage_quotas pagination

See merge request gitlab-org/gitlab!76092
parents 504d4a4c 633eb928
import $ from 'jquery';
import SeatUsageApp from 'ee/seat_usage'; import SeatUsageApp from 'ee/seat_usage';
import initNamespaceStorage from 'ee/usage_quotas/storage/init_namespace_storage'; import initNamespaceStorage from 'ee/usage_quotas/storage/init_namespace_storage';
import LinkedTabs from '~/lib/utils/bootstrap_linked_tabs'; import LinkedTabs from '~/lib/utils/bootstrap_linked_tabs';
...@@ -24,5 +25,30 @@ const initVueApps = () => { ...@@ -24,5 +25,30 @@ const initVueApps = () => {
} }
}; };
/**
* This adds the current URL hash to the pagingation links so that the page
* opens in the correct tab. This happens because rails pagination doesn't add
* URL hash, and it does a full page load, and then LinkedTabs looses track
* of the opened page. Once we move pipelines to Vue, we won't need this hotfix.
*
* To be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/345373
*/
const fixPipelinesPagination = () => {
const pipelinesQuotaTabLink = document.querySelector('#pipelines-quota');
const pipelinesQuotaTab = document.querySelector('#pipelines-quota-tab');
$(document).on('shown.bs.tab', (event) => {
if (event.target.id === pipelinesQuotaTabLink.id) {
const pageLinks = pipelinesQuotaTab.querySelectorAll('.page-link');
Array.from(pageLinks).forEach((pageLink) => {
// eslint-disable-next-line no-param-reassign
pageLink.href = pageLink.href.split('#')[0].concat(window.location.hash);
});
}
});
};
fixPipelinesPagination();
initVueApps(); initVueApps();
initLinkedTabs(); initLinkedTabs();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment