mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
feat(editor): provide yaml validation for docker compose in the portainer web editor [BE-11697] (#526)
This commit is contained in:
parent
0ebfe047d1
commit
81c5f4acc3
27 changed files with 2046 additions and 36 deletions
|
@ -1,3 +1,5 @@
|
|||
import { useDockerComposeSchema } from '@/react/hooks/useDockerComposeSchema/useDockerComposeSchema';
|
||||
|
||||
import { InlineLoader } from '@@/InlineLoader';
|
||||
import { WebEditorForm } from '@@/WebEditorForm';
|
||||
|
||||
|
@ -14,7 +16,9 @@ export function DockerContentField({
|
|||
readonly?: boolean;
|
||||
isLoading?: boolean;
|
||||
}) {
|
||||
if (isLoading) {
|
||||
const dockerComposeSchemaQuery = useDockerComposeSchema();
|
||||
|
||||
if (isLoading || dockerComposeSchemaQuery.isInitialLoading) {
|
||||
return <InlineLoader>Loading stack content...</InlineLoader>;
|
||||
}
|
||||
|
||||
|
@ -27,6 +31,7 @@ export function DockerContentField({
|
|||
placeholder="Define or paste the content of your docker compose file here"
|
||||
error={error}
|
||||
readonly={readonly}
|
||||
schema={dockerComposeSchemaQuery.data}
|
||||
data-cy="stack-creation-editor"
|
||||
>
|
||||
You can get more information about Compose file format in the{' '}
|
||||
|
|
|
@ -4,8 +4,9 @@ import userEvent from '@testing-library/user-event';
|
|||
|
||||
import { http, server } from '@/setup-tests/server';
|
||||
import selectEvent from '@/react/test-utils/react-select';
|
||||
import { mockCodeMirror } from '@/setup-tests/mock-codemirror';
|
||||
|
||||
import { mockCodeMirror, renderCreateForm } from './utils.test';
|
||||
import { renderCreateForm } from './utils.test';
|
||||
|
||||
// keep mockTemplateId and mockTemplateType in module scope
|
||||
let mockTemplateId: number;
|
||||
|
|
|
@ -4,8 +4,9 @@ import userEvent from '@testing-library/user-event';
|
|||
|
||||
import { http, server } from '@/setup-tests/server';
|
||||
import selectEvent from '@/react/test-utils/react-select';
|
||||
import { mockCodeMirror } from '@/setup-tests/mock-codemirror';
|
||||
|
||||
import { mockCodeMirror, renderCreateForm } from './utils.test';
|
||||
import { renderCreateForm } from './utils.test';
|
||||
|
||||
// keep mockTemplateId and mockTemplateType in module scope
|
||||
let mockTemplateId: number;
|
||||
|
|
|
@ -6,6 +6,7 @@ import { withUserProvider } from '@/react/test-utils/withUserProvider';
|
|||
import { withTestRouter } from '@/react/test-utils/withRouter';
|
||||
import { withTestQueryProvider } from '@/react/test-utils/withTestQuery';
|
||||
import { http, server } from '@/setup-tests/server';
|
||||
import { mockCodeMirror } from '@/setup-tests/mock-codemirror';
|
||||
|
||||
import { CreateForm } from '../CreateForm';
|
||||
|
||||
|
@ -211,13 +212,6 @@ test('The form should render', async () => {
|
|||
});
|
||||
});
|
||||
|
||||
export function mockCodeMirror() {
|
||||
vi.mock('@uiw/react-codemirror', () => ({
|
||||
__esModule: true,
|
||||
default: () => <div />,
|
||||
}));
|
||||
}
|
||||
|
||||
export function renderCreateForm() {
|
||||
// user declaration needs to go at the start for user id related requests (e.g. git credentials)
|
||||
const user = new UserViewModel({ Username: 'user' });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue