diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-25 06:16:18 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-25 06:16:18 +0300 |
commit | 80e6e0fcdd078daf40fa642eee76cbf0d07afaff (patch) | |
tree | 6b2524684e489eaafc178ec23beb89e55ecf2c2e /app/assets/javascripts/runner | |
parent | ca6f7d9e723976ab6046a09d1a22211ca2c8a930 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/runner')
7 files changed, 50 insertions, 23 deletions
diff --git a/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue b/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue index b458722af52..3ce9a890b37 100644 --- a/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue +++ b/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue @@ -12,6 +12,7 @@ import RunnerName from '../components/runner_name.vue'; import RunnerStats from '../components/stat/runner_stats.vue'; import RunnerPagination from '../components/runner_pagination.vue'; import RunnerTypeTabs from '../components/runner_type_tabs.vue'; +import RunnerActionsCell from '../components/cells/runner_actions_cell.vue'; import { statusTokenConfig } from '../components/search_tokens/status_token_config'; import { tagTokenConfig } from '../components/search_tokens/tag_token_config'; @@ -57,6 +58,7 @@ export default { RunnerStats, RunnerPagination, RunnerTypeTabs, + RunnerActionsCell, }, props: { registrationToken: { @@ -279,6 +281,9 @@ export default { <runner-name :runner="runner" /> </gl-link> </template> + <template #runner-actions-cell="{ runner }"> + <runner-actions-cell :runner="runner" :edit-url="runner.editAdminUrl" /> + </template> </runner-list> <runner-pagination v-model="search.pagination" diff --git a/app/assets/javascripts/runner/components/cells/runner_actions_cell.vue b/app/assets/javascripts/runner/components/cells/runner_actions_cell.vue index eb50899ddb7..6d56a170414 100644 --- a/app/assets/javascripts/runner/components/cells/runner_actions_cell.vue +++ b/app/assets/javascripts/runner/components/cells/runner_actions_cell.vue @@ -17,6 +17,11 @@ export default { type: Object, required: true, }, + editUrl: { + type: String, + default: null, + required: false, + }, }, computed: { canUpdate() { @@ -31,14 +36,7 @@ export default { <template> <gl-button-group> - <!-- - This button appears for administrators: those with - access to the adminUrl. More advanced permissions policies - will allow more granular permissions. - - See https://gitlab.com/gitlab-org/gitlab/-/issues/334802 - --> - <runner-edit-button v-if="canUpdate && runner.editAdminUrl" :href="runner.editAdminUrl" /> + <runner-edit-button v-if="canUpdate && editUrl" :href="editUrl" /> <runner-pause-button v-if="canUpdate" :runner="runner" :compact="true" /> <runner-delete-button v-if="canDelete" :runner="runner" :compact="true" /> </gl-button-group> diff --git a/app/assets/javascripts/runner/components/runner_edit_button.vue b/app/assets/javascripts/runner/components/runner_edit_button.vue index b115be09e69..33e0acaf5c0 100644 --- a/app/assets/javascripts/runner/components/runner_edit_button.vue +++ b/app/assets/javascripts/runner/components/runner_edit_button.vue @@ -1,8 +1,6 @@ <script> import { GlButton, GlTooltipDirective } from '@gitlab/ui'; -import { __ } from '~/locale'; - -const I18N_EDIT = __('Edit'); +import { I18N_EDIT } from '../constants'; export default { components: { diff --git a/app/assets/javascripts/runner/components/runner_list.vue b/app/assets/javascripts/runner/components/runner_list.vue index 17cbf01c9a1..51749b0255f 100644 --- a/app/assets/javascripts/runner/components/runner_list.vue +++ b/app/assets/javascripts/runner/components/runner_list.vue @@ -5,7 +5,6 @@ import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { __, s__ } from '~/locale'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; import { formatJobCount, tableField } from '../utils'; -import RunnerActionsCell from './cells/runner_actions_cell.vue'; import RunnerSummaryCell from './cells/runner_summary_cell.vue'; import RunnerStatusCell from './cells/runner_status_cell.vue'; import RunnerTags from './runner_tags.vue'; @@ -16,7 +15,6 @@ export default { GlSkeletonLoader, TooltipOnTruncate, TimeAgo, - RunnerActionsCell, RunnerSummaryCell, RunnerTags, RunnerStatusCell, @@ -121,7 +119,7 @@ export default { </template> <template #cell(actions)="{ item }"> - <runner-actions-cell :runner="item" /> + <slot name="runner-actions-cell" :runner="item"></slot> </template> </gl-table-lite> diff --git a/app/assets/javascripts/runner/constants.js b/app/assets/javascripts/runner/constants.js index 4120753dc95..23f87712e63 100644 --- a/app/assets/javascripts/runner/constants.js +++ b/app/assets/javascripts/runner/constants.js @@ -35,7 +35,8 @@ export const I18N_STALE_RUNNER_DESCRIPTION = s__( 'Runners|No contact from this runner in over 3 months', ); -// Active flag +// Actions +export const I18N_EDIT = __('Edit'); export const I18N_PAUSE = __('Pause'); export const I18N_RESUME = __('Resume'); export const I18N_DELETE_RUNNER = s__('Runners|Delete runner'); diff --git a/app/assets/javascripts/runner/graphql/get_group_runners.query.graphql b/app/assets/javascripts/runner/graphql/get_group_runners.query.graphql index 986dd16b992..f9c7b89fc01 100644 --- a/app/assets/javascripts/runner/graphql/get_group_runners.query.graphql +++ b/app/assets/javascripts/runner/graphql/get_group_runners.query.graphql @@ -27,6 +27,7 @@ query getGroupRunners( ) { edges { webUrl + editUrl node { __typename ...RunnerNode diff --git a/app/assets/javascripts/runner/group_runners/group_runners_app.vue b/app/assets/javascripts/runner/group_runners/group_runners_app.vue index 8a37df00765..ba33ead6f46 100644 --- a/app/assets/javascripts/runner/group_runners/group_runners_app.vue +++ b/app/assets/javascripts/runner/group_runners/group_runners_app.vue @@ -12,6 +12,7 @@ import RunnerName from '../components/runner_name.vue'; import RunnerStats from '../components/stat/runner_stats.vue'; import RunnerPagination from '../components/runner_pagination.vue'; import RunnerTypeTabs from '../components/runner_type_tabs.vue'; +import RunnerActionsCell from '../components/cells/runner_actions_cell.vue'; import { statusTokenConfig } from '../components/search_tokens/status_token_config'; import { @@ -55,6 +56,7 @@ export default { RunnerStats, RunnerPagination, RunnerTypeTabs, + RunnerActionsCell, }, props: { registrationToken: { @@ -74,8 +76,8 @@ export default { return { search: fromUrlQueryToSearch(), runners: { - webUrls: [], items: [], + urlsById: {}, pageInfo: {}, }, }; @@ -91,12 +93,23 @@ export default { return this.variables; }, update(data) { - const { runners } = data?.group || {}; + const { edges = [], pageInfo = {} } = data?.group?.runners || {}; + + const items = []; + const urlsById = {}; + + edges.forEach(({ node, webUrl, editUrl }) => { + items.push(node); + urlsById[node.id] = { + web: webUrl, + edit: editUrl, + }; + }); return { - webUrls: runners?.edges.map(({ webUrl }) => webUrl) || [], - items: runners?.edges.map(({ node }) => node) || [], - pageInfo: runners?.pageInfo || {}, + items, + urlsById, + pageInfo, }; }, error(error) { @@ -222,6 +235,12 @@ export default { } return null; }, + webUrl(runner) { + return this.runners.urlsById[runner.id]?.web; + }, + editUrl(runner) { + return this.runners.urlsById[runner.id]?.edit; + }, reportToSentry(error) { captureException({ error, component: this.$options.name }); }, @@ -273,13 +292,20 @@ export default { </div> <template v-else> <runner-list :runners="runners.items" :loading="runnersLoading"> - <template #runner-name="{ runner, index }"> - <gl-link :href="runners.webUrls[index]"> + <template #runner-name="{ runner }"> + <gl-link :href="webUrl(runner)"> <runner-name :runner="runner" /> </gl-link> </template> + <template #runner-actions-cell="{ runner }"> + <runner-actions-cell :runner="runner" :edit-url="editUrl(runner)" /> + </template> </runner-list> - <runner-pagination v-model="search.pagination" :page-info="runners.pageInfo" /> + <runner-pagination + v-model="search.pagination" + class="gl-mt-3" + :page-info="runners.pageInfo" + /> </template> </div> </template> |