From 16f18d6dca870baca1d2874e249a46e6a6334157 Mon Sep 17 00:00:00 2001 From: Gang Li Date: Wed, 15 Nov 2023 17:13:29 +0800 Subject: [PATCH] Re-organize all utils into /utils folder --- .../webui/src/app/components/ComponentConstants.js | 5 +---- .../webui/src/app/components/content/RemoteEdit.jsx | 12 +++++------- .../webui/src/app/components/content/RemoteList.jsx | 4 ++-- .../webui/src/app/components/content/RemoteView.jsx | 8 ++++---- .../components/content/common/CommonPageWidget.jsx | 4 ++-- .../components/content/common/PackageTypeSelect.jsx | 2 +- .../components/content/common/StoreControlPanels.jsx | 4 ++-- .../components/content/common/StoreListingWidget.jsx | 2 +- src/main/webui/src/app/components/nav/NavFooter.jsx | 4 ++-- .../{components/CompUtils.js => utils/AppUtils.js} | 0 .../webui/src/app/{components => utils}/Filters.js | 0 src/main/webui/src/app/{ => utils}/RestClient.js | 0 src/main/webui/src/app/{ => utils}/TimeUtils.js | 0 .../webui/src/content-browse/DirectoryListing.jsx | 2 +- 14 files changed, 21 insertions(+), 26 deletions(-) rename src/main/webui/src/app/{components/CompUtils.js => utils/AppUtils.js} (100%) rename src/main/webui/src/app/{components => utils}/Filters.js (100%) rename src/main/webui/src/app/{ => utils}/RestClient.js (100%) rename src/main/webui/src/app/{ => utils}/TimeUtils.js (100%) diff --git a/src/main/webui/src/app/components/ComponentConstants.js b/src/main/webui/src/app/components/ComponentConstants.js index cfbf6dd..1752ff4 100644 --- a/src/main/webui/src/app/components/ComponentConstants.js +++ b/src/main/webui/src/app/components/ComponentConstants.js @@ -26,8 +26,5 @@ const hostedOptionLegend = [ {icon: 'D', title: 'Deployment allowed'} ]; -// TODO: this should be fetched from backend -const PACKAGE_TYPES = ["maven", "generic","npm"]; - -export {remoteOptionLegend, hostedOptionLegend, PACKAGE_TYPES}; +export {remoteOptionLegend, hostedOptionLegend}; diff --git a/src/main/webui/src/app/components/content/RemoteEdit.jsx b/src/main/webui/src/app/components/content/RemoteEdit.jsx index 6161ada..e959ef2 100644 --- a/src/main/webui/src/app/components/content/RemoteEdit.jsx +++ b/src/main/webui/src/app/components/content/RemoteEdit.jsx @@ -20,11 +20,9 @@ import {PropTypes} from 'prop-types'; 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'; -import {TimeUtils} from '../../TimeUtils.js'; -import {PACKAGE_TYPES} from '../ComponentConstants.js'; -import {jsonRest} from '../../RestClient.js'; +import {Utils} from '../../utils/AppUtils.js'; +import {TimeUtils} from '../../utils/TimeUtils.js'; +import {jsonRest} from '../../utils/RestClient.js'; const init = (pkgType, storeName, setState) => { const getUrl = `/api/admin/stores/${pkgType}/remote/${storeName}`; @@ -121,8 +119,8 @@ export default function RemoteEdit() { // Utils.logMessage(mode); let storeView = state.storeView; // let store = state.store; - // TODO this package types should be fetched from backend - let pkgTypes = PACKAGE_TYPES; + // TODO: this package types should be fetched from backend + let pkgTypes = ["maven", "generic-http", "npm"]; const handleCheckChange = (event, field) => { if (event.target.checked) { diff --git a/src/main/webui/src/app/components/content/RemoteList.jsx b/src/main/webui/src/app/components/content/RemoteList.jsx index c583f01..66e0b5f 100644 --- a/src/main/webui/src/app/components/content/RemoteList.jsx +++ b/src/main/webui/src/app/components/content/RemoteList.jsx @@ -18,9 +18,9 @@ import React, {useEffect, useState} from 'react'; 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 './common/StoreListingWidget.jsx'; -import {jsonRest} from '../../RestClient.js'; +import {Utils} from '../../utils/AppUtils.js'; +import {jsonRest} from '../../utils/RestClient.js'; const init = (state, setState) => { useEffect(()=>{ diff --git a/src/main/webui/src/app/components/content/RemoteView.jsx b/src/main/webui/src/app/components/content/RemoteView.jsx index 864f297..c2824d2 100644 --- a/src/main/webui/src/app/components/content/RemoteView.jsx +++ b/src/main/webui/src/app/components/content/RemoteView.jsx @@ -20,10 +20,10 @@ import {PropTypes} from 'prop-types'; 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'; -import {TimeUtils} from '../../TimeUtils.js'; -import {jsonRest} from '../../RestClient.js'; +import {Filters} from '../../utils/Filters.js'; +import {Utils} from '../../utils/AppUtils.js'; +import {TimeUtils} from '../../utils/TimeUtils.js'; +import {jsonRest} from '../../utils/RestClient.js'; const init = (pkgType, storeName, setState) => { const storeUrl = `/api/admin/stores/${pkgType}/remote/${storeName}`; diff --git a/src/main/webui/src/app/components/content/common/CommonPageWidget.jsx b/src/main/webui/src/app/components/content/common/CommonPageWidget.jsx index 313f311..515049c 100644 --- a/src/main/webui/src/app/components/content/common/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 '../../../utils/AppUtils.js'; const LocalURLSection = ({storeKey}) =>
{' '} @@ -28,7 +28,7 @@ LocalURLSection.propTypes = { storeKey: PropTypes.string }; -// For options, see CompUtils.remoteOptions|hostedOptions +// For options, see AppUtils.remoteOptions|hostedOptions const CapabilitiesSection = ({options}) =>
{' '} { diff --git a/src/main/webui/src/app/components/content/common/PackageTypeSelect.jsx b/src/main/webui/src/app/components/content/common/PackageTypeSelect.jsx index df29da9..29227d7 100644 --- a/src/main/webui/src/app/components/content/common/PackageTypeSelect.jsx +++ b/src/main/webui/src/app/components/content/common/PackageTypeSelect.jsx @@ -16,7 +16,7 @@ import React, {useState, useEffect} from 'react'; import {PropTypes} from 'prop-types'; -import {jsonRest} from '../../../RestClient.js'; +import {jsonRest} from '../../../utils/RestClient.js'; export const PackageTypeSelect = ({pkgType,vauleChangeHandler}) =>{ const [state, setState] = useState({ diff --git a/src/main/webui/src/app/components/content/common/StoreControlPanels.jsx b/src/main/webui/src/app/components/content/common/StoreControlPanels.jsx index 74acd0d..cc369c0 100644 --- a/src/main/webui/src/app/components/content/common/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 '../../../utils/AppUtils'; +import {http} from '../../../utils/RestClient'; const StoreEditControlPanel = ({handleSave, handleCancel, handleRemove}) =>
{' '} diff --git a/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx b/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx index 668a728..da2fc21 100644 --- a/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx +++ b/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx @@ -16,7 +16,7 @@ import React, {Fragment} from 'react'; import {PropTypes} from 'prop-types'; -import {Utils} from '../../CompUtils.js'; +import {Utils} from '../../../utils/AppUtils.js'; import {LocalURLSection,StoreNameSection,CapabilitiesSection} from './CommonPageWidget.jsx'; export const StoreListingWidget = ({StoreList, DisMap, StoreType}) => { diff --git a/src/main/webui/src/app/components/nav/NavFooter.jsx b/src/main/webui/src/app/components/nav/NavFooter.jsx index 05a6cf1..3171484 100644 --- a/src/main/webui/src/app/components/nav/NavFooter.jsx +++ b/src/main/webui/src/app/components/nav/NavFooter.jsx @@ -15,8 +15,8 @@ */ import React, {useEffect, useState} from 'react'; -import {jsonRest} from '../../RestClient'; -import {Utils} from '../CompUtils'; +import {jsonRest} from '../../utils/RestClient'; +import {Utils} from '../../utils/AppUtils'; export default function NavFooter() { const [state, setState] = useState({stats: {}}); diff --git a/src/main/webui/src/app/components/CompUtils.js b/src/main/webui/src/app/utils/AppUtils.js similarity index 100% rename from src/main/webui/src/app/components/CompUtils.js rename to src/main/webui/src/app/utils/AppUtils.js diff --git a/src/main/webui/src/app/components/Filters.js b/src/main/webui/src/app/utils/Filters.js similarity index 100% rename from src/main/webui/src/app/components/Filters.js rename to src/main/webui/src/app/utils/Filters.js diff --git a/src/main/webui/src/app/RestClient.js b/src/main/webui/src/app/utils/RestClient.js similarity index 100% rename from src/main/webui/src/app/RestClient.js rename to src/main/webui/src/app/utils/RestClient.js diff --git a/src/main/webui/src/app/TimeUtils.js b/src/main/webui/src/app/utils/TimeUtils.js similarity index 100% rename from src/main/webui/src/app/TimeUtils.js rename to src/main/webui/src/app/utils/TimeUtils.js diff --git a/src/main/webui/src/content-browse/DirectoryListing.jsx b/src/main/webui/src/content-browse/DirectoryListing.jsx index 0114b5e..2fff3b4 100644 --- a/src/main/webui/src/content-browse/DirectoryListing.jsx +++ b/src/main/webui/src/content-browse/DirectoryListing.jsx @@ -17,7 +17,7 @@ import React, {useState, useEffect} from 'react'; import {PropTypes} from 'prop-types'; import {styles} from './style.js'; -import {jsonRest} from '../app/RestClient.js'; +import {jsonRest} from '../app/utils/RestClient.js'; const replaceUrl = url =>{ if (url.includes("api/browse")){