Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kiota powered, in browser, client generation #3082

Merged
merged 10 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
public class ConfigJsUi {

public String contextPath;
public boolean codegenEnabled;

/**
* Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public class UiConfigProperties {
@Info(category = "ui", description = "UI context path", availableSince = "2.1.0.Final")
String uiContextPath;

@Inject
@ConfigProperty(name = "registry.ui.config.uiCodegenEnabled", defaultValue = "false")
@Info(category = "ui", description = "UI codegen enabled", availableSince = "2.4.2.Final")
boolean uiCodegenEnabled;

@Inject
@ConfigProperty(name = "registry.ui.config.apiUrl")
@Info(category = "ui", description = "UI APIs URL", availableSince = "1.3.0.Final")
Expand Down Expand Up @@ -106,6 +111,7 @@ void onConstruct() {
log.debug("============> featureReadOnly " + featureReadOnly);
log.debug("============> featureSettings " + featureSettings);
log.debug("============> uiContextPath " + uiContextPath);
log.debug("============> codegenEnabled " + uiCodegenEnabled);
log.debug("============> apiUrl " + apiUrl);
}

Expand All @@ -125,6 +131,14 @@ public String getUiContextPath() {
return uiContextPath;
}

public boolean getUiCodegenEnabled() {
return uiCodegenEnabled;
}

public String getUi() {
return uiContextPath;
}

public String getApiUrl() {
return apiUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
config.artifacts.url = this.generateApiUrl(request);

config.ui.contextPath = uiConfig.getUiContextPath();
config.ui.codegenEnabled = uiConfig.getUiCodegenEnabled();

config.features.readOnly = uiConfig.isFeatureReadOnly();
config.features.settings = uiConfig.isFeatureSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,11 @@ This section contains a list of the configuration options available for {registr
|`none`
|`2.2.6.Final`
|UI auth type
|`registry.ui.config.uiCodegenEnabled`
|`boolean`
|`false`
|`2.4.2.Final`
|UI codegen enabled
|`registry.ui.config.uiContextPath`
|`string`
|`/ui/`
Expand Down
2 changes: 2 additions & 0 deletions ui/client-gen/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
kiota
11 changes: 11 additions & 0 deletions ui/client-gen/client-gen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { generate } from './dist/main.js';

try {
if (window.kiota === undefined) {
window.kiota = {};
window.kiota.generate = generate;
console.log("Kiota is now available in the window");
}
} catch (e) {
console.warn("Kiota not available");
}
3 changes: 2 additions & 1 deletion ui/config/config-keycloakjs-rbac.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var ApicurioRegistryConfig = {
},
ui: {
contextPath: "/",
navPrefixPath: "/"
navPrefixPath: "/",
codegenEnabled: false
},
auth: {
type: "keycloakjs",
Expand Down
3 changes: 2 additions & 1 deletion ui/config/config-keycloakjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var ApicurioRegistryConfig = {
},
ui: {
contextPath: "/",
navPrefixPath: "/"
navPrefixPath: "/",
codegenEnabled: false
},
auth: {
type: "keycloakjs",
Expand Down
3 changes: 2 additions & 1 deletion ui/config/config-none.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var ApicurioRegistryConfig = {
},
ui: {
contextPath: "/",
navPrefixPath: "/"
navPrefixPath: "/",
codegenEnabled: false
},
auth: {
type: "none"
Expand Down
3 changes: 2 additions & 1 deletion ui/config/config-oidcjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ var ApicurioRegistryConfig = {
},
ui: {
contextPath: "/",
navPrefixPath: "/"
navPrefixPath: "/",
codegenEnabled: false
},
auth: {
type: "oidc",
Expand Down
19 changes: 18 additions & 1 deletion ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"html-webpack-plugin": "^5.3.1",
"imagemin": "^6.0.0",
"mini-css-extract-plugin": "2.6.0",
"node-polyfill-webpack-plugin": "^1.1.4",
"null-loader": "4.0.1",
"postcss": "8.4.12",
"postcss-loader": "6.2.1",
"node-polyfill-webpack-plugin": "^1.1.4",
"prettier": "^1.15.2",
"prop-types": "^15.6.1",
"raw-loader": "4.0.2",
Expand All @@ -54,26 +54,27 @@
"webpack-bundle-analyzer": "4.5.0",
"webpack-cli": "4.10.0",
"webpack-dev-server": "4.7.4",
"webpack-merge": "5.8.0"
"webpack-merge": "5.8.0",
"webpack-shell-plugin-next": "^2.3.1"
},
"dependencies": {
"@apicurio/data-models": "^1.1.26",
"@asyncapi/react-component": "^1.0.0-next.40",
"@patternfly/patternfly": "4.185.1",
"@patternfly/react-core": "4.202.16",
"@patternfly/react-icons": "4.53.16",
"@patternfly/react-styles": "4.64.1",
"@patternfly/react-table": "4.71.16",
"ace-builds": "1.7.1",
"@apicurio/data-models": "^1.1.26",
"axios": "0.21.2",
"keycloak-js": "^19.0.2",
"mobx": "^6.5.0",
"moment": "2.29.4",
"oidc-client-ts": "^2.0.3",
"react": "17.0.2",
"react-ace": "10.1.0",
"react-dom": "17.0.2",
"react-moment": "1.1.2",
"oidc-client-ts": "^2.0.3",
"react-router-dom": "5.2.1",
"redoc": "2.0.0-rc.72",
"styled-components": "^4.2.0",
Expand Down
20 changes: 18 additions & 2 deletions ui/src/app/pages/artifactVersion/artifactVersion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import { ContentTabContent, DocumentationTabContent, InfoTabContent } from "./co
import { ArtifactVersionPageHeader } from "./components/pageheader";
import { UploadVersionForm } from "./components/uploadForm";
import { Link } from "react-router-dom";
import { EditMetaDataModal } from "./components/modals";
import { EditMetaDataModal, GenerateClientModal } from "./components/modals";
import { InvalidContentModal } from "../../components/modals";
import { IfFeature } from "../../components";
import { ArtifactMetaData, ArtifactTypes, ContentTypes, Rule, SearchedVersion } from "../../../models";
import { CreateVersionData, EditableMetaData, Services } from "../../../services";
import { ClientGeneration, CreateVersionData, EditableMetaData, Services } from "../../../services";
import { PleaseWaitModal } from "../../components/modals/pleaseWaitModal";
import { ChangeOwnerModal } from "./components/modals/changeOwnerModal";

Expand All @@ -60,6 +60,7 @@ export interface ArtifactVersionPageState extends PageState {
isUploadModalOpen: boolean;
isDeleteModalOpen: boolean;
isEditModalOpen: boolean;
isGenerateClientModalOpen: boolean;
isChangeOwnerModalOpen: boolean;
isPleaseWaitModalOpen: boolean;
pleaseWaitMessage: string;
Expand Down Expand Up @@ -98,12 +99,14 @@ export class ArtifactVersionPage extends PageComponent<ArtifactVersionPageProps,
<Tab eventKey={0} title="Overview" key="overview" tabContentId="tab-info">
<InfoTabContent artifact={artifact}
isLatest={this.versionParam() === "latest"}
codegenEnabled={Services.getConfigService().uiCodegenEnabled()}
rules={this.rules()}
onEnableRule={this.doEnableRule}
onDisableRule={this.doDisableRule}
onConfigureRule={this.doConfigureRule}
onDownloadArtifact={this.doDownloadArtifact}
onEditMetaData={this.openEditMetaDataModal}
onGenerateClient={this.openGenerateClientModal}
onChangeOwner={this.openChangeOwnerModal}
/>
</Tab>,
Expand Down Expand Up @@ -195,6 +198,10 @@ export class ArtifactVersionPage extends PageComponent<ArtifactVersionPageProps,
onClose={this.onEditModalClose}
onEditMetaData={this.doEditMetaData}
/>
<GenerateClientModal artifactContent={this.state.artifactContent}
onClose={this.onGenerateClientModalClose}
isOpen={this.state.isGenerateClientModalOpen}
/>
<ChangeOwnerModal isOpen={this.state.isChangeOwnerModalOpen}
onClose={this.onChangeOwnerModalClose}
currentOwner={this.state.artifact?.createdBy || ""}
Expand All @@ -218,6 +225,7 @@ export class ArtifactVersionPage extends PageComponent<ArtifactVersionPageProps,
invalidContentError: null,
isDeleteModalOpen: false,
isEditModalOpen: false,
isGenerateClientModalOpen: false,
isChangeOwnerModalOpen: false,
isInvalidContentModalOpen: false,
isPleaseWaitModalOpen: false,
Expand Down Expand Up @@ -461,6 +469,10 @@ export class ArtifactVersionPage extends PageComponent<ArtifactVersionPageProps,
this.setSingleState("isEditModalOpen", true);
};

private openGenerateClientModal = (): void => {
this.setSingleState("isGenerateClientModalOpen", true);
};

private openChangeOwnerModal = (): void => {
this.setSingleState("isChangeOwnerModalOpen", true);
};
Expand All @@ -469,6 +481,10 @@ export class ArtifactVersionPage extends PageComponent<ArtifactVersionPageProps,
this.setSingleState("isEditModalOpen", false);
};

private onGenerateClientModalClose = (): void => {
this.setSingleState("isGenerateClientModalOpen", false);
};

private onChangeOwnerModalClose = (): void => {
this.setSingleState("isChangeOwnerModalOpen", false);
};
Expand Down
Loading