Skip to content

Commit

Permalink
Update java and frontend code (#3)
Browse files Browse the repository at this point in the history
* Use UiPluginDescriptorSupport from ui package

- satisfy linter

* Implement UiPluginDescriptor

* Adjust maven config

* Fix pom.xml and add missing dependencies

* Update dependencies

- reduce list to required deps only
- remove test setup

* Update to use client rendering API

* Move frontend config to root

- update webpack config
- update dependencies

* Adjust javascript tool config

* Adjust build config

- adjust github workflow
- refine .gitignore
- reduce build.sh
- remove obsolete pom_for_bundle.xml

* Fix call for useEffect
  • Loading branch information
ChriFo committed May 8, 2024
1 parent 4d829f5 commit ccf3d8c
Show file tree
Hide file tree
Showing 20 changed files with 1,599 additions and 5,165 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: mvn -B -f pom_for_bundle.xml -PbuildKar clean package -Dmaven.test.skip=true
run: mvn -B -PbuildKar clean package

- name: Determine Artifact Path
run: echo "ARTIFACT_PATH=$(ls target/nexus-oauth2-proxy-plugin-*-bundle.kar)" >> $GITHUB_ENV

- name: Upload Artifact to Workflow
uses: actions/upload-artifact@v3
with:
Expand All @@ -40,14 +40,14 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3

- name: Extract tag name
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
RELEASE_NAME="$TAG_NAME"
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand All @@ -64,12 +64,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: nexus-oauth2-proxy-plugin-java-11.kar

- name: Find KAR file
id: find_kar
run: |
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
.factorypath
.project
.settings
.vscode
bin
node_modules
target
*.versionsBackup
yarn.lock
*.versionsBackup
6 changes: 1 addition & 5 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"

pushd "${DIR}"
# extjs:aggregate-js
mvn -f pom_for_bundle.xml -PbuildKar clean package -Dmaven.test.skip=true
popd
mvn -PbuildKar clean package
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "nexus-oauth2-proxy-plugin",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "webpack --config webpack.config.js",
"build-all": "webpack --config webpack.config.js",
"watch": "webpack --watch --config webpack.config.js"
},
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^6.5.2",
"axios": "^1.6.8",
"react": "^18.3.1"
},
"devDependencies": {
"@babel/core": "^7.24.4",
"@babel/preset-react": "^7.24.1",
"babel-loader": "^9.1.3",
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
}
}
79 changes: 30 additions & 49 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-plugins</artifactId>
<version>3.67.0-03</version>
</parent>

<groupId>com.github.tumbl3w33d</groupId>
<artifactId>nexus-oauth2-proxy-plugin</artifactId>
<version>0.1.1-SNAPSHOT</version>
<name>${project.groupId}:${project.artifactId}</name>
<packaging>bundle</packaging>

<url>https://github.com/tumbl3w33d/nexus-oauth2-proxy-plugin</url>
<description>
Expand All @@ -16,37 +23,37 @@
on their OIDC scopes.
</description>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<nexus.version>3.67.1-01</nexus.version>
<apache-httpclient.version>4.5.14</apache-httpclient.version>
<sonatype-goodies.version>2.3.9</sonatype-goodies.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.nexus.buildsupport</groupId>
<artifactId>extjs-maven-plugin</artifactId>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<namespace>NX.oauth2proxy</namespace>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-plugin-api</artifactId>
<scope>provided</scope>
<version>${nexus.version}</version>
<exclusions>
<!-- To get rid of the error:
Use Import/Export Package directive -split-package:=(merge-first|merge-last|error|first) to get rid
Expand All @@ -59,61 +66,35 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-capability</artifactId>
<scope>provided</scope>
<version>${nexus.version}</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
<version>${apache-httpclient.version}</version>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest</artifactId>
</dependency>
<dependency>
<groupId>org.sonatype.goodies</groupId>
<artifactId>goodies-testsupport</artifactId>
<scope>test</scope>
<version>${sonatype-goodies.version}</version>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-orient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-core</artifactId>
<version>3.2.29</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-orient</artifactId>
<version>${nexus.version}</version>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest</artifactId>
<version>${nexus.version}</version>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-scheduling</artifactId>
<version>${nexus.version}</version>
</dependency>

<!-- UI plugin part -->
<dependency>
<groupId>org.sonatype.nexus.buildsupport</groupId>
<artifactId>extjs-maven-plugin</artifactId>
<version>${nexus.version}</version>
</dependency>
<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rapture</artifactId>
<scope>provided</scope>
<version>${nexus.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down
43 changes: 0 additions & 43 deletions src/frontend/package.json

This file was deleted.

10 changes: 1 addition & 9 deletions src/frontend/src/components/OAuth2ProxyApiTokenComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SectionFooter
} from '@sonatype/nexus-ui-plugin';

function OAuth2ProxyApiTokenComponent() {
export default function OAuth2ProxyApiTokenComponent() {
const [token, setToken] = React.useState('');
const [error, setError] = React.useState(false);

Expand All @@ -31,7 +31,6 @@ function OAuth2ProxyApiTokenComponent() {
return <div>Error fetching user data.</div>;
}


return <Page>
<PageHeader>
<PageTitle icon={faKey} text="OAuth2 Proxy API Token" description="Access your API token for non-interactive access"></PageTitle>
Expand All @@ -46,10 +45,3 @@ function OAuth2ProxyApiTokenComponent() {
</ContentBody>
</Page >
}

if (typeof window !== 'undefined') {
window.ReactComponents = window.ReactComponents || {};
window.ReactComponents.OAuth2ProxyApiTokenComponent = OAuth2ProxyApiTokenComponent;
}

export default OAuth2ProxyApiTokenComponent;
20 changes: 15 additions & 5 deletions src/frontend/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import React from 'react';
import ReactDOM from 'react-dom';
import OAuth2ProxyApiTokenComponent from './components/OAuth2ProxyApiTokenComponent';

ReactDOM.render(
<OAuth2ProxyApiTokenComponent />
);
window.plugins.push({
id: 'nexus-oauth2-proxy-plugin',

features: [{
mode: 'user',
path: '/oauth2proxy-apitoken',
view: OAuth2ProxyApiTokenComponent,
text: 'OAuth2 Proxy API Token',
description: 'Access OAuth2 proxy API token',
iconCls: 'x-fa fa-key',
visibility: {
requiresUser: true
}
}]
});
Loading

0 comments on commit ccf3d8c

Please sign in to comment.