mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 18:01:02 +00:00
parent
2023518552
commit
9ece7a1c49
5 changed files with 58 additions and 49 deletions
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<select
|
<select
|
||||||
v-model="innerValue"
|
v-model="innerValue"
|
||||||
class="w-full border border-gray-900 py-1 px-2 rounded-md bg-white focus:outline-none border-gray-900"
|
class="dark:bg-dark-gray-700 bg-transparent text-color border-gray-200 dark:border-dark-400 w-full border py-1 px-2 rounded-md focus:outline-none"
|
||||||
:class="{
|
:class="{
|
||||||
'text-color': innerValue === '',
|
'text-color': innerValue === '',
|
||||||
'text-gray-900': innerValue !== '',
|
'text-gray-900': innerValue !== '',
|
||||||
|
|
|
@ -4,12 +4,7 @@
|
||||||
<form @submit.prevent="triggerManualPipeline">
|
<form @submit.prevent="triggerManualPipeline">
|
||||||
<span class="text-xl text-color">{{ $t('repo.manual_pipeline.title') }}</span>
|
<span class="text-xl text-color">{{ $t('repo.manual_pipeline.title') }}</span>
|
||||||
<InputField :label="$t('repo.manual_pipeline.select_branch')">
|
<InputField :label="$t('repo.manual_pipeline.select_branch')">
|
||||||
<SelectField
|
<SelectField v-model="payload.branch" :options="branches" required />
|
||||||
v-model="payload.branch"
|
|
||||||
:options="branches"
|
|
||||||
required
|
|
||||||
class="dark:bg-dark-gray-700 bg-transparent text-color border-gray-200 dark:border-dark-400"
|
|
||||||
/>
|
|
||||||
</InputField>
|
</InputField>
|
||||||
<InputField :label="$t('repo.manual_pipeline.variables.title')">
|
<InputField :label="$t('repo.manual_pipeline.variables.title')">
|
||||||
<span class="text-sm text-color-alt mb-2">{{ $t('repo.manual_pipeline.variables.desc') }}</span>
|
<span class="text-sm text-color-alt mb-2">{{ $t('repo.manual_pipeline.variables.desc') }}</span>
|
||||||
|
|
|
@ -25,16 +25,10 @@
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
required
|
required
|
||||||
class="dark:bg-dark-gray-700 bg-transparent text-color border-gray-200 dark:border-dark-400"
|
|
||||||
/>
|
/>
|
||||||
</InputField>
|
</InputField>
|
||||||
<InputField :label="$t('repo.settings.badge.branch')">
|
<InputField :label="$t('repo.settings.badge.branch')">
|
||||||
<SelectField
|
<SelectField v-model="branch" :options="branches" required />
|
||||||
v-model="branch"
|
|
||||||
:options="branches"
|
|
||||||
required
|
|
||||||
class="dark:bg-dark-gray-700 bg-transparent text-color border-gray-200 dark:border-dark-400"
|
|
||||||
/>
|
|
||||||
</InputField>
|
</InputField>
|
||||||
|
|
||||||
<div v-if="badgeContent" class="flex flex-col space-y-4">
|
<div v-if="badgeContent" class="flex flex-col space-y-4">
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
import { useLocalStorage } from '@vueuse/core';
|
||||||
|
|
||||||
export function getUserLanguage(): string {
|
export function getUserLanguage(): string {
|
||||||
return navigator.language.split('-')[0];
|
const browserLocale = navigator.language.split('-')[0];
|
||||||
|
const selectedLocale = useLocalStorage('woodpecker:locale', browserLocale).value;
|
||||||
|
|
||||||
|
return selectedLocale;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
<FluidContainer class="space-y-4 flex flex-col my-0">
|
<FluidContainer class="space-y-4 flex flex-col my-0">
|
||||||
<Button class="ml-auto" :text="$t('logout')" :to="`${address}/logout`" />
|
<Button class="ml-auto" :text="$t('logout')" :to="`${address}/logout`" />
|
||||||
|
|
||||||
|
<SelectField v-model="selectedLocale" :options="localeOptions" />
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h2 class="text-lg text-color">{{ $t('user.token') }}</h2>
|
<h2 class="text-lg text-color">{{ $t('user.token') }}</h2>
|
||||||
<pre class="cli-box">{{ token }}</pre>
|
<pre class="cli-box">{{ token }}</pre>
|
||||||
|
@ -27,48 +29,61 @@
|
||||||
</FluidContainer>
|
</FluidContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { computed, defineComponent, onMounted, ref } from 'vue';
|
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 { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import Button from '~/components/atomic/Button.vue';
|
import Button from '~/components/atomic/Button.vue';
|
||||||
|
import SelectField from '~/components/form/SelectField.vue';
|
||||||
import FluidContainer from '~/components/layout/FluidContainer.vue';
|
import FluidContainer from '~/components/layout/FluidContainer.vue';
|
||||||
import useApiClient from '~/compositions/useApiClient';
|
import useApiClient from '~/compositions/useApiClient';
|
||||||
|
|
||||||
export default defineComponent({
|
const { t, availableLocales, locale } = useI18n();
|
||||||
name: 'User',
|
|
||||||
|
|
||||||
components: {
|
const apiClient = useApiClient();
|
||||||
FluidContainer,
|
const token = ref<string | undefined>();
|
||||||
Button,
|
|
||||||
|
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() {
|
||||||
setup() {
|
return storedLocale.value;
|
||||||
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}`;
|
|
||||||
|
|
||||||
const usageWithShell = computed(() => {
|
|
||||||
let usage = `export WOODPECKER_SERVER="${address}"\n`;
|
|
||||||
usage += `export WOODPECKER_TOKEN="${token.value}"\n`;
|
|
||||||
return usage;
|
|
||||||
});
|
|
||||||
|
|
||||||
const usageWithCurl = `# ${useI18n().t(
|
|
||||||
'user.shell_setup_before',
|
|
||||||
)}\ncurl -i \${WOODPECKER_SERVER}/api/user -H "Authorization: Bearer \${WOODPECKER_TOKEN}"`;
|
|
||||||
|
|
||||||
const usageWithCli = `# ${useI18n().t('user.shell_setup_before')}\nwoodpecker info`;
|
|
||||||
|
|
||||||
const cliDownload = 'https://github.com/woodpecker-ci/woodpecker/releases';
|
|
||||||
|
|
||||||
return { token, usageWithShell, usageWithCurl, usageWithCli, cliDownload, address };
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue