Skip to content

Commit

Permalink
cleanup take 2 (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacov authored Mar 6, 2022
1 parent d1cc6aa commit be71b80
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 945 deletions.
4 changes: 4 additions & 0 deletions bridge/environment.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env sh

echo "Trying to connect to k8s cluster"

BRIDGE_CLUSTER_ENDPOINT=$(oc whoami --show-server)
export BRIDGE_CLUSTER_ENDPOINT

Expand All @@ -24,3 +26,5 @@ echo "BRIDGE_CLUSTER_ALERTMANAGER: $BRIDGE_CLUSTER_ALERTMANAGER"
echo "BRIDGE_STYLEGUIDE_ENDPOINT $BRIDGE_STYLEGUIDE_ENDPOINT"
echo "BRIDGE_PROXY_REWRITE $BRIDGE_PROXY_REWRITE"
echo "BRIDGE_AUTH_BEARER_TOKEN: hidden"

echo "Setup complete"
493 changes: 0 additions & 493 deletions bridge/yarn.lock

This file was deleted.

2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
comment: false
ignore:
- "bridge"
- "bridge"
4 changes: 4 additions & 0 deletions docs/api/kubernetes/apis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Static mock files, representing k8s API server responces

- URL paths are prefixed by `/api/kubernetes`
- GET, POST, PATCH, PUT share the same resources path

This file was deleted.

2 changes: 0 additions & 2 deletions docs/build/bundle.3059b16a.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/build/bundle.f850185e.js

Large diffs are not rendered by default.

File renamed without changes.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
</head>
<body>
<div id="rsg-root"></div>
<script src="build/bundle.3059b16a.js"></script>
<script src="build/bundle.f850185e.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion jest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ configure({
testIdAttribute: 'data-test-id',
});

jest.doMock('@openshift-console/dynamic-plugin-sdk/lib/lib-core', () => ({
jest.doMock('@openshift-console/dynamic-plugin-sdk', () => ({
useK8sWatchResource: jest.fn((props: WatchK8sResource | null) => {
const response = useK8sWatchResourceFS(props);

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test-cov": "jest --coverage",
"styleguide": "styleguidist server",
"styleguide:build": "styleguidist build",
"styleguide:proxy": "source bridge/environment.sh; styleguidist server --config styleguide.config.proxy.js"
"styleguide:record": "source bridge/environment.sh; styleguidist server --config styleguide.config.proxy.js"
},
"dependencies": {
"@kubevirt-ui/kubevirt-api": "^0.0.35",
Expand Down Expand Up @@ -52,7 +52,6 @@
"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"Express": "^3.0.1",
"babel-jest": "^27.4.6",
"babel-loader": "^8.2.3",
"css-loader": "^6.5.1",
Expand All @@ -65,6 +64,7 @@
"eslint-plugin-react": "^7.28.0",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"express": "^4.17.3",
"file-loader": "^6.2.0",
"http": "^0.0.1-security",
"http-proxy-middleware": "^2.0.3",
Expand Down
4 changes: 4 additions & 0 deletions public/api/kubernetes/apis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Static mock files, representing k8s API server responces

- URL paths are prefixed by `/api/kubernetes`
- GET, POST, PATCH, PUT share the same resources path
21 changes: 1 addition & 20 deletions src/components/Utils/DemoComponent/DemoComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import * as React from 'react';
import { cleanup, render } from '@testing-library/react';

import { demoMock } from './__mocks__/demoMock';
import { vmMock } from './__mocks__/vmMock';
import { DemoComponent, externalLogicData } from './DemoComponent';
import { DemoComponent } from './DemoComponent';

afterEach(cleanup);

Expand All @@ -19,21 +18,3 @@ test('Render DemoComponent (none valid vm)', () => {
const { asFragment } = render(<DemoComponent name="none" namespace="does-not-exist" />);
expect(asFragment()).toMatchSnapshot();
});

test('externalLogicData', () => {
const conditions = externalLogicData([vmMock, true, null]);

expect((conditions || []).length).toBe(1);
});

test('externalLogicData (not loaded yet)', () => {
const conditions = externalLogicData([vmMock, false, null]);

expect(conditions).toBe(null);
});

test('externalLogicData (data error)', () => {
const conditions = externalLogicData([vmMock, true, 'Error loading data']);

expect(conditions).toBe(null);
});
21 changes: 5 additions & 16 deletions src/components/Utils/DemoComponent/DemoComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import * as React from 'react';

import { VirtualMachineModelGroupVersionKind } from '@kubevirt-ui/kubevirt-api/console/models/VirtualMachineModel';
import { V1VirtualMachine } from '@kubevirt-ui/kubevirt-api/kubevirt';
import { useK8sWatchResource, WatchK8sResult } from '@openshift-console/dynamic-plugin-sdk';
import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';

import { ConditionLabelList } from '../ConditionLabelList';

export const externalLogicData = (props: WatchK8sResult<V1VirtualMachine>) => {
const [vm, loaded, loadError] = props;
if (!loaded || !!loadError) {
return null;
}

return vm?.status?.conditions;
};
import { externalLogic } from './extrenalLogic';

export interface DemoComponentProps {
/**
Expand All @@ -31,18 +23,15 @@ export interface DemoComponentProps {
*
* This component can me usefull to demo the components repo coding style.
* @param {DemoComponentProps} props name and namespace.
* @param {string} props.name vm name
* @param {string} props.namespace vm namespace
* */
export const DemoComponent: React.FC<DemoComponentProps> = (props: DemoComponentProps) => {
const { name, namespace } = props;
export const DemoComponent: React.FC<DemoComponentProps> = ({ name, namespace }) => {
const [vm, loaded, loadError] = useK8sWatchResource<V1VirtualMachine>({
groupVersionKind: VirtualMachineModelGroupVersionKind,
groupVersionKind: { group: 'kubevirt.io', version: 'v1', kind: 'VirtualMachine' },
name,
namespace,
namespaced: true,
});
const conditions = externalLogicData([vm, loaded, loadError]);
const conditions = externalLogic(vm, loaded, loadError);

return conditions ? <ConditionLabelList conditions={conditions} /> : null;
};
Expand Down
Loading

0 comments on commit be71b80

Please sign in to comment.