Skip to content

Commit

Permalink
Merge pull request #936 from tharikaGitHub/design-assistant
Browse files Browse the repository at this point in the history
Add improvements to the design assistant feature
  • Loading branch information
hisanhunais authored Feb 21, 2025
2 parents 5e2dc84 + 01b25d1 commit c243f35
Show file tree
Hide file tree
Showing 22 changed files with 572 additions and 604 deletions.
8 changes: 8 additions & 0 deletions portals/publisher/src/main/webapp/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 portals/publisher/src/main/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"@testing-library/user-event": "^14.5.2",
"@types/history": "^4.7.9",
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.9",
"@types/lodash.clonedeep": "^4.5.6",
"@types/mui-datatables": "^4.3.0",
"@types/react": "^17.0.0",
Expand Down
21 changes: 16 additions & 5 deletions portals/publisher/src/main/webapp/site/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"Apis.Create.AsyncAPI.ApiCreateAsyncAPI.create": "Create",
"Apis.Create.AsyncAPI.ApiCreateAsyncAPI.created.error": "Something went wrong while adding the API",
"Apis.Create.AsyncAPI.ApiCreateAsyncAPI.created.success": "API created successfully",
"Apis.Create.AsyncAPI.ApiCreateAsyncAPI.designAssistant.back": "Back",
"Apis.Create.AsyncAPI.ApiCreateAsyncAPI.externalEndpoint": "External Endpoint",
"Apis.Create.AsyncAPI.ApiCreateAsyncAPI.externalEndpoint.error": "Invalid Endpoint URL",
"Apis.Create.AsyncAPI.ApiCreateAsyncAPI.heading": "Create an API using an AsyncAPI definition.",
Expand Down Expand Up @@ -104,7 +105,7 @@
"Apis.Create.Default.APICreateDefault.apiProduct.heading": "Create an API Product",
"Apis.Create.Default.APICreateDefault.apiProduct.sub.heading": "Create an API Product by providing a Name, a Context, and Business Plans (optional).",
"Apis.Create.Default.APICreateDefault.cancel": "Cancel",
"Apis.Create.Default.APICreateDefault.create.btn": "Create",
"Apis.Create.Default.APICreateDefault.create.btn": "Create API",
"Apis.Create.Default.APICreateDefault.create.publish.btn": "Create & Publish",
"Apis.Create.Default.APICreateDefault.create.publish.btn.creating.deploying.revision.status": "Deploying Revision . . .",
"Apis.Create.Default.APICreateDefault.create.publish.btn.creating.publishing.status": "Publishing API . . .",
Expand All @@ -130,6 +131,7 @@
"Apis.Create.GraphQL.ApiCreateGraphQL.create": "Create",
"Apis.Create.GraphQL.ApiCreateGraphQL.created.error": "Something went wrong while adding the API",
"Apis.Create.GraphQL.ApiCreateGraphQL.created.success": "{name} API created successfully",
"Apis.Create.GraphQL.ApiCreateGraphQL.designAssistant.back": "Back",
"Apis.Create.GraphQL.ApiCreateGraphQL.error.policies.not.available": "Throttling policies not available. Contact your administrator",
"Apis.Create.GraphQL.ApiCreateGraphQL.heading": "Create a GraphQL API",
"Apis.Create.GraphQL.ApiCreateGraphQL.next": "Next",
Expand All @@ -152,6 +154,7 @@
"Apis.Create.OpenAPI.ApiCreateOpenAPI.create": "Create",
"Apis.Create.OpenAPI.ApiCreateOpenAPI.created.error": "Something went wrong while adding the API",
"Apis.Create.OpenAPI.ApiCreateOpenAPI.created.success": "API created successfully",
"Apis.Create.OpenAPI.ApiCreateOpenAPI.designAssistant.back": "Back",
"Apis.Create.OpenAPI.ApiCreateOpenAPI.heading": "Create an API using an OpenAPI definition.",
"Apis.Create.OpenAPI.ApiCreateOpenAPI.next": "Next",
"Apis.Create.OpenAPI.ApiCreateOpenAPI.sub.heading": "Create an API using an existing OpenAPI definition file or URL.",
Expand Down Expand Up @@ -312,14 +315,13 @@
"Apis.Details.APIProduct.NewVersion.NewVersion.success": "Successfully created new version",
"Apis.Details.AccessControl.roles.help": "Enter valid role and press enter",
"Apis.Details.ApiChat.components.ApiChatExecute.disclaimer.label": "It is prudent to exercise a degree of caution and thoughtfulness, as language models may exhibit some degree of unpredictability at times.",
"Apis.Details.ApiChat.components.ApiChatExecute.executeButton.label": "Execute",
"Apis.Details.ApiChat.components.ApiChatExecute.queryInput.placeholder": "Type the test scenario here...",
"Apis.Details.ApiChat.components.ApiChatExecute.queryInput.placeholder": "Describe your API design requirements...",
"Apis.Details.ApiChat.components.ApiChatPoweredBy.apiChatMainHeader": "API Design Assistant",
"Apis.Details.ApiChat.components.ApiChatResponse.CopyToClipboard.copiedText": "Copied",
"Apis.Details.ApiChat.components.ApiChatResponse.CopyToClipboard.copyText": "Copy cURL to Clipboard",
"Apis.Details.ApiChat.components.CopyToClipboard.copiedText": "Copied",
"Apis.Details.ApiChat.components.CopyToClipboard.copyText": "Copy to Clipboard",
"Apis.Details.ApiChat.components.SampleQueryCard.executeButton": "EXECUTE",
"Apis.Details.ApiChat.components.SampleQueryCard.executeButton": "Try It",
"Apis.Details.ApiConsole.ApiConsole.title": "Try Out",
"Apis.Details.ApiConsole.adv.auth.header": "Authorization Header",
"Apis.Details.ApiConsole.adv.auth.header.value": "Authorization Header Value",
Expand Down Expand Up @@ -439,10 +441,14 @@
"Apis.Details.Configuration.Components.validate.role.error": "Error when validating role: {role}",
"Apis.Details.Configuration.Configuration.ApiKeyHeader.tooltip": "The header name that is used to send the api key information. \"ApiKey\" is the default header.",
"Apis.Details.Configuration.Configuration.AuthHeader.tooltip": "The header name that is used to send the authorization information. \"Authorization\" is the default header.",
"Apis.Details.Configuration.Configuration.Design.attached.labels": "Attached Labels",
"Apis.Details.Configuration.Configuration.Design.no.labels": "No Labels Attached",
"Apis.Details.Configuration.Configuration.Design.no.labels.found": "No Labels Found",
"Apis.Details.Configuration.Configuration.Design.no.more.labels": "No More Labels Available",
"Apis.Details.Configuration.Configuration.Design.sub.heading": "Configure basic API meta information",
"Apis.Details.Configuration.Configuration.Design.topic.header": "Design Configurations",
"Apis.Details.Configuration.Configuration.Design.topic.label": "Labels",
"Apis.Details.Configuration.Configuration.Design.unattached.labels": "Unattached Labels",
"Apis.Details.Configuration.Configuration.Endpoints.edit.api.endpoints": "Edit API Endpoints",
"Apis.Details.Configuration.Configuration.apiKey.header.label": "ApiKey Header",
"Apis.Details.Configuration.Configuration.auth.header.label": "Authorization Header",
Expand Down Expand Up @@ -1616,10 +1622,14 @@
"Apis.Details.Security.SecurityOverview.policy.remove.success": "Policy removed successfully.",
"Apis.Details.Security.SecurityOverview.policy.type": "Policy Type",
"Apis.Details.Security.SecurityOverview.threat.protection.policies": "Threat Protection Policies",
"Apis.Details.ShareAPI.Organization.Subscriptions.no.selected.organizations": "No organizations selected",
"Apis.Details.ShareAPI.Shared.organizations.selection.all.tooltip": "Select this to share the API with all the existing organizations and all new organizations that you register under your current organization.",
"Apis.Details.ShareAPI.Shared.organizations.selection.none.tooltip": "This will allow you to prevent sharing this API with any of the existing organizations or new organizations that you register under this organization in the future.",
"Apis.Details.ShareAPI.cancel": "Cancel",
"Apis.Details.ShareAPI.save": "Save",
"Apis.Details.ShareAPI.subValidationDisabled.dialog.description": "Subscription validation is disabled for this API. This will allow anyone with a valid token inside a shared organization to consume the API without a subscription. Do you want to confirm?",
"Apis.Details.ShareAPI.subValidationDisabled.dialog.title": "Caution!",
"Apis.Details.ShareAPI.subValidationEnabled.dialog.description": "Subscription policies are not set for some of the organizations. Root organization's subscription policies will be set to them. Do you want to confirm?",
"Apis.Details.ShareAPI.title": "Share API",
"Apis.Details.ShareAPI.update.error": "Error occurred while updating API sharing configurations",
"Apis.Details.ShareAPI.update.success": "API sharing configurations updated successfully",
Expand Down Expand Up @@ -1775,7 +1785,7 @@
"Apis.Listing.SampleAPI.SampleAPI.ai.api.create.title": "Create AI/LLM API",
"Apis.Listing.SampleAPI.SampleAPI.ai.api.import.content": "Create AI/LLM APIs by importing service provider APIs",
"Apis.Listing.SampleAPI.SampleAPI.create.new": "Let’s get started !",
"Apis.Listing.SampleAPI.SampleAPI.create.new.description": "Choose your option to create an API",
"Apis.Listing.SampleAPI.SampleAPI.create.new.description": "Create an API by yourself or",
"Apis.Listing.SampleAPI.SampleAPI.graphql.api": "GraphQL",
"Apis.Listing.SampleAPI.SampleAPI.graphql.import.sdl.content": "Use an existing schema or endpoint",
"Apis.Listing.SampleAPI.SampleAPI.graphql.import.sdl.title": "Create GraphQL API",
Expand Down Expand Up @@ -1943,6 +1953,7 @@
"Confirm.UnDeploy": "Confirm Undeployment",
"Confirm.Undeploy.Verify": "Are you sure you want to undepoly the policy?",
"Connection.Timeout": "Connection Timeout",
"CreateAPIWithAI.components.AlertDialog.error.create.API": "Error Creating API",
"Custom.Split.Button.Save": "Save",
"Custom.Split.Button.Save.And.Deploy": "Save and deploy",
"Delete": "Delete",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Stepper from '@mui/material/Stepper';
import Step from '@mui/material/Step';
import StepLabel from '@mui/material/StepLabel';
import Button from '@mui/material/Button';
import { Link } from 'react-router-dom';
import { Link, useLocation } from 'react-router-dom';
import API from 'AppData/api';
import Alert from 'AppComponents/Shared/Alert';
import CircularProgress from '@mui/material/CircularProgress';
Expand Down Expand Up @@ -82,6 +82,8 @@ const StyledAPICreateBase = styled(APICreateBase)((
*/
export default function ApiCreateAsyncAPI(props) {
const [wizardStep, setWizardStep] = useState(0);
const location = useLocation();
const assistantInfo = location.state;
const { history, multiGateway } = props;
const { data: settings } = usePublisherSettings();
// eslint-disable-next-line no-use-before-define
Expand Down Expand Up @@ -141,6 +143,15 @@ export default function ApiCreateAsyncAPI(props) {
'wso2/synapse' : multiGateway[0]?.value),
});

if (assistantInfo && wizardStep === 0 && assistantInfo.source === 'DesignAssistant') {
setWizardStep(1);
inputsDispatcher({ action: 'preSetAPI', value: assistantInfo });
inputsDispatcher({ action: 'protocol', value: assistantInfo.protocol });
inputsDispatcher({ action: 'endpoint', value: assistantInfo.endpoint });
inputsDispatcher({ action: 'inputType', value: 'file' });
inputsDispatcher({ action: 'inputValue', value: assistantInfo.file });
}

const protocols = [
{
name: 'ws',
Expand Down Expand Up @@ -171,6 +182,16 @@ export default function ApiCreateAsyncAPI(props) {
Other: 'ASYNC',
};

/**
* Handles back button click for the API creation wizard for Design Asistant
* @param
*
*/
const handleBackButtonOnClick = () => {
const landingPage = '/apis';
history.push(landingPage);
};

/**
*
*
Expand Down Expand Up @@ -461,12 +482,21 @@ export default function ApiCreateAsyncAPI(props) {
</Link>
)}
{wizardStep === 1 && (
<Button onClick={() => setWizardStep((step) => step - 1)}>
<FormattedMessage
id='Apis.Create.AsyncAPI.ApiCreateAsyncAPI.back'
defaultMessage='Back'
/>
</Button>
(assistantInfo && assistantInfo.source === 'DesignAssistant') ? (
<Button onClick={handleBackButtonOnClick}>
<FormattedMessage
id='Apis.Create.AsyncAPI.ApiCreateAsyncAPI.designAssistant.back'
defaultMessage='Back'
/>
</Button>
) : (
<Button onClick={() => setWizardStep((step) => step - 1)}>
<FormattedMessage
id='Apis.Create.AsyncAPI.ApiCreateAsyncAPI.back'
defaultMessage='Back'
/>
</Button>
)
)}
</Grid>
<Grid item>
Expand Down
Loading

0 comments on commit c243f35

Please sign in to comment.