Skip to content

Commit

Permalink
feat: Wizard improvements (#1772)
Browse files Browse the repository at this point in the history
* Allows for more inputs where multiple configurations can be present. Updated input data for the Plain Java Enabler. TBD: testing.

Signed-off-by: DianaKorladinova <[email protected]>

* WizardInputs test coverage now at 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* Multiple configs of same category now visually divided, wizard-reducer test coverage raised to 100%

Signed-off-by: ViktorKorladinov <[email protected]>

* Squashed bug occurring after loading already wrapped in array category content.

Signed-off-by: ViktorKorladinov <[email protected]>

* Plain Java Enabler data configuration.

Signed-off-by: DianaKorladinova <[email protected]>

* Wizard reducer refactoring.

Signed-off-by: DianaKorladinova <[email protected]>

* Raised wizard reducer coverage to 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* Foundation for YAML generation.

Signed-off-by: DianaKorladinova <[email protected]>

* YAML now shows in its own tab. TBD: lots of bug squashing.

Signed-off-by: ViktorKorladinov <[email protected]>

* YAML Visualizer test

Signed-off-by: ViktorKorladinov <[email protected]>

* Wizard actions and reducer test coverage raised to 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed Next / Save button bug, added 'Copy' button the the YAML result tab.

Signed-off-by: ViktorKorladinov <[email protected]>

* Test coverage for wizard files raised to 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* Styling of YAML code

Signed-off-by: ViktorKorladinov <[email protected]>

* Added a missing function after merge.

Signed-off-by: DianaKorladinova <[email protected]>

* Hotfix.

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed npm warning on yaml package

Signed-off-by: at670475 <[email protected]>

* Moved the yaml dependency to the correct package.json

Signed-off-by: DianaKorladinova <[email protected]>

* Spring Enabler category configuration

Signed-off-by: DianaKorladinova <[email protected]>

* Created a defaults file and configured spring defaults.

Signed-off-by: ViktorKorladinov <[email protected]>

* Injecting default values operational.

Signed-off-by: DianaKorladinova <[email protected]>

* Raised test coverage to 100% & added a missing category for the Spring Enabler.

Signed-off-by: DianaKorladinova <[email protected]>

* Moved different components into separate sub-folders, reduced size of wizard-config.jsx by dividing the data inside into 2 files - wizard_categories.jsx and wizard_onboarding_methods.jsx.

Signed-off-by: ViktorKorladinov <[email protected]>

* WizardNavigation component now able to group multiple categories under a single tab. Test coverage raised to 100%.

Signed-off-by: ViktorKorladinov <[email protected]>

* Added comments to wizard-actions and all components' functions that weren't self-explanatory.

Signed-off-by: ViktorKorladinov <[email protected]>

* Fixed several bugs after merging. TBD: improve test coverage.

Signed-off-by: DianaKorladinova <[email protected]>

* Test coverage of wizard files raised to 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* Added comments to wizard-reducer, hopefully reduced cognitive complexity

Signed-off-by: ViktorKorladinov <[email protected]>

* Test fixes

Signed-off-by: ViktorKorladinov <[email protected]>

* Mechanism for handling optional fields and checking for empty compulsory fields. TBD: Fix tests.

Signed-off-by: DianaKorladinova <[email protected]>

* Wizard now shows true/false options as checkboxes

Signed-off-by: ViktorKorladinov <[email protected]>

* Boolean property fully works. TBD: mountains of testing : )

Signed-off-by: ViktorKorladinov <[email protected]>

* UI now alerts when a compulsory field is left empty & optional fields are marked as such

Signed-off-by: DianaKorladinova <[email protected]>

* Option property fully works. Fake events substitute the events Select fires.

Signed-off-by: ViktorKorladinov <[email protected]>

* Improved test coverage.

Signed-off-by: DianaKorladinova <[email protected]>

* Test coverage for WizardInputs raised.

Signed-off-by: ViktorKorladinov <[email protected]>

* Redid functions for unfilled compulsory fields. TBD: fix tests

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed failing tests & improved test coverage.

Signed-off-by: DianaKorladinova <[email protected]>

* maxLength and lowercase properties functional.

Signed-off-by: ViktorKorladinov <[email protected]>

* Tab reorganization.

Signed-off-by: DianaKorladinova <[email protected]>

* Hotfix.

Signed-off-by: DianaKorladinova <[email protected]>

* Dependencies now functional.

Signed-off-by: ViktorKorladinov <[email protected]>

* Tabs now indicate if they have an unfilled field & improved test coverage.

Signed-off-by: DianaKorladinova <[email protected]>

* Test coverage of WizardInputs raised

Signed-off-by: ViktorKorladinov <[email protected]>

* Added mechanism for generating warnings when deleting filled fields & improved test coverage. TBD: Add the actual warnings

Signed-off-by: DianaKorladinova <[email protected]>

* Hotfixes of unfilled validation

Signed-off-by: ViktorKorladinov <[email protected]>

* Fixed failing tests.

Signed-off-by: DianaKorladinova <[email protected]>

* Restructuring. TBD: fix tests.

Signed-off-by: DianaKorladinova <[email protected]>

* Raised coverage of WizardNavigation, WizardInputs and WizardDialog to 100.

Signed-off-by: ViktorKorladinov <[email protected]>

* Fixed wizard-reducer tests.

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed some code smells.

Signed-off-by: ViktorKorladinov <[email protected]>

* Indentation dependency now available. TBD: fix tests.

Signed-off-by: DianaKorladinova <[email protected]>

* Array wrapping of some YAML categories for static onboarding. TBD: fix tests.

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed & added tests.

Signed-off-by: DianaKorladinova <[email protected]>

* Wizard dialog 'Next' button fix.

Signed-off-by: DianaKorladinova <[email protected]>

* Post-merge fixes.

Signed-off-by: DianaKorladinova <[email protected]>

* Node Enabler configuration.

Signed-off-by: DianaKorladinova <[email protected]>

* Array indentation mechanism for Micronaut & fixed some tests.

Signed-off-by: DianaKorladinova <[email protected]>

* Micronaut default values.

Signed-off-by: DianaKorladinova <[email protected]>

* Raised test coverage of wizard-reducer and wizard-actions to 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* Divided category configurations into separate files to improve readability

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed the code smell (hopefully).

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed the code smell (hopefully).

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed the code smell (hopefully).

Signed-off-by: DianaKorladinova <[email protected]>

* Added tooltips for some of the fields & stricter validation (valid URLs, semantic versioning, etc.). TBD: raise test coverage.

Signed-off-by: DianaKorladinova <[email protected]>

* Regex fixes and empty fields dont show up

Signed-off-by: ViktorKorladinov <[email protected]>

* Raised test coverage of WizardInputs to 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* PJE configuration changes, dotted passwords, wizard-actions test coverage now at 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* Inputs can now be hidden with the property hide.

Signed-off-by: ViktorKorladinov <[email protected]>

* Node and Static configuration, added stricter data validation, etc.

Signed-off-by: DianaKorladinova <[email protected]>

* Input fields can now be hidden from wizard_defaults, changed category configuration

Signed-off-by: DianaKorladinova <[email protected]>

* Categories now can have minions - categories that copy the amount of sets of their master and some of his values

Signed-off-by: ViktorKorladinov <[email protected]>

* Minions now can share certain values of their masters and are disabled

Signed-off-by: ViktorKorladinov <[email protected]>

* Test coverage of all wizard-related files now back at 100%.

Signed-off-by: DianaKorladinova <[email protected]>

* 'Routes' and 'API info' configuration for all enablers.

Signed-off-by: DianaKorladinova <[email protected]>

* Category catalog now accepts custom / dynamically generated values depending on the user's choice

Signed-off-by: ViktorKorladinov <[email protected]>

* Added explanation & updated configuration for the 'Authentication' category.

Signed-off-by: DianaKorladinova <[email protected]>

* Test coverage of all wizard files at 100% now.

Signed-off-by: DianaKorladinova <[email protected]>

* Code smells fixes

Signed-off-by: ViktorKorladinov <[email protected]>

* hotfix

Signed-off-by: ViktorKorladinov <[email protected]>

* No async func

Signed-off-by: ViktorKorladinov <[email protected]>

* Interference injection more general now & fixed test coverage of WizardInputs.

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed select elements

Signed-off-by: ViktorKorladinov <[email protected]>

* SAF check performed after generating YAML instead.

Signed-off-by: ViktorKorladinov <[email protected]>

* Regex checks now trigger wizard-wide warnings as well.

Signed-off-by: ViktorKorladinov <[email protected]>

* Failed regex checks now generate a tooltip.

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed breaking tests.

Signed-off-by: ViktorKorladinov <[email protected]>

* Catalog tiles for static onboarding now works as well.

Signed-off-by: ViktorKorladinov <[email protected]>

* Category configuration.

Signed-off-by: DianaKorladinova <[email protected]>

* Fixed failing tests & added new.

Signed-off-by: DianaKorladinova <[email protected]>

* Tweak routes messaging

Signed-off-by: jandadav <[email protected]>

* Regex version fix.

Signed-off-by: DianaKorladinova <[email protected]>

Co-authored-by: ViktorKorladinov <[email protected]>
Co-authored-by: Andrea Tabone <[email protected]>
Co-authored-by: jandadav <[email protected]>
  • Loading branch information
4 people authored Sep 14, 2021
1 parent 0dae7fc commit 20dd70b
Show file tree
Hide file tree
Showing 24 changed files with 1,068 additions and 260 deletions.
84 changes: 59 additions & 25 deletions api-catalog-ui/frontend/src/actions/wizard-actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ export function wizardToggleDisplay() {
* @param enablerName the type/name of the onboarding method
*/
export function selectEnabler(enablerName) {
return {
type: SELECT_ENABLER,
payload: { enablerName },
return (dispatch, getState) => {
const { tiles } = getState().tilesReducer;
dispatch({
type: SELECT_ENABLER,
payload: { enablerName, tiles: tiles.map(tile => tile.title) },
});
};
}

Expand Down Expand Up @@ -134,6 +137,52 @@ export function handleArrayIndentation(arrIndent, content) {
return finalContent;
}

/**
* Checks if the current key/value pair should be placed in the yaml
* @param valueObj object containing the value and the properties of the field
* @returns {boolean} should be placed
*/
const shouldBePlacedInYAML = valueObj => {
if (valueObj.show !== false && valueObj.hidden !== true) {
return valueObj.value !== '' || valueObj.optional !== true;
}
return false;
};

/**
* Updates the YAML with a category that has a multiple property set to true
* @param category category object
* @returns {*} an array containing the sets of data ready to be presented as YAML
*/
function handleCategoryMultiple(category) {
let content = [];
let index = 0;
if (category.noKey) {
category.content.forEach(o => {
Object.keys(o).forEach(key => {
const valueObj = category.content[index][key];
if (shouldBePlacedInYAML(valueObj)) {
content[index] = category.content[index][key].value;
}
});
index += 1;
});
} else {
category.content.forEach(o => {
content[index] = {};
Object.keys(o).forEach(key => {
const valueObj = category.content[index][key];
if (shouldBePlacedInYAML(valueObj)) {
content[index][key] = category.content[index][key].value;
}
});
content = handleArrayIndentation(category.arrIndent, content);
index += 1;
});
}
return content;
}

/**
* Receives a single category and translates it to an object the yaml library can correctly convert to yaml
* @param category a category
Expand All @@ -144,33 +193,18 @@ export function handleArrayIndentation(arrIndent, content) {
export const addCategoryToYamlObject = (category, parent, inputData) => {
const result = { ...parent };
let content = {};

// load user's answer into content object
if (!category.multiple) {
Object.keys(category.content[0]).forEach(key => {
if (category.content[0][key].show !== false) {
content[key] = category.content[0][key].value;
const contentElement = category.content[0];
Object.keys(contentElement).forEach(key => {
const valueObj = contentElement[key];
if (shouldBePlacedInYAML(valueObj)) {
content[key] = contentElement[key].value;
}
});
} else {
content = [];
let index = 0;
if (category.noKey) {
category.content.forEach(o => {
Object.keys(o).forEach(key => {
content[index] = category.content[index][key].value;
});
index += 1;
});
} else {
category.content.forEach(o => {
content[index] = {};
Object.keys(o).forEach(key => {
content[index][key] = category.content[index][key].value;
});
content = handleArrayIndentation(category.arrIndent, content);
index += 1;
});
}
content = handleCategoryMultiple(category);
}
// handle indentation, if any
if (!category.indentation) {
Expand Down
43 changes: 39 additions & 4 deletions api-catalog-ui/frontend/src/actions/wizard-actions.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ describe('>>> Wizard actions tests', () => {
expect(actions.wizardToggleDisplay()).toEqual(expectedAction);
});
it('should select enabler', () => {
const tiles = [{title:'test', id:'2'}];
const expectedAction = {
type: constants.SELECT_ENABLER,
payload: { enablerName: 'Test' },
payload: { enablerName: 'Test', tiles: ['test'] },
};
expect(actions.selectEnabler('Test')).toEqual(expectedAction);
const fn = jest.fn();
actions.selectEnabler('Test')(fn, ()=>({tilesReducer:{tiles}}))
expect(fn).toHaveBeenCalledWith(expectedAction);
});
it('should insert if parent is empty', () => {
const parent = {};
Expand Down Expand Up @@ -69,7 +72,6 @@ describe('>>> Wizard actions tests', () => {
let result = { test2: 'test 2' };
result = addCategoryToYamlObject(category, result);
expect(result).toEqual({ test: 'yaml', test2: 'test 2' });

});
it('should add categories to the YAML object when content is an array', () => {
const category = {
Expand Down Expand Up @@ -181,7 +183,40 @@ describe('>>> Wizard actions tests', () => {
};
let result = { test2: 'test 2' };
result = addCategoryToYamlObject(category, result);
expect(result).toEqual({ test2: 'test 2' });});
expect(result).toEqual({ test2: 'test 2' });
});
it('should not add empty optional values', () => {
const category = {
text: 'Category 1',
content: [{ test: { value: '', show: true, optional: true} }],
multiple: false,
indentation: '/',
};
let result = {};
result = addCategoryToYamlObject(category, result);
expect(result).toEqual({});});
it('should not add multiple empty optional keyless values', () => {
const category = {
text: 'Category 1',
content: [{ test: { value: '', show: true, optional: true,} }],
multiple: true,
indentation: '/',
noKey: true,
};
let result = {};
result = addCategoryToYamlObject(category, result);
expect(result).toEqual({});});
it('should not add multiple empty optional values', () => {
const category = {
text: 'Category 1',
content: [
{ test: { value: '', show: true, optional: true,} },
],
multiple: true,
};
let result = {};
result = addCategoryToYamlObject(category, result);
expect(result).toEqual({0: {}});});
it('should change the category', () => {
const expectedAction = {
type: constants.CHANGE_CATEGORY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import ConfirmDialogContainer from '../Wizard/ConfirmDialogContainer';

export default class Dashboard extends Component {
componentDidMount() {
const { fetchTilesStart, clearService, assertAuthorization } = this.props;
assertAuthorization();
const { fetchTilesStart, clearService } = this.props;
clearService();
fetchTilesStart();
}
Expand Down Expand Up @@ -51,7 +50,6 @@ export default class Dashboard extends Component {
fetchTilesStop,
refreshedStaticApisError,
clearError,
userCanAutoOnboard,
} = this.props;
const hasSearchCriteria = searchCriteria !== undefined && searchCriteria !== null && searchCriteria.length > 0;
const hasTiles = !fetchTilesError && tiles && tiles.length > 0;
Expand All @@ -66,7 +64,6 @@ export default class Dashboard extends Component {
<div id="dash-buttons">
<DialogDropdown
selectEnabler={this.props.selectEnabler}
userCanAutoOnboard={userCanAutoOnboard}
data={enablerData}
toggleWizard={this.toggleWizard}
visible
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { filterText, clear } from '../../actions/filter-actions';
import { createLoadingSelector, getVisibleTiles } from '../../selectors/selectors';
import { clearError, refreshedStaticApi } from '../../actions/refresh-static-apis-actions';
import { selectEnabler, wizardToggleDisplay } from '../../actions/wizard-actions';
import { assertAuthorization } from '../../actions/wizard-fetch-actions';

const loadingSelector = createLoadingSelector(['FETCH_TILES']);

Expand All @@ -22,7 +21,6 @@ const mapStateToProps = state => ({
isLoading: loadingSelector(state),
refreshedStaticApisError: state.refreshStaticApisReducer.error,
refreshTimestamp: state.refreshStaticApisReducer.refreshTimestamp,
userCanAutoOnboard: state.wizardReducer.userCanAutoOnboard,
});

const mapDispatchToProps = {
Expand All @@ -35,7 +33,6 @@ const mapDispatchToProps = {
clear,
refreshedStaticApi,
clearError,
assertAuthorization,
wizardToggleDisplay,
selectEnabler,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ export default class DialogDropdown extends Component {
openOnClick() {
const { data } = this.state;
if (Array.isArray(data)) {
let arr = data.map(item => ({ ...item, onClick: this.handleClick }));
if (!this.props.userCanAutoOnboard) {
arr = arr.filter(item => item.text !== 'Static Onboarding');
}
const arr = data.map(item => ({ ...item, onClick: this.handleClick }));
this.setState({ data: arr });
}
}
Expand Down
Loading

0 comments on commit 20dd70b

Please sign in to comment.