diff --git a/src/main/webui/src/app/components/content/GroupEdit.jsx b/src/main/webui/src/app/components/content/GroupEdit.jsx index c8ad006..b03752c 100644 --- a/src/main/webui/src/app/components/content/GroupEdit.jsx +++ b/src/main/webui/src/app/components/content/GroupEdit.jsx @@ -14,24 +14,8 @@ * limitations under the License. */ -import React, {useState, useEffect} from 'react'; -import {useLocation, useNavigate, useParams} from 'react-router-dom'; -import {PropTypes} from 'prop-types'; -import {StoreEditControlPanel as EditControlPanel} from './StoreControlPanels.jsx'; -import {DisableTimeoutHint, DurationHint, PrefetchHint, Hint} from './Hints.jsx'; -import {PackageTypeSelect} from './CommonPageWidget.jsx'; -// import ViewJsonDebugger from './Debugger.jsx'; -import {Utils} from '../CompUtils.js'; -// import Filters from '../Filters.js'; -import {TimeUtils} from '../../TimeUtils.js'; -import {jsonRest} from '../../RestClient.js'; - +import React from 'react'; export default function GroupEdit() { - const [state, setState] = useState({ - store: {}, - storeView: {} - }); - return
This is not implemented yet!
; } diff --git a/src/main/webui/src/app/components/content/GroupList.jsx b/src/main/webui/src/app/components/content/GroupList.jsx index 85375ab..f7b207d 100644 --- a/src/main/webui/src/app/components/content/GroupList.jsx +++ b/src/main/webui/src/app/components/content/GroupList.jsx @@ -14,19 +14,8 @@ * limitations under the License. */ -import React, {useEffect, useState} from 'react'; -import {Link} from 'react-router-dom'; -import {PropTypes} from 'prop-types'; -import {Utils} from '../CompUtils.js'; -import ListControl from "./ListControl.jsx"; -import {ListJsonDebugger} from './Debugger.jsx'; -import {LocalURLSection, StoreNameSection} from './CommonPageWidget.jsx'; +import React from 'react'; export default function GruopList() { - const [state, setState] = useState({ - store: {}, - raw: {}, - message: '' - }); return
This is not implemented yet!
; } diff --git a/src/main/webui/src/app/components/content/GroupView.jsx b/src/main/webui/src/app/components/content/GroupView.jsx index 1149ecd..bceed09 100644 --- a/src/main/webui/src/app/components/content/GroupView.jsx +++ b/src/main/webui/src/app/components/content/GroupView.jsx @@ -14,21 +14,8 @@ * limitations under the License. */ -import React, {useEffect, useState} from 'react'; -import {Link, useParams} from 'react-router-dom'; -import {PropTypes} from 'prop-types'; -import {StoreViewControlPanel as ControlPanel} from './StoreControlPanels.jsx'; -import {DisableTimeoutHint} from './Hints.jsx'; -import {Utils} from '../CompUtils.js'; -import {Filters} from '../Filters.js'; -import {TimeUtils} from '../../TimeUtils.js'; -import {jsonGet} from '../../RestClient.js'; +import React from 'react'; export default function GroupView() { - const [state, setState] = useState({ - store: {}, - raw: {}, - message: '' - }); return
This is not implemented yet!
; } diff --git a/src/main/webui/src/app/components/content/HostedEdit.jsx b/src/main/webui/src/app/components/content/HostedEdit.jsx index 28c8d3d..989e740 100644 --- a/src/main/webui/src/app/components/content/HostedEdit.jsx +++ b/src/main/webui/src/app/components/content/HostedEdit.jsx @@ -14,24 +14,8 @@ * limitations under the License. */ -import React, {useState, useEffect} from 'react'; -import {useLocation, useNavigate, useParams} from 'react-router-dom'; -import {PropTypes} from 'prop-types'; -import {StoreEditControlPanel as EditControlPanel} from './StoreControlPanels.jsx'; -import {DisableTimeoutHint, DurationHint, PrefetchHint, Hint} from './Hints.jsx'; -import {PackageTypeSelect} from './CommonPageWidget.jsx'; -// import ViewJsonDebugger from './Debugger.jsx'; -import {Utils} from '../CompUtils.js'; -// import Filters from '../Filters.js'; -import {TimeUtils} from '../../TimeUtils.js'; -import {jsonRest} from '../../RestClient.js'; - +import React from 'react'; export default function HostedEdit() { - const [state, setState] = useState({ - store: {}, - storeView: {} - }); - return
This is not implemented yet!
; } diff --git a/src/main/webui/src/app/components/content/HostedList.jsx b/src/main/webui/src/app/components/content/HostedList.jsx index 8fe5794..83eafee 100644 --- a/src/main/webui/src/app/components/content/HostedList.jsx +++ b/src/main/webui/src/app/components/content/HostedList.jsx @@ -14,23 +14,9 @@ * limitations under the License. */ -import React, {useEffect, useState} from 'react'; -import ListControl from "./ListControl.jsx"; -import {ListJsonDebugger} from './Debugger.jsx'; -import {Utils} from '../CompUtils.js'; -import {hostedOptionLegend as options} from "../ComponentConstants.js"; -import {StoreListingWidget} from './CommonPageWidget.jsx'; - +import React from 'react'; export default function HostedList() { - const [state, setState] = useState({ - listing: [], - rawListing: [], - disabledMap: {}, - enableDebug: false, - message: '' - }); - return
This is not implemented yet
; } diff --git a/src/main/webui/src/app/components/content/HostedView.jsx b/src/main/webui/src/app/components/content/HostedView.jsx index 0a99ce4..f9588c2 100644 --- a/src/main/webui/src/app/components/content/HostedView.jsx +++ b/src/main/webui/src/app/components/content/HostedView.jsx @@ -14,22 +14,8 @@ * limitations under the License. */ -import React, {useEffect, useState} from 'react'; -import {useParams} from 'react-router-dom'; -import {PropTypes} from 'prop-types'; -import {StoreViewControlPanel as ControlPanel} from './StoreControlPanels.jsx'; -import {DisableTimeoutHint} from './Hints.jsx'; -// import ViewJsonDebugger from './Debugger.jsx'; -import {Utils} from '../CompUtils.js'; -import {Filters} from '../Filters.js'; -import {TimeUtils} from '../../TimeUtils.js'; -import {jsonGet} from '../../RestClient.js'; +import React from 'react'; export default function HostedView() { - const [state, setState] = useState({ - store: {}, - raw: {}, - message: '' - }); return
This is not implemented yet!
; } diff --git a/src/main/webui/src/app/components/content/RemoteEdit.jsx b/src/main/webui/src/app/components/content/RemoteEdit.jsx index f1c4ea1..6161ada 100644 --- a/src/main/webui/src/app/components/content/RemoteEdit.jsx +++ b/src/main/webui/src/app/components/content/RemoteEdit.jsx @@ -14,12 +14,11 @@ * limitations under the License. */ -/* eslint-disable max-lines */ import React, {useState, useEffect} from 'react'; import {useLocation, useNavigate, useParams} from 'react-router-dom'; import {PropTypes} from 'prop-types'; -import {StoreEditControlPanel as EditControlPanel} from './StoreControlPanels.jsx'; -import {DisableTimeoutHint, DurationHint, PrefetchHint, Hint} from './Hints.jsx'; +import {StoreEditControlPanel as EditControlPanel} from './common/StoreControlPanels.jsx'; +import {DisableTimeoutHint, DurationHint, PrefetchHint, Hint} from './common/Hints.jsx'; // import ViewJsonDebugger from './Debugger.jsx'; import {Utils} from '../CompUtils.js'; // import Filters from '../Filters.js'; diff --git a/src/main/webui/src/app/components/content/RemoteList.jsx b/src/main/webui/src/app/components/content/RemoteList.jsx index f1bb9e8..c583f01 100644 --- a/src/main/webui/src/app/components/content/RemoteList.jsx +++ b/src/main/webui/src/app/components/content/RemoteList.jsx @@ -15,11 +15,11 @@ */ import React, {useEffect, useState} from 'react'; -import {ListJsonDebugger} from './Debugger.jsx'; -import ListControl from "./ListControl.jsx"; +import {ListJsonDebugger} from './common/Debugger.jsx'; +import ListControl from "./common/ListControl.jsx"; import {remoteOptionLegend as options} from "../ComponentConstants.js"; import {Utils} from '../CompUtils.js'; -import {StoreListingWidget} from './CommonPageWidget.jsx'; +import {StoreListingWidget} from './common/StoreListingWidget.jsx'; import {jsonRest} from '../../RestClient.js'; const init = (state, setState) => { diff --git a/src/main/webui/src/app/components/content/RemoteView.jsx b/src/main/webui/src/app/components/content/RemoteView.jsx index 68f6139..864f297 100644 --- a/src/main/webui/src/app/components/content/RemoteView.jsx +++ b/src/main/webui/src/app/components/content/RemoteView.jsx @@ -17,8 +17,8 @@ import React, {useState, useEffect} from 'react'; import {useParams} from 'react-router-dom'; import {PropTypes} from 'prop-types'; -import {StoreViewControlPanel as ControlPanel} from './StoreControlPanels.jsx'; -import {DisableTimeoutHint, PrefetchHint, Hint, PasswordMask} from './Hints.jsx'; +import {StoreViewControlPanel as ControlPanel} from './common/StoreControlPanels.jsx'; +import {DisableTimeoutHint, PrefetchHint, Hint, PasswordMask} from './common/Hints.jsx'; // import ViewJsonDebugger from './Debugger.jsx'; import {Utils} from '../CompUtils.js'; import {Filters} from '../Filters.js'; @@ -52,8 +52,8 @@ const init = (pkgType, storeName, setState) => { store: newStore }); }else{ - response.text().then(data=>{ - Utils.logMessage(`Failed to get store data. Error reason: ${response.status}->${response.statusText}`); + response.text().then(data => { + Utils.logMessage(`Failed to get store data. Error reason: ${response.status}->${data}`); }); } }; @@ -68,12 +68,6 @@ const handlers = { handleEnable: () => { // mock }, - // handleEdit: () => { - // navigate(`/remote/${pkgType}/edit/${storeName}`); - // }, - handleCreate: () => { - // mock - }, handleRemove: () => { // mock } diff --git a/src/main/webui/src/app/components/content/CommonPageWidget.jsx b/src/main/webui/src/app/components/content/common/CommonPageWidget.jsx similarity index 91% rename from src/main/webui/src/app/components/content/CommonPageWidget.jsx rename to src/main/webui/src/app/components/content/common/CommonPageWidget.jsx index e2dcd3a..313f311 100644 --- a/src/main/webui/src/app/components/content/CommonPageWidget.jsx +++ b/src/main/webui/src/app/components/content/common/CommonPageWidget.jsx @@ -17,7 +17,7 @@ import React, {Fragment} from 'react'; import {Link} from 'react-router-dom'; import {PropTypes} from 'prop-types'; -import {Utils} from '../CompUtils.js'; +import {Utils} from '../../CompUtils.js'; const LocalURLSection = ({storeKey}) =>
{' '} @@ -54,15 +54,15 @@ StoreNameSection.propTypes = { }; const StoreListingWidget = ({StoreList, DisMap, StoreType}) => { - let listing = StoreList; - let disMap = DisMap; + const listing = StoreList; + const disMap = DisMap; if(listing && listing.length >0){ return (
{ listing.map(store => { - let storeClass = Utils.isDisabled(store.key, disMap)? "disabled-store":"enabled-store"; + const storeClass = Utils.isDisabled(store.key, disMap)? "disabled-store":"enabled-store"; return (
@@ -98,5 +98,7 @@ StoreListingWidget.propTypes = { StoreType: PropTypes.string }; - -export {LocalURLSection, CapabilitiesSection, StoreNameSection, StoreListingWidget}; +export {LocalURLSection, + CapabilitiesSection, + StoreNameSection, + StoreListingWidget}; diff --git a/src/main/webui/src/app/components/content/CommonPageWidget.test.js b/src/main/webui/src/app/components/content/common/CommonPageWidget.test.js similarity index 72% rename from src/main/webui/src/app/components/content/CommonPageWidget.test.js rename to src/main/webui/src/app/components/content/common/CommonPageWidget.test.js index 0b33d2b..dc508da 100644 --- a/src/main/webui/src/app/components/content/CommonPageWidget.test.js +++ b/src/main/webui/src/app/components/content/common/CommonPageWidget.test.js @@ -15,13 +15,11 @@ */ import React from "react"; +import {MemoryRouter} from 'react-router-dom'; import {render, screen, cleanup} from '@testing-library/react'; import '@testing-library/jest-dom'; -import {LocalURLSection, - CapabilitiesSection} from "./CommonPageWidget.jsx"; -import {hostedOptionLegend} from '../ComponentConstants.js'; - -// const mockData = {}; +import {LocalURLSection, CapabilitiesSection, StoreNameSection} from "./CommonPageWidget.jsx"; +import {hostedOptionLegend} from '../../ComponentConstants.js'; afterEach(() => { cleanup(); @@ -43,4 +41,14 @@ describe('CommonPageWidget tests', () => { expect(screen.getByText(/\s*R\s*/u)).toBeInTheDocument(); expect(screen.getByText(/\s*D\s*/u)).toBeInTheDocument(); }); + + it("StoreNameSection", ()=>{ + // As is in , needs to use a Router to wrap it + render( + + ); + expect(screen.getByText(/maven-central/u)).toBeInTheDocument(); + }); }); diff --git a/src/main/webui/src/app/components/content/Debugger.jsx b/src/main/webui/src/app/components/content/common/Debugger.jsx similarity index 100% rename from src/main/webui/src/app/components/content/Debugger.jsx rename to src/main/webui/src/app/components/content/common/Debugger.jsx diff --git a/src/main/webui/src/app/components/content/Hints.jsx b/src/main/webui/src/app/components/content/common/Hints.jsx similarity index 100% rename from src/main/webui/src/app/components/content/Hints.jsx rename to src/main/webui/src/app/components/content/common/Hints.jsx diff --git a/src/main/webui/src/app/components/content/ListControl.jsx b/src/main/webui/src/app/components/content/common/ListControl.jsx similarity index 100% rename from src/main/webui/src/app/components/content/ListControl.jsx rename to src/main/webui/src/app/components/content/common/ListControl.jsx diff --git a/src/main/webui/src/app/components/content/common/PackageTypeSelect.jsx b/src/main/webui/src/app/components/content/common/PackageTypeSelect.jsx new file mode 100644 index 0000000..903eb91 --- /dev/null +++ b/src/main/webui/src/app/components/content/common/PackageTypeSelect.jsx @@ -0,0 +1,57 @@ +/** + * Copyright (C) 2023 Red Hat, Inc. (https://github.com/Commonjava/indy-ui-service) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React, {useState, useEffect} from 'react'; +import {PropTypes} from 'prop-types'; +import {jsonRest} from '../../RestClient.js'; + +const PackageTypeSelect = ({pkgType,vauleChangeHandler}) =>{ + const [state, setState] = useState({ + pkgTypes: [] + }); + + (function() { + const typeUrl = '/api/stats/package-type/keys'; + useEffect(()=>{ + const fetchPkgTypes = async () =>{ + const response = await jsonRest.get(typeUrl); + if (response.ok){ + const pkgTypes = await response.json(); + setState({pkgTypes}); + } + }; + fetchPkgTypes(); + }, []); + }()); + + return + + ; +}; + +PackageTypeSelect.propTypes = { + pkgType: PropTypes.strings, + vauleChangeHandler: PropTypes.func +}; diff --git a/src/main/webui/src/app/components/content/StoreControlPanels.jsx b/src/main/webui/src/app/components/content/common/StoreControlPanels.jsx similarity index 94% rename from src/main/webui/src/app/components/content/StoreControlPanels.jsx rename to src/main/webui/src/app/components/content/common/StoreControlPanels.jsx index 9ad221a..74acd0d 100644 --- a/src/main/webui/src/app/components/content/StoreControlPanels.jsx +++ b/src/main/webui/src/app/components/content/common/StoreControlPanels.jsx @@ -17,8 +17,8 @@ import React from 'react'; import {useNavigate} from 'react-router-dom'; import {PropTypes} from 'prop-types'; -import {Utils} from '../CompUtils'; -import {http} from '../../RestClient'; +import {Utils} from '../../CompUtils'; +import {http} from '../../../RestClient'; const StoreEditControlPanel = ({handleSave, handleCancel, handleRemove}) =>
{' '} @@ -71,9 +71,6 @@ const StoreViewControlPanel = function({enabled, storeObj, handleDisable, handle StoreViewControlPanel.propTypes={ enabled: PropTypes.bool, storeObj: PropTypes.object, - // storeType: PropTypes.string, - // pkgType: PropTypes.string, - // storeName: PropTypes.string, handleDisable: PropTypes.func, handleEnable: PropTypes.func }; diff --git a/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx b/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx new file mode 100644 index 0000000..668a728 --- /dev/null +++ b/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx @@ -0,0 +1,65 @@ +/** + * Copyright (C) 2023 Red Hat, Inc. (https://github.com/Commonjava/indy-ui-service) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React, {Fragment} from 'react'; +import {PropTypes} from 'prop-types'; +import {Utils} from '../../CompUtils.js'; +import {LocalURLSection,StoreNameSection,CapabilitiesSection} from './CommonPageWidget.jsx'; + +export const StoreListingWidget = ({StoreList, DisMap, StoreType}) => { + const listing = StoreList; + const disMap = DisMap; + if(listing && listing.length >0){ + return ( +
+
+ { + listing.map(store => { + const storeClass = Utils.isDisabled(store.key, disMap)? "disabled-store":"enabled-store"; + return ( +
+ +
+
+ + { + StoreType === "remote" &&
+ + {store.url} +
+ } +
+
+ +
+
{store.description}
+
+
+ ); + }) + } +
+
+ ); + } + return ; +}; + +StoreListingWidget.propTypes = { + StoreList: PropTypes.array, + DisMap: PropTypes.object, + StoreType: PropTypes.string +}; diff --git a/src/main/webui/src/app/components/nav/NavFooter.jsx b/src/main/webui/src/app/components/nav/NavFooter.jsx index 281c64b..05a6cf1 100644 --- a/src/main/webui/src/app/components/nav/NavFooter.jsx +++ b/src/main/webui/src/app/components/nav/NavFooter.jsx @@ -33,7 +33,7 @@ export default function NavFooter() { }); }else{ response.text().then(data => { - Utils.logMessage(`Failed to version info. Error reason: ${response.status}->${response.statusText}`); + Utils.logMessage(`Failed to version info. Error reason: ${response.status}->${data}`); }); } }; diff --git a/src/main/webui/src/app/components/nav/NavHeader.jsx b/src/main/webui/src/app/components/nav/NavHeader.jsx index 09e5d91..f8ec5ff 100644 --- a/src/main/webui/src/app/components/nav/NavHeader.jsx +++ b/src/main/webui/src/app/components/nav/NavHeader.jsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import React, {useState} from 'react'; +import React from 'react'; import {Link} from 'react-router-dom'; import Dropdown from 'react-bootstrap/Dropdown'; import Button from 'react-bootstrap/Button'; @@ -26,14 +26,12 @@ const username = "mock"; // eslint-disable-next-line max-lines-per-function export default function IndyNavHeader(){ - const [isOpen, setOpen] = useState(false); - const toggle = () => setOpen(!isOpen); // TODO: addons will be render based on the backend addons response, this is a mock; - const addons=[ - AutoProx Calculator, - AutoProx Rules, - Store Changelogs - ]; + // const addons=[ + // AutoProx Calculator, + // AutoProx Rules, + // Store Changelogs + // ]; return (