<template>
	<Dialog v-model="show" :options="{ title: '配置自动更新' }">
		<template #body-content>
			<div class="mt-8">
				<Switch
					v-model="enableAutoUpdate"
					label="启用自动更新"
					description="每当有可用更新时自动安排站点更新"
				/>
			</div>
		</template>
	</Dialog>
</template>

<script>
import { Switch, getCachedDocumentResource } from 'jingrow-ui';

export default {
	props: {
		site: {
			type: String,
			required: true
		}
	},
	components: { Switch },
	data() {
		return {
			show: true
		};
	},
	computed: {
		$site() {
			return getCachedDocumentResource('Site', this.site);
		},
		enableAutoUpdate: {
			get() {
				return !this.$site?.pg.skip_auto_updates;
			},
			set(value) {
				this.$site.setValue.submit({ skip_auto_updates: !value });
			}
		}
	}
};
</script>