mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
And allow to show badges for disabled repos Fixes 3rd checkbox from https://github.com/woodpecker-ci/woodpecker/discussions/2162#discussion-5498655 
69 lines
2.4 KiB
Vue
69 lines
2.4 KiB
Vue
<template>
|
|
<Scaffold v-model:search="search" :go-back="goBack">
|
|
<template #title>
|
|
{{ $t('repo.add') }}
|
|
</template>
|
|
|
|
<div class="space-y-4">
|
|
<ListItem
|
|
v-for="repo in searchedRepos"
|
|
:key="repo.id"
|
|
class="items-center"
|
|
:to="repo.active ? { name: 'repo', params: { repoId: repo.id } } : undefined"
|
|
>
|
|
<span class="text-wp-text-100">{{ repo.full_name }}</span>
|
|
<span v-if="repo.active" class="ml-auto text-wp-text-alt-100">{{ $t('repo.enable.enabled') }}</span>
|
|
<div v-else class="ml-auto flex items-center">
|
|
<Badge v-if="repo.id" class="<md:hidden mr-2" :label="$t('repo.enable.disabled')" />
|
|
<Button
|
|
:text="$t('repo.enable.enable')"
|
|
:is-loading="isActivatingRepo && repoToActivate?.forge_remote_id === repo.forge_remote_id"
|
|
@click="activateRepo(repo)"
|
|
/>
|
|
</div>
|
|
</ListItem>
|
|
</div>
|
|
</Scaffold>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { onMounted, ref } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useRouter } from 'vue-router';
|
|
|
|
import Badge from '~/components/atomic/Badge.vue';
|
|
import Button from '~/components/atomic/Button.vue';
|
|
import ListItem from '~/components/atomic/ListItem.vue';
|
|
import Scaffold from '~/components/layout/scaffold/Scaffold.vue';
|
|
import useApiClient from '~/compositions/useApiClient';
|
|
import { useAsyncAction } from '~/compositions/useAsyncAction';
|
|
import useNotifications from '~/compositions/useNotifications';
|
|
import { useRepoSearch } from '~/compositions/useRepoSearch';
|
|
import { useRouteBack } from '~/compositions/useRouteBack';
|
|
import { Repo } from '~/lib/api/types';
|
|
|
|
const router = useRouter();
|
|
const apiClient = useApiClient();
|
|
const notifications = useNotifications();
|
|
const repos = ref<Repo[]>();
|
|
const repoToActivate = ref<Repo>();
|
|
const search = ref('');
|
|
const i18n = useI18n();
|
|
|
|
const { searchedRepos } = useRepoSearch(repos, search);
|
|
|
|
onMounted(async () => {
|
|
repos.value = await apiClient.getRepoList({ all: true });
|
|
});
|
|
|
|
const { doSubmit: activateRepo, isLoading: isActivatingRepo } = useAsyncAction(async (repo: Repo) => {
|
|
repoToActivate.value = repo;
|
|
const _repo = await apiClient.activateRepo(repo.forge_remote_id);
|
|
notifications.notify({ title: i18n.t('repo.enable.success'), type: 'success' });
|
|
repoToActivate.value = undefined;
|
|
await router.push({ name: 'repo', params: { repoId: _repo.id } });
|
|
});
|
|
|
|
const goBack = useRouteBack({ name: 'repos' });
|
|
</script>
|