Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent edit/detail view: change the help url based on the backend #4219

16 changes: 11 additions & 5 deletions web/src/components/agent/AgentForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@
<TextField :id="id" :model-value="agent.id?.toString()" disabled />
</InputField>

<InputField
v-slot="{ id }"
:label="$t('admin.settings.agents.backend.backend')"
docs-url="docs/next/administration/backends/docker"
>
<InputField v-slot="{ id }" :label="$t('admin.settings.agents.backend.backend')" :docs-url="backendDocsUrl">
<TextField :id="id" v-model="agent.backend" disabled />
</InputField>

Expand Down Expand Up @@ -107,6 +103,16 @@ const agent = computed({
set: (value) => emit('update:modelValue', value),
});

const baseDocsUrl = 'https://woodpecker-ci.org/docs/next/administration/backends/';

const backendDocsUrl = computed(() => {
let backendUrlSuffix = agent.value.backend?.toLowerCase();
if (backendUrlSuffix === 'custom') {
backendUrlSuffix = 'custom-backends';
}
return `${baseDocsUrl}${backendUrlSuffix === '' ? 'docker' : backendUrlSuffix}`;
});

function updateAgent(newValues: Partial<Agent>) {
emit('update:modelValue', { ...agent.value, ...newValues });
}
Expand Down