Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions frontend/packages/console-shared/src/selectors/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ import * as _ from 'lodash';

import { K8sResourceKind } from '@console/internal/module/k8s';

export const getName = (value: K8sResourceKind): string => _.get(value, 'metadata.name');
export const getNamespace = (value: K8sResourceKind): string => _.get(value, 'metadata.namespace');
export const getName = (value: K8sResourceKind) =>
_.get(value, 'metadata.name') as K8sResourceKind['metadata']['name'];
export const getNamespace = (value: K8sResourceKind) =>
_.get(value, 'metadata.namespace') as K8sResourceKind['metadata']['namespace'];
export const getUid = (value: K8sResourceKind) =>
_.get(value, 'metadata.uid') as K8sResourceKind['metadata']['uid'];
export const getDeletetionTimestamp = (value: K8sResourceKind) =>
_.get(value, 'metadata.deletionTimestamp') as K8sResourceKind['metadata']['deletionTimestamp'];
4 changes: 3 additions & 1 deletion frontend/packages/kubevirt-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"@console/internal": "0.0.0-fixed",
"@console/plugin-sdk": "0.0.0-fixed",
"@console/shared": "0.0.0-fixed",
"kubevirt-web-ui-components": "~0.1.35"
"kubevirt-web-ui-components": "~0.1.35",
"kubevirt-typescript-api": "^0.18.1-rc",
"openshift-typescript-api": "^4.1.0-rc1"
},
"consolePlugin": {
"entry": "src/plugin.ts"
Expand Down
60 changes: 0 additions & 60 deletions frontend/packages/kubevirt-plugin/src/components/vms/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@ import * as _ from 'lodash';

import { getResource, getServicesForVm } from 'kubevirt-web-ui-components';

import {
V1VirtualMachine,
V1VirtualMachineInstance,
V1VirtualMachineInstanceMigration,
} from 'kubevirt-typescript-api/esm';
import { V1Pod } from 'openshift-typescript-api/esm';

import {
Firehose,
StatusBox,
ScrollToTopOnMount,
SectionHeading,
FirehoseResult,
} from '@console/internal/components/utils';

import { PodKind } from '@console/internal/module/k8s';
import { PodModel, ServiceModel } from '@console/internal/models';

import { ServicesList } from '@console/internal/components/service';
import { VMKind, VMIKind } from './types';
import { VirtualMachineInstanceModel, VirtualMachineInstanceMigrationModel } from '../../models';
import { VMResourceSummary, VMDetailsList } from './vm-resource';

export const VMDetailsFirehose = ({ obj: vm }: { obj: VMKind }) => {
export const VMDetailsFirehose = ({ obj: vm }: { obj: V1VirtualMachine }) => {
const { name, namespace } = vm.metadata;

const vmiRes = getResource(VirtualMachineInstanceModel, {
Expand Down Expand Up @@ -79,8 +85,8 @@ const VMDetails = (props: VMDetailsProps) => {
};

type VMDetailsProps = {
vm: VMKind;
pods?: PodKind[];
migrations?: any[];
vmi?: VMIKind;
vm: V1VirtualMachine;
pods?: FirehoseResult<V1Pod[]>;
migrations?: FirehoseResult<V1VirtualMachineInstanceMigration[]>;
vmi?: FirehoseResult<V1VirtualMachineInstance>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ import {
} from 'kubevirt-web-ui-components';

import { ResourceSummary, NodeLink, ResourceLink } from '@console/internal/components/utils';
import { PodKind } from '@console/internal/module/k8s';
import { getName, getNamespace, DASH } from '@console/shared';
import { PodModel } from '@console/internal/models';

import { VMKind, VMIKind } from './types';
import {
V1VirtualMachine,
V1VirtualMachineInstance,
V1VirtualMachineInstanceMigration,
} from 'kubevirt-typescript-api/esm';
import { V1Pod } from 'openshift-typescript-api/esm';

export const VMResourceSummary = ({ vm }: VMResourceSummaryProps) => {
const template = getVmTemplate(vm);
Expand Down Expand Up @@ -87,12 +90,12 @@ export const VMDetailsList = ({ vm, vmi, pods, migrations }: VMResourceListProps
};

type VMResourceSummaryProps = {
vm: VMKind;
vm: V1VirtualMachine;
};

type VMResourceListProps = {
vm: VMKind;
pods?: PodKind[];
migrations?: any[];
vmi?: VMIKind;
vm: V1VirtualMachine;
pods?: V1Pod[];
migrations?: V1VirtualMachineInstanceMigration[];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise it would be quite tedious to create all the new types.

+ the whole console & other plugins could benefit from the usual openshift objects

vmi?: V1VirtualMachineInstance;
};
11 changes: 1 addition & 10 deletions frontend/packages/kubevirt-plugin/src/components/vms/vm.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import * as React from 'react';

import {
getName,
getNamespace,
// VmStatus,
// getSimpleVmStatus,
// VM_SIMPLE_STATUS_ALL,
// VM_SIMPLE_STATUS_TO_TEXT,
// getResource,
// DASHES,
} from 'kubevirt-web-ui-components';
import { getName, getNamespace } from '@console/shared/src';

import { NamespaceModel } from '@console/internal/models';
import {
Expand Down
1 change: 1 addition & 0 deletions frontend/public/components/factory/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const TableData: React.SFC<TableDataProps> = ({className, ...props}) => {
};
TableData.displayName = 'TableData';
export type TableDataProps = {
id?: string;
className?: string;
}

Expand Down
8 changes: 5 additions & 3 deletions frontend/public/module/k8s/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export type ObjectReference = {
export type ObjectMetadata = {
name?: string;
generateName?: string;
uid?: string;
annotations?: {[key: string]: string},
namespace?: string,
labels?: {[key: string]: string},
ownerReferences?: OwnerReference[],
deletionTimestamp?: string | Date;
[key: string]: any,
};

Expand All @@ -56,7 +58,7 @@ export type K8sResourceCondition<T> = {
message: string;
};

export type MatchExpression = {key: string, operator: 'Exists' | 'DoesNotExist'} | {key: string, operator: 'In' | 'NotIn' | 'Equals' | 'NotEquals', values: string[]};
export type MatchExpression = {key: string, operator: 'Exists' | 'DoesNotExist' | 'In' | 'NotIn' | 'Equals' | 'NotEquals' | string, values?: string[]};

export type Selector = {
matchLabels?: {[key: string]: string};
Expand All @@ -81,8 +83,8 @@ export type Toleration = {
};

export type K8sResourceKind = {
apiVersion: string;
kind: string;
apiVersion?: string;
kind?: string;
metadata?: ObjectMetadata;
spec?: {
selector?: Selector;
Expand Down
Loading