diff --git a/.rubocop_todo/rails/include_url_helper.yml b/.rubocop_todo/rails/include_url_helper.yml index dcafeafb9f0..1d8f88e9be1 100644 --- a/.rubocop_todo/rails/include_url_helper.yml +++ b/.rubocop_todo/rails/include_url_helper.yml @@ -19,7 +19,6 @@ Rails/IncludeUrlHelper: - app/models/integrations/redmine.rb - app/models/integrations/webex_teams.rb - app/models/integrations/youtrack.rb - - app/presenters/gitlab/blame_presenter.rb - ee/app/models/integrations/github.rb - ee/spec/helpers/ee/projects/security/configuration_helper_spec.rb - ee/spec/lib/banzai/filter/cross_project_issuable_information_filter_spec.rb diff --git a/app/assets/javascripts/jobs/components/table/constants.js b/app/assets/javascripts/jobs/components/table/constants.js index 962979ba573..951d9324813 100644 --- a/app/assets/javascripts/jobs/components/table/constants.js +++ b/app/assets/javascripts/jobs/components/table/constants.js @@ -1,16 +1,6 @@ import { s__, __ } from '~/locale'; import { DEFAULT_TH_CLASSES } from '~/lib/utils/constants'; -export const GRAPHQL_PAGE_SIZE = 30; - -export const initialPaginationState = { - currentPage: 1, - prevPageCursor: '', - nextPageCursor: '', - first: GRAPHQL_PAGE_SIZE, - last: null, -}; - /* Error constants */ export const POST_FAILURE = 'post_failure'; export const DEFAULT = 'default'; diff --git a/app/assets/javascripts/jobs/components/table/graphql/cache_config.js b/app/assets/javascripts/jobs/components/table/graphql/cache_config.js new file mode 100644 index 00000000000..846efdf21ee --- /dev/null +++ b/app/assets/javascripts/jobs/components/table/graphql/cache_config.js @@ -0,0 +1,29 @@ +import { isEqual } from 'lodash'; + +export default { + typePolicies: { + Project: { + fields: { + jobs: { + keyArgs: false, + }, + }, + }, + CiJobConnection: { + merge(existing = {}, incoming, { args = {} }) { + let nodes; + + if (Object.keys(existing).length !== 0 && isEqual(existing?.statuses, args?.statuses)) { + nodes = [...existing.nodes, ...incoming.nodes]; + } else { + nodes = [...incoming.nodes]; + } + + return { + nodes, + statuses: Array.isArray(args.statuses) ? [...args.statuses] : args.statuses, + }; + }, + }, + }, +}; diff --git a/app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql b/app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql index 88937185a8c..151e49af87e 100644 --- a/app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql +++ b/app/assets/javascripts/jobs/components/table/graphql/queries/get_jobs.query.graphql @@ -1,25 +1,22 @@ -query getJobs( - $fullPath: ID! - $first: Int - $last: Int - $after: String - $before: String - $statuses: [CiJobStatus!] -) { +query getJobs($fullPath: ID!, $after: String, $statuses: [CiJobStatus!]) { project(fullPath: $fullPath) { id - jobs(after: $after, before: $before, first: $first, last: $last, statuses: $statuses) { + __typename + jobs(after: $after, first: 30, statuses: $statuses) { pageInfo { endCursor hasNextPage hasPreviousPage startCursor + __typename } nodes { + __typename artifacts { nodes { downloadPath fileType + __typename } } allowFailure diff --git a/app/assets/javascripts/jobs/components/table/index.js b/app/assets/javascripts/jobs/components/table/index.js index f24daf90815..1b9c7cdcfdd 100644 --- a/app/assets/javascripts/jobs/components/table/index.js +++ b/app/assets/javascripts/jobs/components/table/index.js @@ -4,12 +4,18 @@ import VueApollo from 'vue-apollo'; import JobsTableApp from '~/jobs/components/table/jobs_table_app.vue'; import createDefaultClient from '~/lib/graphql'; import { parseBoolean } from '~/lib/utils/common_utils'; +import cacheConfig from './graphql/cache_config'; Vue.use(VueApollo); Vue.use(GlToast); const apolloProvider = new VueApollo({ - defaultClient: createDefaultClient(), + defaultClient: createDefaultClient( + {}, + { + cacheConfig, + }, + ), }); export default (containerId = 'js-jobs-table') => { diff --git a/app/assets/javascripts/jobs/components/table/jobs_table_app.vue b/app/assets/javascripts/jobs/components/table/jobs_table_app.vue index 81f42c1e293..864e322eecd 100644 --- a/app/assets/javascripts/jobs/components/table/jobs_table_app.vue +++ b/app/assets/javascripts/jobs/components/table/jobs_table_app.vue @@ -1,7 +1,6 @@