chore: Update CopilotActionTypePriorityService and CopilotActionTypeElement

This commit is contained in:
Simon Larsen 2024-09-02 17:36:29 +01:00
parent c76237f785
commit 06ac018ec6
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
3 changed files with 26 additions and 8 deletions

View File

@ -1,4 +1,5 @@
import CopilotActionType from "../../Types/Copilot/CopilotActionType";
import BadDataException from "../../Types/Exception/BadDataException";
import ObjectID from "../../Types/ObjectID";
import CreateBy from "../Types/Database/CreateBy";
import { OnCreate } from "../Types/Database/Hooks";
@ -20,11 +21,11 @@ export class Service extends DatabaseService<Model> {
createBy.data.codeRepositoryId;
if (!actionType) {
throw new Error("ActionType is required");
throw new BadDataException("ActionType is required");
}
if (!codeRepositoryId) {
throw new Error("CodeRepositoryId is required");
throw new BadDataException("CodeRepositoryId is required");
}
const existingItem: Model | null = await this.findOneBy({
@ -44,7 +45,9 @@ export class Service extends DatabaseService<Model> {
};
}
throw new Error("Action Type already exists for this repository.");
throw new BadDataException(
"Action Type already exists for this repository.",
);
}
}

View File

@ -16,7 +16,9 @@ const CopilotActionTypeElement: FunctionComponent<ComponentProps> = (
return (
<div>
<p className="font-semibold text-gray-900">{copilotActionTypeData.type}</p>
<p className="font-semibold text-gray-900">
{copilotActionTypeData.type}
</p>
<p>{copilotActionTypeData.description}</p>
</div>
);

View File

@ -61,7 +61,16 @@ const CopilotPriorities: FunctionComponent<
"Please enter priority for this action. Please enter a number from 1 to 5.",
},
]}
createVerb="Add"
singularName="Action"
pluralName="Actions"
showRefreshButton={true}
onBeforeCreate={(
copilotActionTypePriority: CopilotActionTypePriority,
) => {
copilotActionTypePriority.codeRepositoryId = modelId;
return Promise.resolve(copilotActionTypePriority);
}}
showViewIdButton={true}
filters={[]}
columns={[
@ -71,11 +80,15 @@ const CopilotPriorities: FunctionComponent<
},
title: "Action",
type: FieldType.Element,
getElement: (copilotActionTypePriority: CopilotActionTypePriority) => {
getElement: (
copilotActionTypePriority: CopilotActionTypePriority,
) => {
return (
<CopilotActionTypeElement copilotAction={copilotActionTypePriority.actionType!} />
)
}
<CopilotActionTypeElement
copilotAction={copilotActionTypePriority.actionType!}
/>
);
},
},
{
field: {