1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

feat(edge/templates): introduce custom templates [EE-6208] (#10561)

This commit is contained in:
Chaim Lev-Ari 2023-11-15 10:45:07 +02:00 committed by GitHub
parent a0f583a17d
commit 68950fbb24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 2047 additions and 334 deletions

View file

@ -0,0 +1,49 @@
import { useCurrentStateAndParams, useRouter } from '@uirouter/react';
import { useEffect } from 'react';
import { useCustomTemplate } from '@/react/portainer/templates/custom-templates/queries/useCustomTemplate';
import { notifyError } from '@/portainer/services/notifications';
import { PageHeader } from '@@/PageHeader';
import { Widget } from '@@/Widget';
import { EditTemplateForm } from './EditTemplateForm';
export function EditView() {
const router = useRouter();
const {
params: { id },
} = useCurrentStateAndParams();
const customTemplateQuery = useCustomTemplate(id);
useEffect(() => {
if (customTemplateQuery.data && !customTemplateQuery.data.EdgeTemplate) {
notifyError('Error', new Error('Trying to load non edge template'));
router.stateService.go('^');
}
}, [customTemplateQuery.data, router.stateService]);
if (!customTemplateQuery.data) {
return null;
}
const template = customTemplateQuery.data;
return (
<>
<PageHeader
title="Edit Custom Template"
breadcrumbs={[{ label: 'Custom templates', link: '^' }, template.Title]}
/>
<div className="row">
<div className="col-sm-12">
<Widget>
<Widget.Body>
<EditTemplateForm template={template} />
</Widget.Body>
</Widget>
</div>
</div>
</>
);
}