mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-03 05:59:30 +00:00
e2ab8a46ed
Some improvements to the Page Header and Tab UI. Original | New :--------:|:-------: ![image](https://user-images.githubusercontent.com/62170586/197360886-046f1016-ca39-4b69-8134-99ba88e3a0c2.png) | ![image](https://user-images.githubusercontent.com/62170586/197360819-7efd0d82-1412-465d-aefa-039164f97465.png) ![image](https://user-images.githubusercontent.com/62170586/197360872-f2ece5fd-7c0b-4e2c-8629-31524a412af5.png) | ![image](https://user-images.githubusercontent.com/62170586/197360830-49f09e0d-619e-4fa9-8e38-8d05d9404185.png) ![image](https://user-images.githubusercontent.com/62170586/197281776-e3de6441-9417-4614-8b25-1aaef0b8da61.png) | ![image](https://user-images.githubusercontent.com/62170586/197281698-40c66d34-76f3-4fd5-97e3-1c422b74844c.png) ![image](https://user-images.githubusercontent.com/62170586/196609248-ff150c6e-2995-4bcc-8573-49ffaf388446.png) | ![image](https://user-images.githubusercontent.com/62170586/197323734-7c1a1b79-0f41-4bf2-96a3-dd38df9e1415.png) ![image](https://user-images.githubusercontent.com/62170586/196609329-b7a6f37e-e8c2-4004-a98b-73f837122ff8.png) | ![image](https://user-images.githubusercontent.com/62170586/197323882-10141ffd-7411-4493-8291-b8000adc3cc5.png) What? - Create a new Scaffold component, which includes the header and tabs required for a page. - Use this component to wrap all the views that have a header. - Ensures consistency in headers between different pages. - [x] Add support to use custom html/component in place of title (for repo page, pipeline page, etc) - [x] Add support of right icon buttons (for repo page, pipeline page, etc) - [x] Refactor tabs handling using compositions (useTabsProvider, useTabsClient) - [x] Make new header ui resposive
99 lines
3.1 KiB
Vue
99 lines
3.1 KiB
Vue
<template>
|
|
<Scaffold>
|
|
<template #title>{{ $t('user.settings') }}</template>
|
|
<template #titleActions><Button :text="$t('logout')" :to="`${address}/logout`" /></template>
|
|
<div class="space-y-4 flex flex-col">
|
|
<SelectField v-model="selectedLocale" :options="localeOptions" />
|
|
|
|
<div>
|
|
<h2 class="text-lg text-color">{{ $t('user.token') }}</h2>
|
|
<pre class="cli-box">{{ token }}</pre>
|
|
</div>
|
|
|
|
<div>
|
|
<h2 class="text-lg text-color">{{ $t('user.shell_setup') }}</h2>
|
|
<pre class="cli-box">{{ usageWithShell }}</pre>
|
|
</div>
|
|
|
|
<div>
|
|
<h2 class="text-lg text-color">{{ $t('user.api_usage') }}</h2>
|
|
<pre class="cli-box">{{ usageWithCurl }}</pre>
|
|
</div>
|
|
|
|
<div>
|
|
<div class="flex items-center">
|
|
<h2 class="text-lg text-color">{{ $t('user.cli_usage') }}</h2>
|
|
<a :href="cliDownload" target="_blank" class="ml-4 text-link">{{ $t('user.dl_cli') }}</a>
|
|
</div>
|
|
<pre class="cli-box">{{ usageWithCli }}</pre>
|
|
</div>
|
|
</div>
|
|
</Scaffold>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { useLocalStorage } from '@vueuse/core';
|
|
import dayjs from 'dayjs';
|
|
import TimeAgo from 'javascript-time-ago';
|
|
import { computed, onMounted, ref } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
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';
|
|
|
|
const { t, availableLocales, locale } = useI18n();
|
|
|
|
const apiClient = useApiClient();
|
|
const token = ref<string | undefined>();
|
|
|
|
onMounted(async () => {
|
|
token.value = await apiClient.getToken();
|
|
});
|
|
|
|
// eslint-disable-next-line no-restricted-globals
|
|
const address = `${location.protocol}//${location.host}`; // port is included in location.host
|
|
|
|
const usageWithShell = computed(() => {
|
|
let usage = `export WOODPECKER_SERVER="${address}"\n`;
|
|
usage += `export WOODPECKER_TOKEN="${token.value}"\n`;
|
|
return usage;
|
|
});
|
|
|
|
const usageWithCurl = `# ${t(
|
|
'user.shell_setup_before',
|
|
)}\ncurl -i \${WOODPECKER_SERVER}/api/user -H "Authorization: Bearer \${WOODPECKER_TOKEN}"`;
|
|
|
|
const usageWithCli = `# ${t('user.shell_setup_before')}\nwoodpecker info`;
|
|
|
|
const cliDownload = 'https://github.com/woodpecker-ci/woodpecker/releases';
|
|
|
|
const localeOptions = computed(() =>
|
|
availableLocales.map((availableLocale) => ({
|
|
value: availableLocale,
|
|
text: new Intl.DisplayNames(availableLocale, { type: 'language' }).of(availableLocale) || availableLocale,
|
|
})),
|
|
);
|
|
|
|
const storedLocale = useLocalStorage('woodpecker:locale', locale.value);
|
|
const selectedLocale = computed<string>({
|
|
set(_selectedLocale) {
|
|
storedLocale.value = _selectedLocale;
|
|
locale.value = _selectedLocale;
|
|
dayjs.locale(_selectedLocale);
|
|
TimeAgo.setDefaultLocale(_selectedLocale);
|
|
},
|
|
get() {
|
|
return storedLocale.value;
|
|
},
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.cli-box {
|
|
@apply bg-gray-500 p-2 rounded-md text-white break-words dark:bg-dark-400 dark:text-gray-400;
|
|
white-space: pre-wrap;
|
|
}
|
|
</style>
|