Skip to content

Commit

Permalink
Fix unneeded things appear during autocomplete (#61)
Browse files Browse the repository at this point in the history
* fix storageTypes link

Signed-off-by: Oleksii Orel <[email protected]>

* fix unneeded things appear during autocomplete

Signed-off-by: Oleksii Orel <[email protected]>

* fixup! fix unneeded things appear during autocomplete
  • Loading branch information
olexii4 authored Aug 31, 2020
1 parent 77088ec commit e3fa786
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 14 deletions.
3 changes: 2 additions & 1 deletion assets/branding/product.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"converting": "https://www.eclipse.org/che/docs/che-7/converting-a-che-6-workspace-to-a-che-7-devfile/",
"certificate": "https://www.eclipse.org/che/docs/che-7/installing-che-in-tls-mode-with-self-signed-certificates/#using-che-with-tls_installing-che-in-tls-mode-with-self-signed-certificates",
"general": "https://www.eclipse.org/che/docs/che-7",
"storageTypes": "https://www.eclipse.org/che/docs/che-7/using-different-type-of-storage/"
"storageTypes": "https://www.eclipse.org/che/docs/che-7/using-different-type-of-storage/",
"webSocketTroubleshooting": "https://www.eclipse.org/che/docs/che-7/troubleshooting-network-problems/#troubleshooting-websocket-secure-connections_troubleshooting-network-problems"
}
}
8 changes: 8 additions & 0 deletions src/app.styl
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
.pf-c-form
--pf-c-form--m-horizontal__group-label--md--GridColumnWidth: 11rem

div.tippy-popper
a
pointer-events initial
a:not(:hover)
--pf-global--link--Color: #73bcf7
a:hover
--pf-global--link--Color: #2b9af3

div.main-page-loader
font-family Helvetica, Arial, sans-serif
font-size 24px
Expand Down
6 changes: 6 additions & 0 deletions src/components/DevfileEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ export class DevfileEditor extends React.PureComponent<Props, State> {
const items = this.props.plugins.plugins;
const components = jsonSchema && jsonSchema.properties ? jsonSchema.properties.components : undefined;
if (components) {
const mountSources = components.items.properties.mountSources;
// mount sources is specific only for some of component types but always appears
// patch schema and remove default value for boolean mount sources to avoid their appearing during the completion
if (mountSources && mountSources.default === 'false') {
delete mountSources.default;
}
jsonSchema.additionalProperties = true;
if (!components.defaultSnippets) {
components.defaultSnippets = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Props = {
onChange?: (storageType: StorageType) => void;
} & {
brandingStore: BrandingStore.State;
workspaces: WorkspaceStore.WorkspacesState,
workspaces: WorkspaceStore.WorkspacesState;
}
type State = {
isOpen?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/GetStarted/GetStartedTab/SamplesListToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
TextInput,
TextInputProps,
} from '@patternfly/react-core';
import { TemporaryStorageSwitch } from './TemporaryStorageSwitch';
import TemporaryStorageSwitch from './TemporaryStorageSwitch';
import * as DevfileFiltersStore from '../../../store/DevfileFilters';
import { AppState } from '../../../store';

Expand Down
21 changes: 20 additions & 1 deletion src/pages/GetStarted/GetStartedTab/TemporaryStorageSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@
import React, { FormEvent } from 'react';
import {
Switch,
Text,
Tooltip,
TooltipPosition
} from '@patternfly/react-core';
import { connect } from 'react-redux';
import { AppState } from '../../../store';
import * as BrandingStore from '../../../store/Branding';
import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons';

type TemporaryStorageSwitchProps = {
persistVolumesDefault: string;
onChange: (temporary: boolean) => void;
} & {
brandingStore: BrandingStore.State;
};

type TemporaryStorageSwitchState = {
Expand All @@ -45,6 +51,7 @@ export class TemporaryStorageSwitch extends React.PureComponent<TemporaryStorage
}

render(): React.ReactElement {
const href = this.props.brandingStore.data.docs.storageTypes;
const isChecked = this.state.isChecked;
return (
<React.Fragment>
Expand All @@ -59,10 +66,16 @@ export class TemporaryStorageSwitch extends React.PureComponent<TemporaryStorage
<span style={{ marginLeft: '10px' }}>
<Tooltip
id="temporary-storage-tooltip"
exitDelay={8000}
isContentLeftAligned={true}
position={TooltipPosition.top}
content={
<div>Temporary Storage allows for faster I/O but may have limited storage and is not persistent.</div>
<React.Fragment>
Temporary Storage allows for faster I/O but may have limited storage and is not persistent.
<Text>
<a rel="noreferrer" target="_blank" href={href}>Open documentation page</a>
</Text>
</React.Fragment>
}
>
<OutlinedQuestionCircleIcon />
Expand All @@ -73,3 +86,9 @@ export class TemporaryStorageSwitch extends React.PureComponent<TemporaryStorage
}

}

export default connect(
(state: AppState) => ({
brandingStore: state.branding,
}),
)(TemporaryStorageSwitch);
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ function createFakeStore(metadata?: che.DevfileMetaData[]): Store {
plugins: [],
},
workspaces: {} as any,
branding: {} as any,
branding: {
data: {
docs: {
storageTypes: 'https://docs.location'
}
}
} as any,
devfileMetadataFilter: {
filter: undefined,
found: metadata || []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ function createFakeStore(metadata?: che.DevfileMetaData[]): Store {
plugins: [],
},
workspaces: {} as any,
branding: {} as any,
branding: {
data: {
docs: {
storageTypes: 'https://docs.location'
}
}
} as any,
devfileMetadataFilter: {
filter: undefined,
found: metadata || []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,25 @@

import React from 'react';
import { RenderResult, render, screen } from '@testing-library/react';
import { TemporaryStorageSwitch } from '../TemporaryStorageSwitch';
import TemporaryStorageSwitch from '../TemporaryStorageSwitch';
import thunk from 'redux-thunk';
import createMockStore from 'redux-mock-store';
import { Provider } from 'react-redux';
import { Store } from 'redux';
import { AppState } from '../../../../store';
import mockMetadata from '../../__tests__/devfileMetadata.json';

describe('Temporary Storage Switch', () => {

const mockOnChange = jest.fn();

function renderSwitch(persistVolumesDefault: 'true' | 'false'): RenderResult {
function renderSwitch(store: Store, persistVolumesDefault: 'true' | 'false'): RenderResult {
return render(
<TemporaryStorageSwitch
persistVolumesDefault={persistVolumesDefault}
onChange={mockOnChange} />
<Provider store={store}>
<TemporaryStorageSwitch
persistVolumesDefault={persistVolumesDefault}
onChange={mockOnChange} />
</Provider>
);
}

Expand All @@ -31,7 +39,8 @@ describe('Temporary Storage Switch', () => {
});

it('should be initially switched on', () => {
renderSwitch('false');
const store = createFakeStoreWithMetadata();
renderSwitch(store, 'false');
const switchInput = screen.getByRole('checkbox') as HTMLInputElement;
expect(switchInput.checked).toBeTruthy();

Expand All @@ -41,7 +50,8 @@ describe('Temporary Storage Switch', () => {
});

it('should be initially switched off', () => {
renderSwitch('true');
const store = createFakeStoreWithMetadata();
renderSwitch(store, 'true');
const switchInput = screen.getByRole('checkbox') as HTMLInputElement;
expect(switchInput.checked).toBeFalsy();

Expand All @@ -51,3 +61,38 @@ describe('Temporary Storage Switch', () => {
});

});

function createFakeStore(metadata?: che.DevfileMetaData[]): Store {
const initialState: AppState = {
factoryResolver: {
isLoading: false,
resolver: {},
},
plugins: {
isLoading: false,
plugins: [],
},
workspaces: {} as any,
branding: {
data: {
docs: {
storageTypes: 'https://docs.location'
}
}
} as any,
devfileMetadataFilter: {
filter: undefined,
found: metadata || []
},
devfileRegistries: {} as any,
user: {} as any,
infrastructureNamespace: {} as any,
};
const middleware = [thunk];
const mockStore = createMockStore(middleware);
return mockStore(initialState);
}

function createFakeStoreWithMetadata(): Store {
return createFakeStore(mockMetadata);
}
4 changes: 3 additions & 1 deletion src/services/bootstrap/branding.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type BrandingDocs = {
certificate: string;
faq?: string;
storageTypes: string,
webSocketTroubleshooting: string,
}

export type BrandingWorkspace = {
Expand Down Expand Up @@ -100,7 +101,8 @@ export const BRANDING_DEFAULT: BrandingData = {
converting: 'https://www.eclipse.org/che/docs/che-7/converting-a-che-6-workspace-to-a-che-7-devfile/',
certificate: 'https://www.eclipse.org/che/docs/che-7/setup-che-in-tls-mode-with-self-signed-certificate/',
general: 'https://www.eclipse.org/che/docs/che-7',
storageTypes: 'https://www.eclipse.org/che/docs/che-7/using-different-type-of-storage/',
storageTypes: 'https://www.eclipse.org/che/docs/che-7/configuring-storage-types/',
webSocketTroubleshooting: 'https://www.eclipse.org/che/docs/che-7/troubleshooting-network-problems/#troubleshooting-websocket-secure-connections_troubleshooting-network-problems',
},
configuration: {
menu: {
Expand Down

0 comments on commit e3fa786

Please sign in to comment.