forked from syndesisio/syndesis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request syndesisio#346 from kahboom/api-editors
- Loading branch information
Showing
84 changed files
with
2,183 additions
and
1,013 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { APISummary } from '@syndesis/models'; | ||
import * as React from 'react'; | ||
import { ApiContext } from './ApiContext'; | ||
import { callFetch } from './callFetch'; | ||
|
||
export function useApiProviderSummary(specification: string) { | ||
const apiContext = React.useContext(ApiContext); | ||
const [loading, setLoading] = React.useState(true); | ||
const [error, setError] = React.useState<false | Error>(false); | ||
const [apiSummary, setApiSummary] = React.useState<APISummary | undefined>( | ||
undefined | ||
); | ||
|
||
React.useEffect(() => { | ||
const fetchSummary = async () => { | ||
setLoading(true); | ||
try { | ||
const body = new FormData(); | ||
body.append('specification', specification); | ||
const response = await callFetch({ | ||
body, | ||
headers: apiContext.headers, | ||
includeAccept: true, | ||
includeContentType: false, | ||
method: 'POST', | ||
url: `${apiContext.apiUri}/apis/info`, | ||
}); | ||
const summary = await response.json(); | ||
if (summary.errorCode) { | ||
throw new Error(summary.userMsg); | ||
} | ||
setApiSummary(summary as APISummary); | ||
} catch (e) { | ||
setError(e as Error); | ||
} finally { | ||
setLoading(false); | ||
} | ||
}; | ||
fetchSummary(); | ||
}, [specification, apiContext, setLoading]); | ||
|
||
return { apiSummary, loading, error }; | ||
} | ||
|
||
export function useApiProviderIntegration() { | ||
const apiContext = React.useContext(ApiContext); | ||
|
||
const getIntegration = async (specification: string) => { | ||
const body = new FormData(); | ||
body.append('specification', specification); | ||
const response = await callFetch({ | ||
body, | ||
headers: apiContext.headers, | ||
includeAccept: true, | ||
includeContentType: false, | ||
method: 'POST', | ||
url: `${apiContext.apiUri}/apis/generator`, | ||
}); | ||
const integration = await response.json(); | ||
if (integration.errorCode) { | ||
throw new Error(integration.userMsg); | ||
} | ||
return integration; | ||
}; | ||
|
||
return getIntegration; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
app/ui-react/packages/ui/src/Integration/Editor/apiProvider/ApiProviderEditSpecification.tsx
This file was deleted.
Oops, something went wrong.
91 changes: 0 additions & 91 deletions
91
app/ui-react/packages/ui/src/Integration/Editor/apiProvider/ApiProviderReviewActions.tsx
This file was deleted.
Oops, something went wrong.
20 changes: 11 additions & 9 deletions
20
app/ui-react/packages/ui/src/Integration/Editor/apiProvider/ApiProviderReviewOperations.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { PageSection } from '@patternfly/react-core'; | ||
import { ListView } from 'patternfly-react'; | ||
import * as React from 'react'; | ||
|
||
export interface IApiProviderReviewOperationsProps { | ||
/** | ||
* The title | ||
*/ | ||
i18nTitle?: string; | ||
} | ||
import { IListViewToolbarProps, ListViewToolbar } from '../../../Shared'; | ||
|
||
export class ApiProviderReviewOperations extends React.Component< | ||
IApiProviderReviewOperationsProps | ||
IListViewToolbarProps | ||
> { | ||
public render() { | ||
return <>{this.props.i18nTitle}</>; | ||
const { children, ...props } = this.props; | ||
return ( | ||
<PageSection> | ||
<ListViewToolbar {...props} /> | ||
<ListView>{children}</ListView> | ||
</PageSection> | ||
); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...-react/packages/ui/src/Integration/Editor/apiProvider/ApiProviderReviewOperationsItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as H from '@syndesis/history'; | ||
import { ListView } from 'patternfly-react'; | ||
import * as React from 'react'; | ||
import { ButtonLink } from '../../../Layout'; | ||
import { HttpMethodColors } from '../../../Shared'; | ||
|
||
export interface IApiProviderReviewOperationsItemProps { | ||
createAsPrimary: boolean; | ||
createFlowHref: H.LocationDescriptor; | ||
i18nCreateFlow: string; | ||
onCreateFlow?: (e: React.MouseEvent<any>) => void; | ||
operationDescription: string; | ||
operationHttpMethod: string; | ||
operationPath: string; | ||
} | ||
|
||
export class ApiProviderReviewOperationsItem extends React.Component< | ||
IApiProviderReviewOperationsItemProps | ||
> { | ||
public render() { | ||
return ( | ||
<ListView.Item | ||
actions={ | ||
<ButtonLink | ||
data-testid={'api-provider-operations-create-flow'} | ||
onClick={this.props.onCreateFlow} | ||
href={this.props.createFlowHref} | ||
as={this.props.createAsPrimary ? 'primary' : 'default'} | ||
> | ||
{this.props.i18nCreateFlow} | ||
</ButtonLink> | ||
} | ||
className={'api-provider-operations-list-item'} | ||
heading={this.props.operationPath} | ||
description={this.props.operationDescription} | ||
leftContent={ | ||
<HttpMethodColors method={this.props.operationHttpMethod} /> | ||
} | ||
stacked={false} | ||
/> | ||
); | ||
} | ||
} |
Oops, something went wrong.