Skip to content

Commit

Permalink
Merge pull request #1865 from yaacov/kubevirt-vm-template-create-yaml
Browse files Browse the repository at this point in the history
Kubevirt VMTemplate create YAML
  • Loading branch information
openshift-merge-robot authored Jul 2, 2019
2 parents d2b7139 + 3e8d47c commit 95222f3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';

import { CreateYAML } from '@console/internal/components/create-yaml';
import { TemplateModel } from '@console/internal/models';
import { VMTemplateYAMLTemplates } from '../../models/templates';

export const CreateVMTemplateYAML = (props: any) => (
<CreateYAML
{...props as any}
plural={TemplateModel.plural}
template={VMTemplateYAMLTemplates.getIn(['vm-template'])}
/>
);
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { ListPage, Table, TableRow, TableData } from '@console/internal/componen
import { Kebab, ResourceLink, ResourceKebab } from '@console/internal/components/utils';
import { getName, getNamespace, DASH, getUid } from '@console/shared';
import { TemplateModel } from '@console/internal/models';
import { TemplateKind } from '../../../../../public/module/k8s/index';
import { TemplateKind } from '@console/internal/module/k8s';
import { match } from 'react-router';

export const menuActions = Kebab.factory.common;

Expand Down Expand Up @@ -124,14 +125,24 @@ const VirtualMachineTemplates = (props: React.ComponentProps<typeof Table>) => {
);
};

const VirtualMachineTemplatesPage = (props: React.ComponentProps<typeof ListPage>) => (
const getCreateProps = (namespace: string) => ({
items: {
yaml: 'Create from YAML',
},
createLink: () => `/k8s/ns/${namespace || 'default'}/vmtemplates/~new/`,
});

const VirtualMachineTemplatesPage = (
props: VirtualMachineTemplatesPageProps & React.ComponentProps<typeof ListPage>,
) => (
<ListPage
{...props}
title={labelPlural}
ListComponent={VirtualMachineTemplates}
kind={kind}
selector={selector}
canCreate
createProps={getCreateProps(props.match.params.ns)}
/>
);

Expand All @@ -142,4 +153,8 @@ type VmTemplateTableRowProps = {
style: any;
};

type VirtualMachineTemplatesPageProps = {
match: match<{ ns?: string }>;
};

export { VirtualMachineTemplates, VirtualMachineTemplatesPage };
11 changes: 11 additions & 0 deletions frontend/packages/kubevirt-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@ const plugin: Plugin<ConsumedExtensions> = [
).then((m) => m.VirtualMachineTemplatesPage),
},
},
{
type: 'Page/Route',
properties: {
exact: true,
path: ['/k8s/ns/:ns/vmtemplates/~new'],
loader: () =>
import(
'./components/vm-templates/vm-template-create-yaml' /* webpackChunkName: "kubevirt-vmtemplates-create-yaml" */
).then((m) => m.CreateVMTemplateYAML),
},
},
];

export default plugin;

0 comments on commit 95222f3

Please sign in to comment.