2025-01-24 17:38:18 +01:00
|
|
|
<script setup>
|
|
|
|
|
|
|
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
const i18n = useI18n();
|
|
|
|
|
const t = i18n.t;
|
|
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
import { ref, onMounted, useTemplateRef, inject } from 'vue';
|
2025-05-07 19:05:54 +02:00
|
|
|
import { Button, TableView, InputDialog } from 'pankow';
|
2025-01-24 17:38:18 +01:00
|
|
|
import Section from '../components/Section.vue';
|
2025-05-07 18:10:10 +02:00
|
|
|
import DockerRegistryDialog from '../components/DockerRegistryDialog.vue';
|
|
|
|
|
import DockerRegistriesModel from '../models/DockerRegistriesModel.js';
|
2025-01-24 17:38:18 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
const dockerRegistriesModel = DockerRegistriesModel.create();
|
2025-01-24 17:38:18 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
const registries = ref([]);
|
2025-01-24 17:38:18 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
const columns = {
|
|
|
|
|
serverAddress: {
|
|
|
|
|
label: t('settings.privateDockerRegistry.server'),
|
|
|
|
|
sort: true
|
|
|
|
|
},
|
|
|
|
|
username: {
|
|
|
|
|
label: t('settings.privateDockerRegistry.username'),
|
|
|
|
|
sort: true
|
|
|
|
|
},
|
|
|
|
|
actions: {}
|
|
|
|
|
};
|
2025-01-24 17:38:18 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
const features = inject('features');
|
|
|
|
|
const subscriptionRequiredDialog = inject('subscriptionRequiredDialog');
|
2025-01-24 17:38:18 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
const dialog = useTemplateRef('dialog');
|
2025-05-07 19:05:54 +02:00
|
|
|
const inputDialog = useTemplateRef('inputDialog');
|
2025-01-24 17:38:18 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
function onEditOrAdd(registry = null) {
|
|
|
|
|
if (registry || features.value.privateDockerRegistry) dialog.value.open(registry);
|
|
|
|
|
else subscriptionRequiredDialog.value.open();
|
2025-01-24 17:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
2025-05-07 19:05:54 +02:00
|
|
|
async function onRemove(registry) {
|
|
|
|
|
const yes = await inputDialog.value.confirm({
|
2025-05-07 19:08:22 +02:00
|
|
|
message: t('settings.privateDockerRegistry.deleteQuestion'),
|
2025-05-07 19:05:54 +02:00
|
|
|
confirmStyle: 'danger',
|
|
|
|
|
confirmLabel: t('main.dialog.delete'),
|
|
|
|
|
rejectLabel: t('main.dialog.cancel')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!yes) return;
|
|
|
|
|
|
|
|
|
|
const [error] = await dockerRegistriesModel.remove(registry.id);
|
|
|
|
|
if (error) console.error(error);
|
|
|
|
|
|
|
|
|
|
await refresh();
|
|
|
|
|
}
|
2025-01-24 17:38:18 +01:00
|
|
|
async function refresh() {
|
2025-05-07 18:10:10 +02:00
|
|
|
const [error, result] = await dockerRegistriesModel.list();
|
2025-01-24 17:38:18 +01:00
|
|
|
if (error) return console.error(error);
|
|
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
registries.value = result;
|
2025-01-24 17:38:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await refresh();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-05-22 15:16:04 +02:00
|
|
|
<Section :title="$t('settings.privateDockerRegistry.title')" :title-badge="features.privateDockerRegistry ? 'Upgrade' : ''">
|
2025-05-07 19:05:54 +02:00
|
|
|
<InputDialog ref="inputDialog" />
|
2025-05-07 18:10:10 +02:00
|
|
|
<DockerRegistryDialog ref="dialog" @success="refresh()"/>
|
2025-03-26 18:36:04 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
<template #header-buttons>
|
|
|
|
|
<!-- TODO translate -->
|
|
|
|
|
<Button icon="fa-solid fa-plus" @click="onEditOrAdd()">Add</Button>
|
|
|
|
|
</template>
|
2025-01-24 17:38:18 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
<p v-html="$t('settings.privateDockerRegistry.description', { customAppsLink: 'https://docs.cloudron.io/custom-apps/tutorial/' })"></p>
|
2025-01-24 17:38:18 +01:00
|
|
|
|
2025-05-07 18:10:10 +02:00
|
|
|
<TableView :columns="columns" :model="registries">
|
|
|
|
|
<template #actions="registry">
|
|
|
|
|
<div class="table-actions">
|
|
|
|
|
<Button small tool secondary @click="onEditOrAdd(registry)" icon="fa fa-pencil-alt" />
|
|
|
|
|
<Button small tool danger @click="onRemove(registry)" icon="far fa-trash-alt" />
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</TableView>
|
2025-01-24 17:38:18 +01:00
|
|
|
</Section>
|
|
|
|
|
</template>
|