diff --git a/.github/workflows/merge-build.yml b/.github/workflows/merge-build.yml index c1d00a7..e76b595 100644 --- a/.github/workflows/merge-build.yml +++ b/.github/workflows/merge-build.yml @@ -23,7 +23,7 @@ on: [push] jobs: publish-snapshot: - name: publish to oss sonatype & push image + name: Build & push image runs-on: ubuntu-latest permissions: contents: read @@ -43,18 +43,17 @@ jobs: - name: maven-settings-xml-action uses: whelk-io/maven-settings-xml-action@v14 - if: ${{ github.event.repository.fork == false }} with: repositories: '[{ "id": "sonatype", "url": "https://oss.sonatype.org/content/repositories/snapshots/", "releases": {"enabled": "false"}, "snapshots": {"enabled": "true" }}]' - servers: '[{ "id": "sonatype", "username": "${{ secrets.SONATYPE_BOT_USERNAME}}", "password": "${{ secrets.SONATYPE_BOT_TOKEN}}" }]' - name: "Maven Verify" if: ${{ github.event.repository.fork == true }} run: mvn -B -e verify - - name: "Maven Build & Deploy Snapshot to Sonatype OSSRH" + # For service app we don't need to push it to sonatype + - name: "Maven Build" if: ${{ github.event.repository.fork == false }} - run: mvn -B -e clean deploy -DskipTests -DaltDeploymentRepository=sonatype::default::https://oss.sonatype.org/content/repositories/snapshots/ + run: mvn -B -e clean install -DskipTests - name: Checkout tools repo uses: actions/checkout@v4 diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 63ef93e..bddaab0 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -44,4 +44,6 @@ jobs: repositories: '[{ "id": "sonatype", "url": "https://oss.sonatype.org/content/repositories/snapshots/", "releases": {"enabled": "false"}, "snapshots": {"enabled": "true" }}]' - name: Build with Maven - run: mvn -B -e verify + run: | + sed -i 's/build: "npm run build-no-test"/build: "npm run build"/g' ./src/main/resources/application.yaml && \ + mvn -B -e verify diff --git a/src/main/java/org/commonjava/indy/service/ui/models/auth/UserInfo.java b/src/main/java/org/commonjava/indy/service/ui/models/auth/UserInfo.java index 93f8436..d8b299c 100644 --- a/src/main/java/org/commonjava/indy/service/ui/models/auth/UserInfo.java +++ b/src/main/java/org/commonjava/indy/service/ui/models/auth/UserInfo.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2024 Red Hat, Inc. + * 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. diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index a60e9f0..c28279d 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -100,6 +100,7 @@ quarkus: install-env: strict-ssl: false install: "config set strict-ssl false && npm ci" + build: "run build-no-test" # These REST APIs are not needed to show in rest docs mp: diff --git a/src/main/webui/nodemon.js b/src/main/webui/nodemon.js index fe16291..9808ea1 100644 --- a/src/main/webui/nodemon.js +++ b/src/main/webui/nodemon.js @@ -1,3 +1,18 @@ +/** + * 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. + */ { "watch": ["src/server/"] } diff --git a/src/main/webui/package.json b/src/main/webui/package.json index 82feadc..2077dac 100644 --- a/src/main/webui/package.json +++ b/src/main/webui/package.json @@ -65,6 +65,7 @@ "scripts": { "build-dev": "npm run clean && npm run compile-dev && npm run lint && npm run test && npm run deploy && cp ./src/content-browse/html/* ./dist/content-browse/", "build": "npm run clean && npm run compile && npm run test && npm run lint && npm run deploy && cp ./src/content-browse/html/* ./dist/content-browse/", + "build-no-test": "npm run clean && npm run compile && npm run deploy && cp ./src/content-browse/html/* ./dist/content-browse/", "clean": "rm -rf ./dist/*", "compile-dev": "NODE_ENV=development webpack --config ./webpack.config.js && webpack --config ./webpack-content-browse.dev.config.js", "compile": "NODE_ENV=production webpack --config ./webpack.config-prod.js && webpack --config ./webpack-content-browse.prod.config.js", diff --git a/src/main/webui/setupTests.js b/src/main/webui/setupTests.js index 3f4d094..300e791 100644 --- a/src/main/webui/setupTests.js +++ b/src/main/webui/setupTests.js @@ -1,3 +1,18 @@ +/** + * 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 fetchMock from "fetch-mock"; fetchMock.restore(); 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 45c20e7..a4235b1 100644 --- a/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx +++ b/src/main/webui/src/app/components/content/common/StoreListingWidget.jsx @@ -1,5 +1,5 @@ /** - * Copyright (C) 2024 Red Hat, Inc. (https://github.com/Commonjava/indy-ui-service) + * 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import React, {Fragment, useState} from 'react'; import {Link} from 'react-router-dom'; import {PropTypes} from 'prop-types'; @@ -94,16 +93,15 @@ StoreNameSection.propTypes = { storeClass: PropTypes.string }; -const StoreListingWidget = ({storeList, disableMap, storeType}) => { +const StoreListingWidget = ({storeList, storeType}) => { const listing = storeList; - const disMap = disableMap; if(listing && listing.length >0){ return (
{ listing.map(store => { - const storeClass = Utils.isDisabled(store.key, disMap)? "disabled-store":"enabled-store"; + const storeClass = store.disabled? "disabled-store":"enabled-store"; return (
@@ -137,7 +135,6 @@ const StoreListingWidget = ({storeList, disableMap, storeType}) => { StoreListingWidget.propTypes = { storeList: PropTypes.array, - disableMap: PropTypes.object, storeType: PropTypes.string }; diff --git a/src/main/webui/src/app/components/content/common/StoreListingWidget.test.jsx b/src/main/webui/src/app/components/content/common/StoreListingWidget.test.jsx index 8fae726..baadff6 100644 --- a/src/main/webui/src/app/components/content/common/StoreListingWidget.test.jsx +++ b/src/main/webui/src/app/components/content/common/StoreListingWidget.test.jsx @@ -37,9 +37,8 @@ describe('StoreListingWidget tests', () => { url: "https://maven.repository.redhat.com/ga/", description: "Red Hat maven repository"}, ]; - const mockDisableMap = {}; render( - + ); // Testing LocalURLSection diff --git a/src/main/webui/src/app/components/content/group/GroupEdit.jsx b/src/main/webui/src/app/components/content/group/GroupEdit.jsx index 2547ef8..4e7aba1 100644 --- a/src/main/webui/src/app/components/content/group/GroupEdit.jsx +++ b/src/main/webui/src/app/components/content/group/GroupEdit.jsx @@ -1,5 +1,5 @@ /** - * Copyright (C) 2024 Red Hat, Inc. (https://github.com/Commonjava/indy-ui-service) + * 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import React, {useState, useEffect} from 'react'; import {useLocation, useParams} from 'react-router-dom'; import {useForm} from 'react-hook-form'; @@ -27,7 +26,7 @@ import {Utils} from '#utils/AppUtils.js'; import {TimeUtils} from '#utils/TimeUtils.js'; import {IndyRest} from '#utils/RestClient.js'; -const {statsRes, storeRes, disableRes} = IndyRest; +const {storeRes, storeQueryRes, disableRes} = IndyRest; const EditConstituents = ({store, currentAvailable}) => { const [state, setState] = useState(false); @@ -163,10 +162,11 @@ export default function GroupEdit() { const path = location.pathname; const mode = path.match(/.*\/new$/u) ? 'new' : 'edit'; useEffect(() => { + const pkgType = mode === "edit" ? packageType : "all"; const fetchAvailable = async () => { setAvaiLoading(true); // get available Store data - const availableRes = await statsRes.getAllEndpoints(); + const availableRes = await storeQueryRes.getEndpoints(pkgType); let allAvailable = new Set(); if (availableRes.success) { let availableResult = availableRes.result.items; @@ -174,7 +174,7 @@ export default function GroupEdit() { allAvailable.add(item.packageType + ':' + item.type + ':' + item.name); }); } else { - Utils.logMessage(`Getting available constituents failed! Error reason: ${statsRes.error.message}`); + Utils.logMessage(`Getting available constituents failed! Error reason: ${availableRes.error.message}`); } setAvaiLoading(false); return allAvailable; diff --git a/src/main/webui/src/app/components/content/group/GroupEdit.test.jsx b/src/main/webui/src/app/components/content/group/GroupEdit.test.jsx index 9c21f19..ad9354f 100644 --- a/src/main/webui/src/app/components/content/group/GroupEdit.test.jsx +++ b/src/main/webui/src/app/components/content/group/GroupEdit.test.jsx @@ -1,3 +1,18 @@ +/** + * 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. + */ /* eslint-disable camelcase */ /** * Copyright (C) 2024 Red Hat, Inc. (https://github.com/Commonjava/indy-ui-service) @@ -86,7 +101,7 @@ describe('GroupEdit tests', () => { } ] }; - fetchMock.mock(`/api/stats/all-endpoints`, {status: 200, body: JSON.stringify(mockAvailable)}); + fetchMock.mock(`/api/admin/stores/query/endpoints/all`, {status: 200, body: JSON.stringify(mockAvailable)}); render( } /> @@ -181,7 +196,7 @@ describe('GroupEdit tests', () => { expiration: "2030-02-22T17:00:00.000Z" }; fetchMock.mock(`${STORE_API_BASE_URL}/maven/group/local-deployment`, {status: 200, body: JSON.stringify(mockGroupStore)}); - fetchMock.mock(`/api/stats/all-endpoints`, {status: 200, body: JSON.stringify(mockAvailable)}); + fetchMock.mock(`/api/admin/stores/query/endpoints/maven`, {status: 200, body: JSON.stringify(mockAvailable)}); fetchMock.mock("/api/admin/schedule/store/maven/group/local-deployment/disable-timeout", {status: 200, body: JSON.stringify(mockDisableTimeout)}); render( diff --git a/src/main/webui/src/app/components/content/group/GroupList.jsx b/src/main/webui/src/app/components/content/group/GroupList.jsx index ba47765..da93371 100644 --- a/src/main/webui/src/app/components/content/group/GroupList.jsx +++ b/src/main/webui/src/app/components/content/group/GroupList.jsx @@ -1,5 +1,5 @@ /** - * Copyright (C) 2024 Red Hat, Inc. (https://github.com/Commonjava/indy-ui-service) + * 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import React, {useEffect, useState} from "react"; import {useParams} from "react-router-dom"; import {ListJsonDebugger} from "../common/Debugger.jsx"; @@ -24,7 +23,7 @@ import {LoadingSpiner} from "../common/LoadingSpiner.jsx"; import {Utils} from "#utils/AppUtils.js"; import {IndyRest} from "#utils/RestClient.js"; -const {storeRes, disableRes} = IndyRest; +const {storeRes} = IndyRest; const handlers = { handleDebug: (event, setState) => { @@ -51,7 +50,6 @@ export default function GroupList() { const [state, setState] = useState({ rawList: [], listing: [], - disabledMap: {}, enableDebug: false, message: "", }); @@ -62,22 +60,13 @@ export default function GroupList() { (async () => { const res = await storeRes.getStores(packageType, "group"); if (res.success) { - const timeoutRes = await disableRes.getAllStoreTimeout(); - let disabledMap = {}; - if (timeoutRes.success) { - const timeoutData = timeoutRes.result; - disabledMap = Utils.setDisableMap(timeoutData); - } else { - Utils.logMessage(`disable timeout get failed in group listing! Error reason: ${timeoutRes.error.message}`,); - } let data = res.result; if (typeof data === "string") { data = JSON.parse(data); } setState({ rawList: data.items, - listing: data.items, - disabledMap, + listing: data.items }); } else { setState({ @@ -106,7 +95,6 @@ export default function GroupList() { {state.listing ? : diff --git a/src/main/webui/src/app/components/content/group/GroupList.test.jsx b/src/main/webui/src/app/components/content/group/GroupList.test.jsx index ba47aa9..df7af46 100644 --- a/src/main/webui/src/app/components/content/group/GroupList.test.jsx +++ b/src/main/webui/src/app/components/content/group/GroupList.test.jsx @@ -1,5 +1,5 @@ /** - * Copyright (C) 2024 Red Hat, Inc. (https://github.com/Commonjava/indy-ui-service) + * 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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import React from "react"; import {MemoryRouter, Route, Routes} from 'react-router-dom'; import {render, screen, cleanup, waitFor} from '@testing-library/react'; diff --git a/src/main/webui/src/app/components/content/hosted/HostedList.jsx b/src/main/webui/src/app/components/content/hosted/HostedList.jsx index 13aee56..7a9ed2e 100644 --- a/src/main/webui/src/app/components/content/hosted/HostedList.jsx +++ b/src/main/webui/src/app/components/content/hosted/HostedList.jsx @@ -24,7 +24,7 @@ import {LoadingSpiner} from "../common/LoadingSpiner.jsx"; import {Utils} from "#utils/AppUtils.js"; import {IndyRest} from "#utils/RestClient.js"; -const {storeRes, disableRes} = IndyRest; +const {storeRes} = IndyRest; const handlers = { handleDebug: (event, setState) => { @@ -51,7 +51,6 @@ export default function HostedList() { const [state, setState] = useState({ rawList: [], listing: [], - disabledMap: {}, enableDebug: false, message: "", }); @@ -62,22 +61,13 @@ export default function HostedList() { (async () => { const res = await storeRes.getStores(packageType, "hosted"); if (res.success) { - const timeoutRes = await disableRes.getAllStoreTimeout(); - let disabledMap = {}; - if (timeoutRes.success) { - const timeoutData = timeoutRes.result; - disabledMap = Utils.setDisableMap(timeoutData); - } else { - Utils.logMessage(`disable timeout get failed in hosted listing! Error reason: ${timeoutRes.error.message}`,); - } let data = res.result; if (typeof data === "string") { data = JSON.parse(data); } setState({ rawList: data.items, - listing: data.items, - disabledMap, + listing: data.items }); } else { setState({ @@ -106,7 +96,6 @@ export default function HostedList() { {state.listing ? : diff --git a/src/main/webui/src/app/components/content/remote/RemoteList.jsx b/src/main/webui/src/app/components/content/remote/RemoteList.jsx index 914a7e9..3b4e860 100644 --- a/src/main/webui/src/app/components/content/remote/RemoteList.jsx +++ b/src/main/webui/src/app/components/content/remote/RemoteList.jsx @@ -24,7 +24,7 @@ import {LoadingSpiner} from "../common/LoadingSpiner.jsx"; import {Utils} from '#utils/AppUtils.js'; import {IndyRest} from '#utils/RestClient.js'; -const {storeRes, disableRes} = IndyRest; +const {storeRes} = IndyRest; const handlers = { handleDebug: (event, setState) => { @@ -51,7 +51,6 @@ export default function RemoteList() { const [state, setState] = useState({ rawList: [], listing: [], - disabledMap: {}, enableDebug: false, message: '' }); @@ -62,22 +61,13 @@ export default function RemoteList() { (async ()=>{ const res = await storeRes.getStores(packageType, "remote"); if (res.success){ - const timeoutRes = await disableRes.getAllStoreTimeout(); - let disabledMap = {}; - if (timeoutRes.success){ - const timeoutData = timeoutRes.result; - disabledMap = Utils.setDisableMap(timeoutData); - }else{ - Utils.logMessage(`disable timeout get failed in remote listing! Error reason: ${timeoutRes.error.message}`); - } let data = res.result; if(typeof data === 'string'){ data = JSON.parse(data); } setState({ rawList: data.items, - listing: data.items, - disabledMap + listing: data.items }); }else{ setState({ @@ -103,7 +93,7 @@ export default function RemoteList() { /> { state.listing? - : + :
No content fetched!
diff --git a/src/main/webui/src/server/app.js b/src/main/webui/src/server/app.js index fc094c8..2a3c7b9 100644 --- a/src/main/webui/src/server/app.js +++ b/src/main/webui/src/server/app.js @@ -1,3 +1,18 @@ +/** + * 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. + */ /* eslint-disable no-console */ import compression from 'compression'; import express from 'express'; diff --git a/src/main/webui/src/server/config/AppConfig.js b/src/main/webui/src/server/config/AppConfig.js index c47087b..0bfb359 100644 --- a/src/main/webui/src/server/config/AppConfig.js +++ b/src/main/webui/src/server/config/AppConfig.js @@ -1,3 +1,18 @@ +/** + * 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. + */ export const Config = { SERVER_PORT: 4000, APP_ROOT: "/#" diff --git a/src/test/java/org/commonjava/indy/service/ui/jaxrs/auth/AuthResourceTest.java b/src/test/java/org/commonjava/indy/service/ui/jaxrs/auth/AuthResourceTest.java index 1248975..c1d83dd 100644 --- a/src/test/java/org/commonjava/indy/service/ui/jaxrs/auth/AuthResourceTest.java +++ b/src/test/java/org/commonjava/indy/service/ui/jaxrs/auth/AuthResourceTest.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2024 Red Hat, Inc. + * 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. diff --git a/src/test/java/org/commonjava/indy/service/ui/jaxrs/auth/AuthTestProfile.java b/src/test/java/org/commonjava/indy/service/ui/jaxrs/auth/AuthTestProfile.java index b886941..bac8a63 100644 --- a/src/test/java/org/commonjava/indy/service/ui/jaxrs/auth/AuthTestProfile.java +++ b/src/test/java/org/commonjava/indy/service/ui/jaxrs/auth/AuthTestProfile.java @@ -1,5 +1,5 @@ /** - * Copyright (C) 2024 Red Hat, Inc. + * 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.