Allow to disable swagger (#2093)

https://github.com/woodpecker-ci/woodpecker/issues/1944
This commit is contained in:
qwerty287
2023-08-03 02:42:30 +02:00
committed by GitHub
parent f06e0acdc6
commit 1a7f7a9427
9 changed files with 40 additions and 9 deletions

View File

@@ -18,7 +18,9 @@
<!-- Docs Link -->
<a :href="docsUrl" target="_blank" class="navbar-link navbar-clickable hidden md:flex">{{ $t('docs') }}</a>
<!-- API Link -->
<a :href="apiUrl" target="_blank" class="navbar-link navbar-clickable hidden md:flex">{{ $t('api') }}</a>
<a v-if="enableSwagger" :href="apiUrl" target="_blank" class="navbar-link navbar-clickable hidden md:flex">{{
$t('api')
}}</a>
</div>
<!-- Right Icons Box -->
<div class="flex ml-auto -m-1.5 items-center space-x-2">
@@ -82,7 +84,15 @@ export default defineComponent({
const version = config.version?.startsWith('next') ? 'next' : config.version;
return { darkMode, user: authentication.user, doLogin, docsUrl, version, apiUrl };
return {
darkMode,
user: authentication.user,
doLogin,
docsUrl,
version,
apiUrl,
enableSwagger: config.enableSwagger,
};
},
});
</script>

View File

@@ -8,6 +8,7 @@ declare global {
WOODPECKER_CSRF: string | undefined;
WOODPECKER_FORGE: string | undefined;
WOODPECKER_ROOT_URL: string | undefined;
WOODPECKER_ENABLE_SWAGGER: boolean | undefined;
}
}
@@ -18,4 +19,5 @@ export default () => ({
csrf: window.WOODPECKER_CSRF || null,
forge: window.WOODPECKER_FORGE || null,
rootURL: window.WOODPECKER_ROOT_URL || null,
enableSwagger: window.WOODPECKER_ENABLE_SWAGGER || false,
});

View File

@@ -22,6 +22,7 @@
<div class="flex items-center">
<h2 class="text-lg text-wp-text-100">{{ $t('user.api_usage') }}</h2>
<a
v-if="enableSwagger"
:href="`${address}/swagger/index.html`"
target="_blank"
class="ml-4 text-wp-link-100 hover:text-wp-link-200"
@@ -56,9 +57,11 @@ import Button from '~/components/atomic/Button.vue';
import SelectField from '~/components/form/SelectField.vue';
import Scaffold from '~/components/layout/scaffold/Scaffold.vue';
import useApiClient from '~/compositions/useApiClient';
import useConfig from '~/compositions/useConfig';
import { setI18nLanguage } from '~/compositions/useI18n';
const { t, locale } = useI18n();
const { enableSwagger } = useConfig();
const apiClient = useApiClient();
const token = ref<string | undefined>();