From e3fa786cb8aabca360a79e9af63dcb7c302eecee Mon Sep 17 00:00:00 2001 From: Oleksii Orel Date: Mon, 31 Aug 2020 09:55:59 +0300 Subject: [PATCH] Fix unneeded things appear during autocomplete (#61) * fix storageTypes link Signed-off-by: Oleksii Orel * fix unneeded things appear during autocomplete Signed-off-by: Oleksii Orel * fixup! fix unneeded things appear during autocomplete --- assets/branding/product.json | 3 +- src/app.styl | 8 +++ src/components/DevfileEditor/index.tsx | 6 ++ .../CustomWorkspaceTab/StorageType/index.tsx | 2 +- .../GetStartedTab/SamplesListToolbar.tsx | 2 +- .../GetStartedTab/TemporaryStorageSwitch.tsx | 21 ++++++- .../__tests__/SamplesListGallery.spec.tsx | 8 ++- .../__tests__/SamplesListToolbar.spec.tsx | 8 ++- .../__tests__/TemporaryStorageSwitch.spec.tsx | 59 ++++++++++++++++--- src/services/bootstrap/branding.constant.ts | 4 +- 10 files changed, 107 insertions(+), 14 deletions(-) diff --git a/assets/branding/product.json b/assets/branding/product.json index 47180e97d..8e487d6da 100644 --- a/assets/branding/product.json +++ b/assets/branding/product.json @@ -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" } } diff --git a/src/app.styl b/src/app.styl index c5ca6b7c5..05aede91d 100644 --- a/src/app.styl +++ b/src/app.styl @@ -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 diff --git a/src/components/DevfileEditor/index.tsx b/src/components/DevfileEditor/index.tsx index 36532117d..1c2128f2f 100644 --- a/src/components/DevfileEditor/index.tsx +++ b/src/components/DevfileEditor/index.tsx @@ -102,6 +102,12 @@ export class DevfileEditor extends React.PureComponent { 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 = []; diff --git a/src/pages/GetStarted/CustomWorkspaceTab/StorageType/index.tsx b/src/pages/GetStarted/CustomWorkspaceTab/StorageType/index.tsx index 76af15e95..b55b9f100 100644 --- a/src/pages/GetStarted/CustomWorkspaceTab/StorageType/index.tsx +++ b/src/pages/GetStarted/CustomWorkspaceTab/StorageType/index.tsx @@ -41,7 +41,7 @@ type Props = { onChange?: (storageType: StorageType) => void; } & { brandingStore: BrandingStore.State; - workspaces: WorkspaceStore.WorkspacesState, + workspaces: WorkspaceStore.WorkspacesState; } type State = { isOpen?: boolean; diff --git a/src/pages/GetStarted/GetStartedTab/SamplesListToolbar.tsx b/src/pages/GetStarted/GetStartedTab/SamplesListToolbar.tsx index cf48d9e14..a776da1ae 100644 --- a/src/pages/GetStarted/GetStartedTab/SamplesListToolbar.tsx +++ b/src/pages/GetStarted/GetStartedTab/SamplesListToolbar.tsx @@ -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'; diff --git a/src/pages/GetStarted/GetStartedTab/TemporaryStorageSwitch.tsx b/src/pages/GetStarted/GetStartedTab/TemporaryStorageSwitch.tsx index 9ead854c8..012496db9 100644 --- a/src/pages/GetStarted/GetStartedTab/TemporaryStorageSwitch.tsx +++ b/src/pages/GetStarted/GetStartedTab/TemporaryStorageSwitch.tsx @@ -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 = { @@ -45,6 +51,7 @@ export class TemporaryStorageSwitch extends React.PureComponent @@ -59,10 +66,16 @@ export class TemporaryStorageSwitch extends React.PureComponent Temporary Storage allows for faster I/O but may have limited storage and is not persistent. + + Temporary Storage allows for faster I/O but may have limited storage and is not persistent. + + Open documentation page + + } > @@ -73,3 +86,9 @@ export class TemporaryStorageSwitch extends React.PureComponent ({ + brandingStore: state.branding, + }), +)(TemporaryStorageSwitch); diff --git a/src/pages/GetStarted/GetStartedTab/__tests__/SamplesListGallery.spec.tsx b/src/pages/GetStarted/GetStartedTab/__tests__/SamplesListGallery.spec.tsx index 418147a53..c282bbd6e 100644 --- a/src/pages/GetStarted/GetStartedTab/__tests__/SamplesListGallery.spec.tsx +++ b/src/pages/GetStarted/GetStartedTab/__tests__/SamplesListGallery.spec.tsx @@ -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 || [] diff --git a/src/pages/GetStarted/GetStartedTab/__tests__/SamplesListToolbar.spec.tsx b/src/pages/GetStarted/GetStartedTab/__tests__/SamplesListToolbar.spec.tsx index b5bf7f7ee..aa84d4a79 100644 --- a/src/pages/GetStarted/GetStartedTab/__tests__/SamplesListToolbar.spec.tsx +++ b/src/pages/GetStarted/GetStartedTab/__tests__/SamplesListToolbar.spec.tsx @@ -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 || [] diff --git a/src/pages/GetStarted/GetStartedTab/__tests__/TemporaryStorageSwitch.spec.tsx b/src/pages/GetStarted/GetStartedTab/__tests__/TemporaryStorageSwitch.spec.tsx index c32a5a308..fc9d2f8c8 100644 --- a/src/pages/GetStarted/GetStartedTab/__tests__/TemporaryStorageSwitch.spec.tsx +++ b/src/pages/GetStarted/GetStartedTab/__tests__/TemporaryStorageSwitch.spec.tsx @@ -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( - + + + ); } @@ -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(); @@ -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(); @@ -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); +} diff --git a/src/services/bootstrap/branding.constant.ts b/src/services/bootstrap/branding.constant.ts index e8daf4fd4..d92ed3f56 100644 --- a/src/services/bootstrap/branding.constant.ts +++ b/src/services/bootstrap/branding.constant.ts @@ -42,6 +42,7 @@ export type BrandingDocs = { certificate: string; faq?: string; storageTypes: string, + webSocketTroubleshooting: string, } export type BrandingWorkspace = { @@ -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: {