diff options
Diffstat (limited to 'app/assets/javascripts/ci/runner/graphql')
24 files changed, 434 insertions, 0 deletions
diff --git a/app/assets/javascripts/ci/runner/graphql/edit/runner_fields.fragment.graphql b/app/assets/javascripts/ci/runner/graphql/edit/runner_fields.fragment.graphql new file mode 100644 index 00000000000..b732d587d70 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/edit/runner_fields.fragment.graphql @@ -0,0 +1,5 @@ +#import "./runner_fields_shared.fragment.graphql" + +fragment RunnerFields on CiRunner { + ...RunnerFieldsShared +} diff --git a/app/assets/javascripts/ci/runner/graphql/edit/runner_fields_shared.fragment.graphql b/app/assets/javascripts/ci/runner/graphql/edit/runner_fields_shared.fragment.graphql new file mode 100644 index 00000000000..29abddf84f5 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/edit/runner_fields_shared.fragment.graphql @@ -0,0 +1,14 @@ +fragment RunnerFieldsShared on CiRunner { + id + shortSha + runnerType + active + accessLevel + runUntagged + locked + description + maximumTimeout + tagList + createdAt + status(legacyMode: null) +} diff --git a/app/assets/javascripts/ci/runner/graphql/edit/runner_form.query.graphql b/app/assets/javascripts/ci/runner/graphql/edit/runner_form.query.graphql new file mode 100644 index 00000000000..5599c147c56 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/edit/runner_form.query.graphql @@ -0,0 +1,7 @@ +#import "ee_else_ce/ci/runner/graphql/edit/runner_fields.fragment.graphql" + +query getRunnerForm($id: CiRunnerID!) { + runner(id: $id) { + ...RunnerFields + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/edit/runner_update.mutation.graphql b/app/assets/javascripts/ci/runner/graphql/edit/runner_update.mutation.graphql new file mode 100644 index 00000000000..9469078c317 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/edit/runner_update.mutation.graphql @@ -0,0 +1,13 @@ +#import "ee_else_ce/ci/runner/graphql/edit/runner_fields.fragment.graphql" + +# Mutation for updates from the runner form, loads +# attributes shown in the runner details. + +mutation runnerUpdate($input: RunnerUpdateInput!) { + runnerUpdate(input: $input) { + runner { + ...RunnerFields + } + errors + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/all_runners.query.graphql b/app/assets/javascripts/ci/runner/graphql/list/all_runners.query.graphql new file mode 100644 index 00000000000..15401c25c64 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/all_runners.query.graphql @@ -0,0 +1,29 @@ +#import "~/ci/runner/graphql/list/all_runners_connection.fragment.graphql" + +query getAllRunners( + $before: String + $after: String + $first: Int + $last: Int + $paused: Boolean + $status: CiRunnerStatus + $type: CiRunnerType + $tagList: [String!] + $search: String + $sort: CiRunnerSort +) { + runners( + before: $before + after: $after + first: $first + last: $last + paused: $paused + status: $status + type: $type + tagList: $tagList + search: $search + sort: $sort + ) { + ...AllRunnersConnection + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/all_runners_connection.fragment.graphql b/app/assets/javascripts/ci/runner/graphql/list/all_runners_connection.fragment.graphql new file mode 100644 index 00000000000..39d79df02e7 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/all_runners_connection.fragment.graphql @@ -0,0 +1,13 @@ +#import "ee_else_ce/ci/runner/graphql/list/list_item.fragment.graphql" +#import "~/graphql_shared/fragments/page_info.fragment.graphql" + +fragment AllRunnersConnection on CiRunnerConnection { + nodes { + ...ListItem + adminUrl + editAdminUrl + } + pageInfo { + ...PageInfo + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/all_runners_count.query.graphql b/app/assets/javascripts/ci/runner/graphql/list/all_runners_count.query.graphql new file mode 100644 index 00000000000..82591b88d3e --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/all_runners_count.query.graphql @@ -0,0 +1,11 @@ +query getAllRunnersCount( + $paused: Boolean + $status: CiRunnerStatus + $type: CiRunnerType + $tagList: [String!] + $search: String +) { + runners(paused: $paused, status: $status, type: $type, tagList: $tagList, search: $search) { + count + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/bulk_runner_delete.mutation.graphql b/app/assets/javascripts/ci/runner/graphql/list/bulk_runner_delete.mutation.graphql new file mode 100644 index 00000000000..b73c016b1de --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/bulk_runner_delete.mutation.graphql @@ -0,0 +1,6 @@ +mutation bulkRunnerDelete($input: BulkRunnerDeleteInput!) { + bulkRunnerDelete(input: $input) { + deletedIds + errors + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/checked_runner_ids.query.graphql b/app/assets/javascripts/ci/runner/graphql/list/checked_runner_ids.query.graphql new file mode 100644 index 00000000000..c01f1edb451 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/checked_runner_ids.query.graphql @@ -0,0 +1,3 @@ +query getCheckedRunnerIds { + checkedRunnerIds @client +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/group_runner_connection.fragment.graphql b/app/assets/javascripts/ci/runner/graphql/list/group_runner_connection.fragment.graphql new file mode 100644 index 00000000000..53be8fdc613 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/group_runner_connection.fragment.graphql @@ -0,0 +1,16 @@ +#import "ee_else_ce/ci/runner/graphql/list/list_item.fragment.graphql" +#import "~/graphql_shared/fragments/page_info.fragment.graphql" + +fragment GroupRunnerConnection on CiRunnerConnection { + edges { + webUrl + editUrl + node { + ...ListItem + projectCount # Used to determine why some project runners can't be deleted + } + } + pageInfo { + ...PageInfo + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/group_runners.query.graphql b/app/assets/javascripts/ci/runner/graphql/list/group_runners.query.graphql new file mode 100644 index 00000000000..08fd8974826 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/group_runners.query.graphql @@ -0,0 +1,35 @@ +#import "~/ci/runner/graphql/list/group_runner_connection.fragment.graphql" + +query getGroupRunners( + $groupFullPath: ID! + $membership: CiRunnerMembershipFilter + $before: String + $after: String + $first: Int + $last: Int + $paused: Boolean + $status: CiRunnerStatus + $type: CiRunnerType + $tagList: [String!] + $search: String + $sort: CiRunnerSort +) { + group(fullPath: $groupFullPath) { + id # Apollo required + runners( + membership: $membership + before: $before + after: $after + first: $first + last: $last + paused: $paused + status: $status + type: $type + tagList: $tagList + search: $search + sort: $sort + ) { + ...GroupRunnerConnection + } + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/group_runners_count.query.graphql b/app/assets/javascripts/ci/runner/graphql/list/group_runners_count.query.graphql new file mode 100644 index 00000000000..e88a2c2e7e6 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/group_runners_count.query.graphql @@ -0,0 +1,23 @@ +query getGroupRunnersCount( + $groupFullPath: ID! + $membership: CiRunnerMembershipFilter + $paused: Boolean + $status: CiRunnerStatus + $type: CiRunnerType + $tagList: [String!] + $search: String +) { + group(fullPath: $groupFullPath) { + id # Apollo required + runners( + membership: $membership + paused: $paused + status: $status + type: $type + tagList: $tagList + search: $search + ) { + count + } + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/list_item.fragment.graphql b/app/assets/javascripts/ci/runner/graphql/list/list_item.fragment.graphql new file mode 100644 index 00000000000..19a5a48ea75 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/list_item.fragment.graphql @@ -0,0 +1,5 @@ +#import "./list_item_shared.fragment.graphql" + +fragment ListItem on CiRunner { + ...ListItemShared +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/list_item_shared.fragment.graphql b/app/assets/javascripts/ci/runner/graphql/list/list_item_shared.fragment.graphql new file mode 100644 index 00000000000..0dff011daaa --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/list_item_shared.fragment.graphql @@ -0,0 +1,33 @@ +fragment ListItemShared on CiRunner { + id + description + runnerType + shortSha + version + ipAddress + active + locked + jobCount + tagList + createdAt + contactedAt + status(legacyMode: null) + userPermissions { + updateRunner + deleteRunner + } + groups(first: 1) { + nodes { + id + name + fullName + webUrl + } + } + ownerProject { + id + name + nameWithNamespace + webUrl + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/local_state.js b/app/assets/javascripts/ci/runner/graphql/list/local_state.js new file mode 100644 index 00000000000..ab53bfdbd5b --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/local_state.js @@ -0,0 +1,75 @@ +import { makeVar } from '@apollo/client/core'; +import { RUNNER_TYPENAME } from '../../constants'; +import typeDefs from './typedefs.graphql'; + +/** + * Local state for checkable runner items. + * + * Usage: + * + * ``` + * import { createLocalState } from '~/ci/runner/graphql/list/local_state'; + * + * // initialize local state + * const { cacheConfig, typeDefs, localMutations } = createLocalState(); + * + * // configure the client + * apolloClient = createApolloClient({}, { cacheConfig, typeDefs }); + * + * // modify local state + * localMutations.setRunnerChecked( ... ) + * ``` + * + * @returns {Object} An object to configure an Apollo client: + * contains cacheConfig, typeDefs, localMutations. + */ +export const createLocalState = () => { + const checkedRunnerIdsVar = makeVar({}); + + const cacheConfig = { + typePolicies: { + Query: { + fields: { + checkedRunnerIds(_, { canRead, toReference }) { + return Object.entries(checkedRunnerIdsVar()) + .filter(([id]) => { + // Some runners may be deleted by the user separately. + // Skip dangling references, those not in the cache. + // See: https://www.apollographql.com/docs/react/caching/garbage-collection/#dangling-references + return canRead(toReference({ __typename: RUNNER_TYPENAME, id })); + }) + .filter(([, isChecked]) => isChecked) + .map(([id]) => id); + }, + }, + }, + }, + }; + + const localMutations = { + setRunnerChecked({ runner, isChecked }) { + const { id, userPermissions } = runner; + if (userPermissions?.deleteRunner) { + checkedRunnerIdsVar({ + ...checkedRunnerIdsVar(), + [id]: isChecked, + }); + } + }, + setRunnersChecked({ runners, isChecked }) { + const newVal = runners + .filter(({ userPermissions }) => userPermissions?.deleteRunner) + .reduce((acc, { id }) => ({ ...acc, [id]: isChecked }), checkedRunnerIdsVar()); + checkedRunnerIdsVar(newVal); + }, + clearChecked() { + checkedRunnerIdsVar({}); + }, + }; + + return { + cacheConfig, + typeDefs, + localMutations, + }; +}; diff --git a/app/assets/javascripts/ci/runner/graphql/list/runners_registration_token_reset.mutation.graphql b/app/assets/javascripts/ci/runner/graphql/list/runners_registration_token_reset.mutation.graphql new file mode 100644 index 00000000000..9c2797732ad --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/runners_registration_token_reset.mutation.graphql @@ -0,0 +1,6 @@ +mutation runnersRegistrationTokenReset($input: RunnersRegistrationTokenResetInput!) { + runnersRegistrationTokenReset(input: $input) { + token + errors + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/list/typedefs.graphql b/app/assets/javascripts/ci/runner/graphql/list/typedefs.graphql new file mode 100644 index 00000000000..24e9e20cc8c --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/list/typedefs.graphql @@ -0,0 +1,3 @@ +extend type Query { + checkedRunnerIds: [ID!]! +} diff --git a/app/assets/javascripts/ci/runner/graphql/shared/runner_delete.mutation.graphql b/app/assets/javascripts/ci/runner/graphql/shared/runner_delete.mutation.graphql new file mode 100644 index 00000000000..d580ea2785e --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/shared/runner_delete.mutation.graphql @@ -0,0 +1,5 @@ +mutation runnerDelete($input: RunnerDeleteInput!) { + runnerDelete(input: $input) { + errors + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/shared/runner_toggle_active.mutation.graphql b/app/assets/javascripts/ci/runner/graphql/shared/runner_toggle_active.mutation.graphql new file mode 100644 index 00000000000..9b15570dbc0 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/shared/runner_toggle_active.mutation.graphql @@ -0,0 +1,12 @@ +# Mutation executed for the pause/resume button in the +# runner list and details views. + +mutation runnerToggleActive($input: RunnerUpdateInput!) { + runnerUpdate(input: $input) { + runner { + id + active + } + errors + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/show/runner.query.graphql b/app/assets/javascripts/ci/runner/graphql/show/runner.query.graphql new file mode 100644 index 00000000000..6375b4f35a4 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/show/runner.query.graphql @@ -0,0 +1,7 @@ +#import "ee_else_ce/ci/runner/graphql/show/runner_details.fragment.graphql" + +query getRunner($id: CiRunnerID!) { + runner(id: $id) { + ...RunnerDetails + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/show/runner_details.fragment.graphql b/app/assets/javascripts/ci/runner/graphql/show/runner_details.fragment.graphql new file mode 100644 index 00000000000..2449ee0fc0f --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/show/runner_details.fragment.graphql @@ -0,0 +1,5 @@ +#import "./runner_details_shared.fragment.graphql" + +fragment RunnerDetails on CiRunner { + ...RunnerDetailsShared +} diff --git a/app/assets/javascripts/ci/runner/graphql/show/runner_details_shared.fragment.graphql b/app/assets/javascripts/ci/runner/graphql/show/runner_details_shared.fragment.graphql new file mode 100644 index 00000000000..b5689ff7687 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/show/runner_details_shared.fragment.graphql @@ -0,0 +1,39 @@ +fragment RunnerDetailsShared on CiRunner { + id + shortSha + runnerType + active + accessLevel + runUntagged + locked + ipAddress + executorName + architectureName + platformName + description + maximumTimeout + jobCount + tagList + createdAt + status(legacyMode: null) + contactedAt + tokenExpiresAt + version + editAdminUrl + userPermissions { + updateRunner + deleteRunner + } + groups { + # Only a single group can be loaded here, while projects + # are loaded separately using the query with pagination + # parameters `runner_projects.query.graphql`. + nodes { + id + avatarUrl + name + fullName + webUrl + } + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/show/runner_jobs.query.graphql b/app/assets/javascripts/ci/runner/graphql/show/runner_jobs.query.graphql new file mode 100644 index 00000000000..edfc22f644b --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/show/runner_jobs.query.graphql @@ -0,0 +1,38 @@ +#import "~/graphql_shared/fragments/page_info.fragment.graphql" + +query getRunnerJobs($id: CiRunnerID!, $first: Int, $last: Int, $before: String, $after: String) { + runner(id: $id) { + id + projectCount + jobs(before: $before, after: $after, first: $first, last: $last) { + nodes { + id + detailedStatus { + # fields for `<ci-badge>` + id + detailsPath + group + icon + text + } + pipeline { + id + project { + id + name + webUrl + } + } + shortSha + commitPath + finishedAt + duration + queuedDuration + tags + } + pageInfo { + ...PageInfo + } + } + } +} diff --git a/app/assets/javascripts/ci/runner/graphql/show/runner_projects.query.graphql b/app/assets/javascripts/ci/runner/graphql/show/runner_projects.query.graphql new file mode 100644 index 00000000000..e42648b3079 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/show/runner_projects.query.graphql @@ -0,0 +1,31 @@ +#import "~/graphql_shared/fragments/page_info.fragment.graphql" + +query getRunnerProjects( + $id: CiRunnerID! + $search: String + $first: Int + $last: Int + $before: String + $after: String +) { + runner(id: $id) { + id + ownerProject { + id + } + projectCount + projects(search: $search, first: $first, last: $last, before: $before, after: $after) { + nodes { + id + avatarUrl + description + name + nameWithNamespace + webUrl + } + pageInfo { + ...PageInfo + } + } + } +} |