-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
157 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
frontend/packages/kubevirt-plugin/src/components/vm-templates/vm-template-details-page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as React from 'react'; | ||
|
||
import { navFactory } from '@console/internal/components/utils'; | ||
|
||
import { DetailsPage } from '@console/internal/components/factory'; | ||
import { K8sResourceKindReference } from '@console/internal/module/k8s'; | ||
|
||
import { TemplateModel } from '@console/internal/models'; | ||
import { VmTemplateDetailsFirehose } from './vm-template-details'; | ||
|
||
export const VmTemplateDetailsPage = (props: VmTemplateDetailsPageProps) => { | ||
const pages = [navFactory.details(VmTemplateDetailsFirehose), navFactory.editYaml()]; | ||
|
||
const menuActions = undefined; // TODO(mlibra): menuActions | ||
|
||
return ( | ||
<DetailsPage | ||
{...props} | ||
name={props.match.params.name} | ||
namespace={props.match.params.ns} | ||
kind={TemplateModel.kind} | ||
kindObj={TemplateModel} | ||
menuActions={menuActions} | ||
pages={pages} | ||
/> | ||
); | ||
}; | ||
|
||
type VmTemplateDetailsPageProps = { | ||
name: string; | ||
namespace: string; | ||
kind: K8sResourceKindReference; | ||
match: any; | ||
}; |
61 changes: 61 additions & 0 deletions
61
frontend/packages/kubevirt-plugin/src/components/vm-templates/vm-template-details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import * as React from 'react'; | ||
|
||
import { getResource } from 'kubevirt-web-ui-components'; | ||
|
||
import { | ||
Firehose, | ||
StatusBox, | ||
ScrollToTopOnMount, | ||
SectionHeading, | ||
} from '@console/internal/components/utils'; | ||
|
||
import { TemplateKind } from '@console/internal/module/k8s'; | ||
import { VmTemplateResourceSummary } from './vm-template-resource'; | ||
import { TemplateModel } from '../../../../../public/models/index'; | ||
|
||
export const VmTemplateDetailsFirehose = ({ obj: template }: { obj: TemplateKind }) => { | ||
const { name, namespace } = template.metadata; | ||
|
||
const vmtRes = getResource(TemplateModel, { | ||
name, | ||
namespace, | ||
isList: false, | ||
prop: 'vmt', | ||
optional: true, | ||
}); | ||
|
||
const resources = [vmtRes]; | ||
|
||
return ( | ||
<div className="co-m-pane__body"> | ||
<Firehose resources={resources}> | ||
<VmTemplateDetails template={template} /> | ||
</Firehose> | ||
</div> | ||
); | ||
}; | ||
|
||
const VmTemplateDetails = (props: VmTemplateDetailsProps) => { | ||
const { template, ...restProps } = props; | ||
const flatResources = { | ||
template, | ||
}; | ||
|
||
return ( | ||
<StatusBox data={template} {...restProps}> | ||
<ScrollToTopOnMount /> | ||
<div className="co-m-pane__body"> | ||
<SectionHeading text="VM Template Overview" /> | ||
<div className="row"> | ||
<div className="col-sm-6"> | ||
<VmTemplateResourceSummary {...flatResources} /> | ||
</div> | ||
</div> | ||
</div> | ||
</StatusBox> | ||
); | ||
}; | ||
|
||
type VmTemplateDetailsProps = { | ||
template: TemplateKind; | ||
}; |
34 changes: 34 additions & 0 deletions
34
frontend/packages/kubevirt-plugin/src/components/vm-templates/vm-template-resource.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as React from 'react'; | ||
|
||
import { | ||
getVmTemplate, | ||
getTemplateDisplayName, | ||
getOperatingSystemName, | ||
getOperatingSystem, | ||
getDescription, | ||
} from 'kubevirt-web-ui-components'; | ||
|
||
import { ResourceSummary } from '@console/internal/components/utils'; | ||
|
||
import { DASH } from '@console/shared'; | ||
import { TemplateKind } from '@console/internal/module/k8s'; | ||
|
||
export const VmTemplateResourceSummary = ({ template }: VmTemplateResourceSummaryProps) => { | ||
const base = getVmTemplate(template); | ||
const baseLink = base && getTemplateDisplayName(base); // TODO(mlibra): link to a template detail, once implemented | ||
|
||
return ( | ||
<ResourceSummary resource={template}> | ||
<dt>Description</dt> | ||
<dd>{getDescription(template)}</dd> | ||
<dt>Operating System</dt> | ||
<dd>{getOperatingSystemName(template) || getOperatingSystem(template) || DASH}</dd> | ||
<dt>Template</dt> | ||
<dd>{baseLink || DASH}</dd> | ||
</ResourceSummary> | ||
); | ||
}; | ||
|
||
type VmTemplateResourceSummaryProps = { | ||
template: TemplateKind; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters