Skip to content

Commit

Permalink
feature behind a flag
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Feb 15, 2023
1 parent 13fb3d8 commit ccb8c8c
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 7 deletions.
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
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
2 changes: 1 addition & 1 deletion ui/package-lock.json

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

1 change: 1 addition & 0 deletions ui/src/app/pages/artifactVersion/artifactVersion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ 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}
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/pages/artifactVersion/components/tabs/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { If } from "../../../../components/common/if";
export interface InfoTabContentProps extends PureComponentProps {
artifact: ArtifactMetaData;
isLatest: boolean;
codegenEnabled: boolean;
rules: Rule[];
onEnableRule: (ruleType: string) => void;
onDisableRule: (ruleType: string) => void;
Expand Down Expand Up @@ -188,7 +189,7 @@ export class InfoTabContent extends PureComponent<InfoTabContentProps, InfoTabCo
title="Download artifact content"
onClick={this.props.onDownloadArtifact}
variant="secondary"><DownloadIcon /> Download</Button>
{((window as any).kiota !== undefined) ?
{((window as any).kiota !== undefined && this.props.codegenEnabled) ?
<Button id="generate-client-action"
data-testid="artifact-btn-gen-client"
isDisabled={this.props.artifact.type !== "OPENAPI"}
Expand Down
10 changes: 9 additions & 1 deletion ui/src/services/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const DEFAULT_CONFIG: ConfigType = {
},
ui: {
contextPath: "/",
navPrefixPath: "/"
navPrefixPath: "/",
codegenEnabled: false
}
};

Expand Down Expand Up @@ -95,6 +96,13 @@ export class ConfigService implements Service {
return this.config.ui.navPrefixPath;
}

public uiCodegenEnabled(): boolean {
if (!this.config.ui || !this.config.ui.codegenEnabled) {
return false;
}
return this.config.ui.codegenEnabled;
}

public features(): FeaturesConfig {
const defaults: FeaturesConfig = {
readOnly: false,
Expand Down
1 change: 1 addition & 0 deletions ui/src/services/config/config.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface ArtifactsConfig {
export interface UiConfig {
contextPath?: string;
navPrefixPath?: string;
codegenEnabled?: boolean;
}

export interface AuthConfig {
Expand Down

0 comments on commit ccb8c8c

Please sign in to comment.