Skip to content
Snippets Groups Projects

Add runner registration instructions (2)

Merged Miguel Rincon requested to merge 383139-add-runner-registration-instructions into master
All threads resolved!
5 files
+ 84
4
Compare changes
  • Side-by-side
  • Inline
Files
5
  • 3e2b9d29
    Call API to create runner · 3e2b9d29
    Miguel Rincon authored
    This change adds an API call to create a runner using then new workflow.
    
    The result is meant to redirect the user to a registration page.
<script>
<script>
import { GlSprintf, GlLink, GlModalDirective } from '@gitlab/ui';
import { GlSprintf, GlLink, GlModalDirective, GlForm, GlButton } from '@gitlab/ui';
 
import { createAlert, VARIANT_SUCCESS } from '~/flash';
 
import { redirectTo, setUrlParams } from '~/lib/utils/url_utility';
 
import { __ } from '~/locale';
import RunnerInstructionsModal from '~/vue_shared/components/runner_instructions/runner_instructions_modal.vue';
import RunnerInstructionsModal from '~/vue_shared/components/runner_instructions/runner_instructions_modal.vue';
 
import { modelToUpdateMutationVariables } from 'ee_else_ce/ci/runner/runner_update_form_utils';
 
import runnerCreateMutation from '~/ci/runner/graphql/new/runner_create.mutation.graphql';
import RunnerPlatformsRadioGroup from '~/ci/runner/components/runner_platforms_radio_group.vue';
import RunnerPlatformsRadioGroup from '~/ci/runner/components/runner_platforms_radio_group.vue';
import RunnerFormFields from '~/ci/runner/components/runner_form_fields.vue';
import RunnerFormFields from '~/ci/runner/components/runner_form_fields.vue';
import { DEFAULT_PLATFORM, DEFAULT_ACCESS_LEVEL } from '../constants';
import { DEFAULT_PLATFORM, DEFAULT_ACCESS_LEVEL, PARAM_KEY_PLATFORM } from '../constants';
 
import { captureException } from '../sentry_utils';
 
import { saveAlertToLocalStorage } from '../local_storage_alert/save_alert_to_local_storage';
export default {
export default {
name: 'AdminNewRunnerApp',
name: 'AdminNewRunnerApp',
components: {
components: {
GlLink,
GlLink,
GlSprintf,
GlSprintf,
 
GlForm,
 
GlButton,
RunnerInstructionsModal,
RunnerInstructionsModal,
RunnerPlatformsRadioGroup,
RunnerPlatformsRadioGroup,
RunnerFormFields,
RunnerFormFields,
@@ -26,6 +35,7 @@ export default {
@@ -26,6 +35,7 @@ export default {
data() {
data() {
return {
return {
platform: DEFAULT_PLATFORM,
platform: DEFAULT_PLATFORM,
 
saving: false,
runner: {
runner: {
description: '',
description: '',
maintenanceNote: '',
maintenanceNote: '',
@@ -33,10 +43,53 @@ export default {
@@ -33,10 +43,53 @@ export default {
accessLevel: DEFAULT_ACCESS_LEVEL,
accessLevel: DEFAULT_ACCESS_LEVEL,
runUntagged: false,
runUntagged: false,
tagList: '',
tagList: '',
maximumTimeout: ' ',
maximumTimeout: '',
},
},
};
};
},
},
 
computed: {
 
variables() {
 
return modelToUpdateMutationVariables(this.runner);
 
},
 
},
 
methods: {
 
async onSubmit() {
 
this.saving = true;
 
 
try {
 
const {
 
data: {
 
runnerCreate: { errors, runner },
 
},
 
} = await this.$apollo.mutate({
 
mutation: runnerCreateMutation,
 
variables: modelToUpdateMutationVariables(this.runner),
 
});
 
 
if (errors?.length) {
 
this.onError(errors[0]);
 
} else {
 
this.onSuccess(runner);
 
}
 
} catch (error) {
 
const { message } = error;
 
this.onError(message);
 
captureException({ error, component: this.$options.name });
 
}
 
},
 
onSuccess(runner) {
 
const registerUrl = setUrlParams(
 
{ [PARAM_KEY_PLATFORM]: this.platform },
 
runner.registerAdminUrl,
 
);
 
saveAlertToLocalStorage({ message: __('Runner created.'), variant: VARIANT_SUCCESS });
 
redirectTo(registerUrl);
 
},
 
onError(message) {
 
this.saving = false;
 
createAlert({ message });
 
},
 
},
modalId: 'runners-legacy-registration-instructions-modal',
modalId: 'runners-legacy-registration-instructions-modal',
};
};
</script>
</script>
@@ -73,6 +126,14 @@ export default {
@@ -73,6 +126,14 @@ export default {
<hr aria-hidden="true" />
<hr aria-hidden="true" />
<runner-form-fields v-model="runner" />
<gl-form @submit.prevent="onSubmit">
 
<runner-form-fields v-model="runner" />
 
 
<div class="gl-display-flex">
 
<gl-button type="submit" variant="confirm" class="js-no-auto-disable" :loading="saving">
 
{{ __('Submit') }}
 
</gl-button>
 
</div>
 
</gl-form>
</div>
</div>
</template>
</template>
Loading