Skip to content

Commit

Permalink
Merge branch 'main' into quarkus-3
Browse files Browse the repository at this point in the history
  • Loading branch information
ligangty committed Mar 4, 2024
2 parents a5179e7 + 103d38e commit 9988f82
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 67 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/merge-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 15 additions & 0 deletions src/main/webui/nodemon.js
Original file line number Diff line number Diff line change
@@ -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/"]
}
1 change: 1 addition & 0 deletions src/main/webui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions src/main/webui/setupTests.js
Original file line number Diff line number Diff line change
@@ -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();
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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';
Expand Down Expand Up @@ -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 (
<div className="content-panel">
<div className="store-listing">
{
listing.map(store => {
const storeClass = Utils.isDisabled(store.key, disMap)? "disabled-store":"enabled-store";
const storeClass = store.disabled? "disabled-store":"enabled-store";
return (
<div key={store.key} className="store-listing-item">
<StoreNameSection store={store} storeClass={storeClass} />
Expand Down Expand Up @@ -137,7 +135,6 @@ const StoreListingWidget = ({storeList, disableMap, storeType}) => {

StoreListingWidget.propTypes = {
storeList: PropTypes.array,
disableMap: PropTypes.object,
storeType: PropTypes.string
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ describe('StoreListingWidget tests', () => {
url: "https://maven.repository.redhat.com/ga/",
description: "Red Hat maven repository"},
];
const mockDisableMap = {};
render(<MemoryRouter>
<StoreListingWidget storeList={mockRemoteStoreList} disableMap={mockDisableMap} storeType="remote"/>
<StoreListingWidget storeList={mockRemoteStoreList} storeType="remote"/>
</MemoryRouter>);

// Testing LocalURLSection
Expand Down
10 changes: 5 additions & 5 deletions src/main/webui/src/app/components/content/group/GroupEdit.jsx
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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';
Expand All @@ -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);
Expand Down Expand Up @@ -163,18 +162,19 @@ 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;
availableResult.forEach(item => {
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;
Expand Down
19 changes: 17 additions & 2 deletions src/main/webui/src/app/components/content/group/GroupEdit.test.jsx
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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(<MemoryRouter initialEntries={["/group/new"]}>
<Routes>
<Route path="/group/new" element={<GroupEdit />} />
Expand Down Expand Up @@ -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(<MemoryRouter initialEntries={["/group/maven/edit/local-deployment"]}>
<Routes>
Expand Down
18 changes: 3 additions & 15 deletions src/main/webui/src/app/components/content/group/GroupList.jsx
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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";
Expand All @@ -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) => {
Expand All @@ -51,7 +50,6 @@ export default function GroupList() {
const [state, setState] = useState({
rawList: [],
listing: [],
disabledMap: {},
enableDebug: false,
message: "",
});
Expand All @@ -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({
Expand Down Expand Up @@ -106,7 +95,6 @@ export default function GroupList() {
{state.listing ?
<StoreListingWidget
storeList={state.listing}
disableMap={state.disabledMap}
storeType="group"
/>
:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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';
Expand Down
15 changes: 2 additions & 13 deletions src/main/webui/src/app/components/content/hosted/HostedList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -51,7 +51,6 @@ export default function HostedList() {
const [state, setState] = useState({
rawList: [],
listing: [],
disabledMap: {},
enableDebug: false,
message: "",
});
Expand All @@ -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({
Expand Down Expand Up @@ -106,7 +96,6 @@ export default function HostedList() {
{state.listing ?
<StoreListingWidget
storeList={state.listing}
disableMap={state.disabledMap}
storeType="hosted"
/>
:
Expand Down
Loading

0 comments on commit 9988f82

Please sign in to comment.