2021-11-03 16:40:31 +00:00
|
|
|
<template>
|
2023-08-21 08:23:16 +00:00
|
|
|
<Settings
|
2024-01-27 20:15:10 +00:00
|
|
|
:title="$t('repo.settings.registries.credentials')"
|
2023-08-21 08:23:16 +00:00
|
|
|
:desc="$t('repo.settings.registries.desc')"
|
|
|
|
docs-url="docs/usage/registries"
|
|
|
|
>
|
|
|
|
<template #titleActions>
|
2021-11-03 16:40:31 +00:00
|
|
|
<Button
|
2022-03-01 23:19:33 +00:00
|
|
|
v-if="selectedRegistry"
|
|
|
|
start-icon="back"
|
2022-05-16 19:18:48 +00:00
|
|
|
:text="$t('repo.settings.registries.show')"
|
2022-03-01 23:19:33 +00:00
|
|
|
@click="selectedRegistry = undefined"
|
2021-11-03 16:40:31 +00:00
|
|
|
/>
|
2023-08-21 08:23:16 +00:00
|
|
|
<Button v-else start-icon="plus" :text="$t('repo.settings.registries.add')" @click="selectedRegistry = {}" />
|
|
|
|
</template>
|
2021-11-03 16:40:31 +00:00
|
|
|
|
Use consistent woodpecker color scheme (#2003)
Fixes: https://github.com/woodpecker-ci/woodpecker/issues/1079
What do you think about using a consistent `woodpecker` color scheme?
Right now, the `lime` color scheme from windicss is used that does not
really fit the primary color used for the documentation website. I have
used the primary color `#4CAF50` from the docs and created a color
palette with https://palettte.app/:
<details>
<summary>JSON source</summary>
```Json
[
{
"paletteName": "New Palette",
"swatches": [
{
"name": "New Swatch",
"color": "166E30"
},
{
"name": "New Swatch",
"color": "248438"
},
{
"name": "New Swatch",
"color": "369943"
},
{
"name": "New Swatch",
"color": "4CAF50"
},
{
"name": "New Swatch",
"color": "68C464"
},
{
"name": "New Swatch",
"color": "8AD97F"
}
]
}
]
```
</details>
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/a254f1e0-ce17-43a9-9e8b-72252296fd6f)
I have added this color scheme to the windicss config and replaced the
use of `lime` in the UI. While `woodpecker-300` would be the primary
color that is used for the docs, I currently use `woodpecke-400` as
primary color for the UI to fix some contrast issues.
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/7bf751e1-f2a6-481c-bee7-a27d27cf8adb)
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/e5673dc7-81c1-4fd4-bef9-14494bc5aa27)
What do you think? If you would like to stay with the current colors,
that's fine for me, I can just use the custom CSS feature in this case.
---------
Co-authored-by: 6543 <6543@obermui.de>
2023-08-02 07:09:12 +00:00
|
|
|
<div v-if="!selectedRegistry" class="space-y-4 text-wp-text-100">
|
|
|
|
<ListItem
|
|
|
|
v-for="registry in registries"
|
|
|
|
:key="registry.id"
|
|
|
|
class="items-center !bg-wp-background-200 !dark:bg-wp-background-100"
|
|
|
|
>
|
2021-11-03 16:40:31 +00:00
|
|
|
<span>{{ registry.address }}</span>
|
2022-10-08 17:06:53 +00:00
|
|
|
<IconButton
|
|
|
|
icon="edit"
|
|
|
|
class="ml-auto w-8 h-8"
|
|
|
|
:title="$t('repo.settings.registries.edit')"
|
|
|
|
@click="selectedRegistry = registry"
|
|
|
|
/>
|
2021-11-03 16:40:31 +00:00
|
|
|
<IconButton
|
|
|
|
icon="trash"
|
Use consistent woodpecker color scheme (#2003)
Fixes: https://github.com/woodpecker-ci/woodpecker/issues/1079
What do you think about using a consistent `woodpecker` color scheme?
Right now, the `lime` color scheme from windicss is used that does not
really fit the primary color used for the documentation website. I have
used the primary color `#4CAF50` from the docs and created a color
palette with https://palettte.app/:
<details>
<summary>JSON source</summary>
```Json
[
{
"paletteName": "New Palette",
"swatches": [
{
"name": "New Swatch",
"color": "166E30"
},
{
"name": "New Swatch",
"color": "248438"
},
{
"name": "New Swatch",
"color": "369943"
},
{
"name": "New Swatch",
"color": "4CAF50"
},
{
"name": "New Swatch",
"color": "68C464"
},
{
"name": "New Swatch",
"color": "8AD97F"
}
]
}
]
```
</details>
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/a254f1e0-ce17-43a9-9e8b-72252296fd6f)
I have added this color scheme to the windicss config and replaced the
use of `lime` in the UI. While `woodpecker-300` would be the primary
color that is used for the docs, I currently use `woodpecke-400` as
primary color for the UI to fix some contrast issues.
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/7bf751e1-f2a6-481c-bee7-a27d27cf8adb)
![image](https://github.com/woodpecker-ci/woodpecker/assets/3391958/e5673dc7-81c1-4fd4-bef9-14494bc5aa27)
What do you think? If you would like to stay with the current colors,
that's fine for me, I can just use the custom CSS feature in this case.
---------
Co-authored-by: 6543 <6543@obermui.de>
2023-08-02 07:09:12 +00:00
|
|
|
class="w-8 h-8 hover:text-wp-control-error-100"
|
2021-11-03 16:40:31 +00:00
|
|
|
:is-loading="isDeleting"
|
2022-10-08 17:06:53 +00:00
|
|
|
:title="$t('repo.settings.registries.delete')"
|
2021-11-03 16:40:31 +00:00
|
|
|
@click="deleteRegistry(registry)"
|
|
|
|
/>
|
|
|
|
</ListItem>
|
|
|
|
|
2022-05-16 19:18:48 +00:00
|
|
|
<div v-if="registries?.length === 0" class="ml-2">{{ $t('repo.settings.registries.none') }}</div>
|
2021-11-03 16:40:31 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-else class="space-y-4">
|
|
|
|
<form @submit.prevent="createRegistry">
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('repo.settings.registries.address.address')">
|
2021-11-25 18:04:36 +00:00
|
|
|
<!-- TODO: check input field Address is a valid address -->
|
2022-03-01 23:19:33 +00:00
|
|
|
<TextField
|
2023-12-19 20:32:35 +00:00
|
|
|
:id="id"
|
2022-03-01 23:19:33 +00:00
|
|
|
v-model="selectedRegistry.address"
|
2022-05-16 19:18:48 +00:00
|
|
|
:placeholder="$t('repo.settings.registries.address.placeholder')"
|
2022-03-01 23:19:33 +00:00
|
|
|
required
|
|
|
|
:disabled="isEditingRegistry"
|
|
|
|
/>
|
2021-11-03 16:40:31 +00:00
|
|
|
</InputField>
|
|
|
|
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('username')">
|
|
|
|
<TextField :id="id" v-model="selectedRegistry.username" :placeholder="$t('username')" required />
|
2021-11-03 16:40:31 +00:00
|
|
|
</InputField>
|
|
|
|
|
2023-12-19 20:32:35 +00:00
|
|
|
<InputField v-slot="{ id }" :label="$t('password')">
|
|
|
|
<TextField :id="id" v-model="selectedRegistry.password" :placeholder="$t('password')" required />
|
2021-11-03 16:40:31 +00:00
|
|
|
</InputField>
|
|
|
|
|
2023-03-19 12:52:58 +00:00
|
|
|
<div class="flex gap-2">
|
|
|
|
<Button type="button" color="gray" :text="$t('cancel')" @click="selectedRegistry = undefined" />
|
|
|
|
<Button
|
|
|
|
type="submit"
|
|
|
|
color="green"
|
|
|
|
:is-loading="isSaving"
|
|
|
|
:text="isEditingRegistry ? $t('repo.settings.registries.save') : $t('repo.settings.registries.add')"
|
|
|
|
/>
|
|
|
|
</div>
|
2021-11-03 16:40:31 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
2023-08-21 08:23:16 +00:00
|
|
|
</Settings>
|
2021-11-03 16:40:31 +00:00
|
|
|
</template>
|
|
|
|
|
2023-08-08 10:22:39 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, inject, Ref, ref } from 'vue';
|
2022-05-16 19:18:48 +00:00
|
|
|
import { useI18n } from 'vue-i18n';
|
2021-11-03 16:40:31 +00:00
|
|
|
|
|
|
|
import Button from '~/components/atomic/Button.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';
|
2023-08-21 08:23:16 +00:00
|
|
|
import Settings from '~/components/layout/Settings.vue';
|
2021-11-03 16:40:31 +00:00
|
|
|
import useApiClient from '~/compositions/useApiClient';
|
|
|
|
import { useAsyncAction } from '~/compositions/useAsyncAction';
|
|
|
|
import useNotifications from '~/compositions/useNotifications';
|
2023-04-30 01:40:13 +00:00
|
|
|
import { usePagination } from '~/compositions/usePaginate';
|
2021-11-03 16:40:31 +00:00
|
|
|
import { Repo } from '~/lib/api/types';
|
|
|
|
import { Registry } from '~/lib/api/types/registry';
|
|
|
|
|
2023-08-08 10:22:39 +00:00
|
|
|
const apiClient = useApiClient();
|
|
|
|
const notifications = useNotifications();
|
|
|
|
const i18n = useI18n();
|
|
|
|
|
|
|
|
const repo = inject<Ref<Repo>>('repo');
|
|
|
|
const selectedRegistry = ref<Partial<Registry>>();
|
|
|
|
const isEditingRegistry = computed(() => !!selectedRegistry.value?.id);
|
|
|
|
|
|
|
|
async function loadRegistries(page: number): Promise<Registry[] | null> {
|
|
|
|
if (!repo?.value) {
|
|
|
|
throw new Error("Unexpected: Can't load repo");
|
|
|
|
}
|
|
|
|
|
|
|
|
return apiClient.getRegistryList(repo.value.id, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
const { resetPage, data: registries } = usePagination(loadRegistries, () => !selectedRegistry.value);
|
|
|
|
|
|
|
|
const { doSubmit: createRegistry, isLoading: isSaving } = useAsyncAction(async () => {
|
|
|
|
if (!repo?.value) {
|
|
|
|
throw new Error("Unexpected: Can't load repo");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!selectedRegistry.value) {
|
|
|
|
throw new Error("Unexpected: Can't get registry");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isEditingRegistry.value) {
|
|
|
|
await apiClient.updateRegistry(repo.value.id, selectedRegistry.value);
|
|
|
|
} else {
|
|
|
|
await apiClient.createRegistry(repo.value.id, selectedRegistry.value);
|
|
|
|
}
|
|
|
|
notifications.notify({
|
|
|
|
title: i18n.t(
|
|
|
|
isEditingRegistry.value ? 'repo.settings.registries.saved' : i18n.t('repo.settings.registries.created'),
|
|
|
|
),
|
|
|
|
type: 'success',
|
|
|
|
});
|
|
|
|
selectedRegistry.value = undefined;
|
|
|
|
resetPage();
|
|
|
|
});
|
|
|
|
|
|
|
|
const { doSubmit: deleteRegistry, isLoading: isDeleting } = useAsyncAction(async (_registry: Registry) => {
|
|
|
|
if (!repo?.value) {
|
|
|
|
throw new Error("Unexpected: Can't load repo");
|
|
|
|
}
|
|
|
|
|
|
|
|
const registryAddress = encodeURIComponent(_registry.address);
|
|
|
|
await apiClient.deleteRegistry(repo.value.id, registryAddress);
|
|
|
|
notifications.notify({ title: i18n.t('repo.settings.registries.deleted'), type: 'success' });
|
|
|
|
resetPage();
|
2021-11-03 16:40:31 +00:00
|
|
|
});
|
|
|
|
</script>
|