Skip to content

Commit

Permalink
finalizing
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Jan 13, 2023
1 parent 884ceb3 commit de2f913
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ui/client-gen/client-gen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { generate } from './kiota/main.js';
import { generate } from './dist/main.js';

try {
if (window.kiota === undefined) {
Expand Down
6 changes: 0 additions & 6 deletions ui/src/app/pages/artifactVersion/artifactVersion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,6 @@ export class ArtifactVersionPage extends PageComponent<ArtifactVersionPageProps,
this.onEditModalClose();
};

private doGenerateClientData = (data: ClientGeneration): void => {

alert("go on from here???")

};

private doChangeOwner = (newOwner: string): void => {
Services.getGroupsService().updateArtifactOwner(this.groupId(), this.artifactId(), newOwner).then( () => {
if (this.state.artifact) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
FormGroup,
Grid,
GridItem,
Label,
Modal,
TextInput
} from "@patternfly/react-core";
Expand Down Expand Up @@ -61,16 +62,18 @@ export class GenerateClientModal extends PureComponent<GenerateClientModalProps,
}

private downloadLink(): React.ReactElement {
if (this.state.isDownloadLinkVisible || this.state.isErrorVisible) {
console.log(this.state);
if (this.state.isDownloadLinkVisible) {
return <a
key="DownloadLink"
href={this.state.downloadLink}
aria-disabled={!this.state.isDownloadLinkVisible || this.state.isErrorVisible}
download={"client-" + this.state.data.language.toLowerCase() + ".zip"}
onClick={this.onDownloadLinkClick}
>
{this.state.isErrorVisible ? "Error" : "Download"}
</a>
} else if (this.state.isErrorVisible) {
return <Label key="Error">ERROR, please check the console logs for details.</Label>
} else {
return <div key="Placeholder"/>
}
Expand All @@ -85,12 +88,17 @@ export class GenerateClientModal extends PureComponent<GenerateClientModalProps,
onClose={this.props.onClose}
className="generate-client pf-m-redhat-font"
actions={[
<Button key="Generate" variant="primary" data-testid="modal-btn-edit" onClick={this.doGenerate} isDisabled={!this.state.isValid}>Generate</Button>,
<Button key="Generate" variant="primary" data-testid="modal-btn-edit" onClick={this.doGenerate} isDisabled={!this.isGenerateEnabled()}>Generate</Button>,
this.downloadLink()
]}
>
<Form>
<Grid hasGutter md={6}>
<GridItem span={12}>
<Label>[EXPERIMENTAL] This is "in-browser" generation of the client code using&nbsp;<a href="https://github.com/microsoft/kiota">Kiota</a>, please refer to&nbsp;
<a href="https://microsoft.github.io/kiota/get-started/">the official documentation</a>&nbsp;to get started.</Label>
</GridItem>

<GridItem span={12}>
<FormGroup
label="Client Class Name"
Expand Down Expand Up @@ -268,6 +276,10 @@ export class GenerateClientModal extends PureComponent<GenerateClientModalProps,
});
};

private isGenerateEnabled = (): boolean => {
return this.state.isValid && !this.state.isErrorVisible && !this.state.isDownloadLinkVisible;
};

private validate = (): void => {
let isValid: boolean = (
this.state.data.clientClassName !== undefined &&
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 @@ -188,12 +188,13 @@ 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) ?
<Button id="generate-client-action"
data-testid="artifact-btn-gen-client"
isDisabled={this.props.artifact.type !== "OPENAPI"}
title="[EXPERIMENTAL] Generate a client"
onClick={this.props.onGenerateClient}
variant="secondary">Generate Client</Button>
variant="secondary">Generate Client</Button> : <div/>}
</div>
</CardBody>
</Card>
Expand Down
5 changes: 2 additions & 3 deletions ui/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ module.exports = (env, argv) => {
new WebpackShellPluginNext({
onBuildStart:{
scripts: [
'rm -rf client-gen/dist client-gen/kiota',
'curl -sL https://github.com/andreaTP/apicurio-client-gen-poc/releases/download/0.0.4/dist.tar.gz | tar -xz -C client-gen',
'mv client-gen/dist client-gen/kiota'
'rm -rf client-gen/dist',
'curl -sL https://github.com/andreaTP/apicurio-client-gen-poc/releases/download/0.0.7/dist.tar.gz | tar -xz -C client-gen'
],
blocking: true,
parallel: false
Expand Down

0 comments on commit de2f913

Please sign in to comment.