mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-26 13:40:06 +00:00
58838f225c
Rewrite of the UI using Typescript, Vue3, Windicss and Vite. The design should be close to the current one with some changes: - latest pipeline in a sidebar on the right - secrets and registry as part of the repo-settings (secrets and registry entries shouldn't be used as much so they can be "hidden" under settings IMO) - start page shows list of active repositories with button to enable / add new ones (currently you see all repositories and in most cases you only add new repositories once in a while)
130 lines
4.4 KiB
Vue
130 lines
4.4 KiB
Vue
<template>
|
|
<Panel>
|
|
<div class="flex flex-row border-b mb-4 pb-4 items-center dark:border-gray-600">
|
|
<div class="ml-2">
|
|
<h1 class="text-xl text-gray-500">Registry credentials</h1>
|
|
<p class="text-sm text-gray-400 dark:text-gray-600">
|
|
Registries credentials can be added to use private images for your pipeline.
|
|
<DocsLink url="docs/usage/registry" />
|
|
</p>
|
|
</div>
|
|
<Button
|
|
v-if="showAddRegistry"
|
|
class="ml-auto"
|
|
start-icon="list"
|
|
text="Show registries"
|
|
@click="showAddRegistry = false"
|
|
/>
|
|
<Button v-else class="ml-auto" start-icon="plus" text="Add registry" @click="showAddRegistry = true" />
|
|
</div>
|
|
|
|
<div v-if="!showAddRegistry" class="space-y-4 text-gray-500">
|
|
<ListItem v-for="registry in registries" :key="registry.id" class="items-center">
|
|
<span>{{ registry.address }}</span>
|
|
<IconButton
|
|
icon="trash"
|
|
class="ml-auto w-8 h-8 hover:text-red-400"
|
|
:is-loading="isDeleting"
|
|
@click="deleteRegistry(registry)"
|
|
/>
|
|
</ListItem>
|
|
|
|
<div v-if="registries?.length === 0" class="ml-2">There are no registry credentials yet.</div>
|
|
</div>
|
|
|
|
<div v-else class="space-y-4">
|
|
<form @submit.prevent="createRegistry">
|
|
<InputField label="Address">
|
|
<TextField v-model="selectedRegistry.address" placeholder="Registry Address (e.g. docker.io)" required />
|
|
</InputField>
|
|
|
|
<InputField label="Username">
|
|
<TextField v-model="selectedRegistry.username" placeholder="Username" required />
|
|
</InputField>
|
|
|
|
<InputField label="Password">
|
|
<TextField v-model="selectedRegistry.password" placeholder="Password" required />
|
|
</InputField>
|
|
|
|
<Button type="submit" :is-loading="isSaving" text="Add registry" />
|
|
</form>
|
|
</div>
|
|
</Panel>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { defineComponent, inject, onMounted, Ref, ref } from 'vue';
|
|
|
|
import Button from '~/components/atomic/Button.vue';
|
|
import DocsLink from '~/components/atomic/DocsLink.vue';
|
|
import IconButton from '~/components/atomic/IconButton.vue';
|
|
import ListItem from '~/components/atomic/ListItem.vue';
|
|
import InputField from '~/components/form/InputField.vue';
|
|
import TextField from '~/components/form/TextField.vue';
|
|
import Panel from '~/components/layout/Panel.vue';
|
|
import useApiClient from '~/compositions/useApiClient';
|
|
import { useAsyncAction } from '~/compositions/useAsyncAction';
|
|
import useNotifications from '~/compositions/useNotifications';
|
|
import { Repo } from '~/lib/api/types';
|
|
import { Registry } from '~/lib/api/types/registry';
|
|
|
|
export default defineComponent({
|
|
name: 'RegistriesTab',
|
|
|
|
components: {
|
|
Button,
|
|
Panel,
|
|
ListItem,
|
|
IconButton,
|
|
InputField,
|
|
TextField,
|
|
DocsLink,
|
|
},
|
|
|
|
setup() {
|
|
const apiClient = useApiClient();
|
|
const notifications = useNotifications();
|
|
|
|
const repo = inject<Ref<Repo>>('repo');
|
|
const registries = ref<Registry[]>();
|
|
const showAddRegistry = ref(false);
|
|
const selectedRegistry = ref<Partial<Registry>>({});
|
|
|
|
async function loadRegistries() {
|
|
if (!repo?.value) {
|
|
throw new Error("Unexpected: Can't load repo");
|
|
}
|
|
|
|
registries.value = await apiClient.getRegistryList(repo.value.owner, repo.value.name);
|
|
}
|
|
|
|
const { doSubmit: createRegistry, isLoading: isSaving } = useAsyncAction(async () => {
|
|
if (!repo?.value) {
|
|
throw new Error("Unexpected: Can't load repo");
|
|
}
|
|
|
|
await apiClient.createRegistry(repo.value.owner, repo.value.name, selectedRegistry.value);
|
|
notifications.notify({ title: 'Registry credentials created', type: 'success' });
|
|
showAddRegistry.value = false;
|
|
selectedRegistry.value = {};
|
|
await loadRegistries();
|
|
});
|
|
|
|
const { doSubmit: deleteRegistry, isLoading: isDeleting } = useAsyncAction(async (_registry: Registry) => {
|
|
if (!repo?.value) {
|
|
throw new Error("Unexpected: Can't load repo");
|
|
}
|
|
|
|
await apiClient.deleteRegistry(repo.value.owner, repo.value.name, _registry.address);
|
|
notifications.notify({ title: 'Registry credentials deleted', type: 'success' });
|
|
await loadRegistries();
|
|
});
|
|
|
|
onMounted(async () => {
|
|
await loadRegistries();
|
|
});
|
|
|
|
return { selectedRegistry, registries, showAddRegistry, isSaving, isDeleting, createRegistry, deleteRegistry };
|
|
},
|
|
});
|
|
</script>
|