mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
refactor: Update CopilotActionTypeElement import paths
This commit is contained in:
parent
4314920cd7
commit
4b0f71b4e4
@ -2,28 +2,38 @@ import Link from "Common/UI/Components/Link/Link";
|
||||
import React, { FunctionComponent, ReactElement } from "react";
|
||||
import CodeRepositoryType from "Common/Types/CodeRepository/CodeRepositoryType";
|
||||
import URL from "Common/Types/API/URL";
|
||||
import PullRequestStatusElement from "./PullRequestStatus";
|
||||
import PullRequestState from "Common/Types/CodeRepository/PullRequestState";
|
||||
|
||||
export interface ComponentProps {
|
||||
pullRequestId: string;
|
||||
repoType: CodeRepositoryType;
|
||||
organizationName: string;
|
||||
repositoryName: string;
|
||||
pullRequestStatus: PullRequestState
|
||||
}
|
||||
|
||||
const PullRequestViewElement: FunctionComponent<ComponentProps> = (
|
||||
props: ComponentProps,
|
||||
): ReactElement => {
|
||||
if (props.repoType === CodeRepositoryType.GitHub) {
|
||||
|
||||
const to: URL = URL.fromString(
|
||||
`https://github.com/${props.organizationName}/${props.repositoryName}/pull/${props.pullRequestId}`,
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-x-3 flex">
|
||||
<div>
|
||||
<PullRequestStatusElement pullRequestStatus={props.pullRequestStatus} />
|
||||
</div>
|
||||
<Link to={to} className="hover:underline" openInNewTab={true}>
|
||||
<>
|
||||
<span>#</span>
|
||||
{props.pullRequestId}
|
||||
</>
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
import { Gray500, Green500, Red500, Yellow500 } from "Common/Types/BrandColors";
|
||||
import CopilotActionStatus from "Common/Types/Copilot/CopilotActionStatus";
|
||||
import Pill from "Common/UI/Components/Pill/Pill";
|
||||
import React, { FunctionComponent, ReactElement } from "react";
|
||||
|
||||
export interface ComponentProps {
|
||||
copilotActionStatus: CopilotActionStatus;
|
||||
}
|
||||
|
||||
const CopilotActionStatusElement: FunctionComponent<ComponentProps> = (
|
||||
props: ComponentProps,
|
||||
): ReactElement => {
|
||||
if (props.copilotActionStatus === CopilotActionStatus.PR_CREATED) {
|
||||
return <Pill color={Green500} isMinimal={true} text={"PR Created"} />;
|
||||
}
|
||||
|
||||
if (props.copilotActionStatus === CopilotActionStatus.NO_ACTION_REQUIRED) {
|
||||
return <Pill color={Green500} isMinimal={true} text={"No Action Required"} />;
|
||||
}
|
||||
|
||||
if (props.copilotActionStatus === CopilotActionStatus.CANNOT_FIX) {
|
||||
return <Pill color={Red500} text={"Cannot Fix"} />;
|
||||
}
|
||||
|
||||
if (props.copilotActionStatus === CopilotActionStatus.IN_QUEUE) {
|
||||
return <Pill color={Gray500} text={"In Queue"} />;
|
||||
}
|
||||
|
||||
if (props.copilotActionStatus === CopilotActionStatus.PROCESSING) {
|
||||
return <Pill color={Yellow500} text={"Processing"} />;
|
||||
}
|
||||
|
||||
return <></>;
|
||||
};
|
||||
|
||||
export default CopilotActionStatusElement;
|
@ -0,0 +1,152 @@
|
||||
import DashboardNavigation from "../../../Utils/Navigation";
|
||||
import ModelTable from "Common/UI/Components/ModelTable/ModelTable";
|
||||
import FieldType from "Common/UI/Components/Types/FieldType";
|
||||
import React, {
|
||||
Fragment,
|
||||
FunctionComponent,
|
||||
ReactElement,
|
||||
} from "react";
|
||||
import DropdownUtil from "Common/UI/Utils/Dropdown";
|
||||
import PullRequestState from "Common/Types/CodeRepository/PullRequestState";
|
||||
import PullRequestViewElement from "../../CodeRepository/PullRequestView";
|
||||
import CopilotAction from "Common/Models/DatabaseModels/CopilotAction";
|
||||
import Query from "Common/Types/BaseDatabase/Query";
|
||||
import CopilotActionStatus from "Common/Types/Copilot/CopilotActionStatus";
|
||||
import Columns from "Common/UI/Components/ModelTable/Columns";
|
||||
import CopilotActionStatusElement from "./CopilotActionStatusElement";
|
||||
import CodeRepositoryType from "Common/Types/CodeRepository/CodeRepositoryType";
|
||||
|
||||
|
||||
export interface ComponentProps {
|
||||
query: Query<CopilotAction>;
|
||||
repoOrganizationName: string;
|
||||
repoName: string;
|
||||
repoType: CodeRepositoryType;
|
||||
}
|
||||
|
||||
const LabelElement: FunctionComponent<ComponentProps> = (
|
||||
props: ComponentProps,
|
||||
): ReactElement => {
|
||||
|
||||
let isPullRequestTable = false;
|
||||
|
||||
if (props.query.copilotActionStatus === CopilotActionStatus.PR_CREATED) {
|
||||
isPullRequestTable = true;
|
||||
}
|
||||
|
||||
const columns: Columns<CopilotAction> = [
|
||||
{
|
||||
field: {
|
||||
copilotActionType: true,
|
||||
},
|
||||
title: "Action Type",
|
||||
type: FieldType.Text,
|
||||
},
|
||||
{
|
||||
field: {
|
||||
createdAt: true,
|
||||
},
|
||||
title: "Created At",
|
||||
type: FieldType.DateTime,
|
||||
},
|
||||
{
|
||||
field: {
|
||||
copilotActionStatus: true,
|
||||
},
|
||||
title: "Status",
|
||||
type: FieldType.Element,
|
||||
getElement: (item: CopilotAction): ReactElement => {
|
||||
if (!item.copilotActionStatus) {
|
||||
return <p>-</p>;
|
||||
}
|
||||
|
||||
return (
|
||||
<CopilotActionStatusElement copilotActionStatus={item.copilotActionStatus} />
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
if (isPullRequestTable) {
|
||||
// then
|
||||
columns.push({
|
||||
field: {
|
||||
copilotPullRequest: {
|
||||
pullRequestId: true,
|
||||
copilotPullRequestStatus: true,
|
||||
|
||||
},
|
||||
},
|
||||
title: "Pull Request",
|
||||
type: FieldType.Element,
|
||||
getElement: (item: CopilotAction): ReactElement => {
|
||||
if (!item.copilotPullRequest) {
|
||||
return <p>-</p>;
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<PullRequestViewElement
|
||||
pullRequestId={item.copilotPullRequest.pullRequestId!}
|
||||
organizationName={props.repoOrganizationName}
|
||||
repositoryName={props.repoName}
|
||||
repoType={props.repoType}
|
||||
pullRequestStatus={item.copilotPullRequest.copilotPullRequestStatus!}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<ModelTable<CopilotAction>
|
||||
modelType={CopilotAction}
|
||||
id="table-copiolt-pull-requests"
|
||||
name="Code Repository > Pull Requests"
|
||||
isDeleteable={false}
|
||||
isCreateable={false}
|
||||
isEditable={false}
|
||||
isViewable={false}
|
||||
showViewIdButton={false}
|
||||
query={{
|
||||
projectId: DashboardNavigation.getProjectId()!,
|
||||
...props.query
|
||||
}}
|
||||
selectMoreFields={{
|
||||
copilotPullRequest: {
|
||||
pullRequestId: true,
|
||||
copilotPullRequestStatus: true
|
||||
}
|
||||
}}
|
||||
cardProps={{
|
||||
title: "Pull Requests",
|
||||
description:
|
||||
"List of pull requests created by OneUptime Copilot for this code repository.",
|
||||
}}
|
||||
noItemsMessage={
|
||||
"No pull requests found. OneUptime Copilot has not created any pull requests for this code repository."
|
||||
}
|
||||
showRefreshButton={true}
|
||||
filters={[
|
||||
{
|
||||
field: {
|
||||
copilotActionType: true,
|
||||
},
|
||||
type: FieldType.Text,
|
||||
title: "Action",
|
||||
},
|
||||
{
|
||||
field: {
|
||||
createdAt: true,
|
||||
},
|
||||
type: FieldType.DateTime,
|
||||
title: "Created At",
|
||||
}
|
||||
]}
|
||||
columns={columns}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default LabelElement;
|
@ -10,7 +10,7 @@ import DashboardNavigation from "../../../../Utils/Navigation";
|
||||
import SortOrder from "Common/Types/BaseDatabase/SortOrder";
|
||||
import DropdownUtil from "Common/UI/Utils/Dropdown";
|
||||
import CopilotActionType from "Common/Types/Copilot/CopilotActionType";
|
||||
import CopilotActionTypeElement from "../../../../Components/Copilot/CopilotActionTypeElement";
|
||||
import CopilotActionTypeElement from "../../../../Components/Copilot/CopilotAction/CopilotActionTypeElement";
|
||||
|
||||
const CopilotPriorities: FunctionComponent<
|
||||
PageComponentProps
|
||||
|
@ -23,6 +23,7 @@ import API from "Common/UI/Utils/API/API";
|
||||
import PullRequestViewElement from "../../../../Components/CodeRepository/PullRequestView";
|
||||
import { PromiseVoidFunction } from "Common/Types/FunctionTypes";
|
||||
import CopilotLastRunAt from "../../../../Components/Copilot/LastRunMessage";
|
||||
import CopilotAction from "Common/Models/DatabaseModels/CopilotAction";
|
||||
|
||||
const CopilotPullRequestPage: FunctionComponent<
|
||||
PageComponentProps
|
||||
@ -89,12 +90,11 @@ const CopilotPullRequestPage: FunctionComponent<
|
||||
lastRunAt={codeRepository?.lastCopilotRunDateTime}
|
||||
/>
|
||||
|
||||
<ModelTable<CopilotPullRequest>
|
||||
modelType={CopilotPullRequest}
|
||||
<ModelTable<CopilotAction>
|
||||
modelType={CopilotAction}
|
||||
id="table-copiolt-pull-requests"
|
||||
name="Code Repository > Pull Requests"
|
||||
isDeleteable={false}
|
||||
createVerb={"Add"}
|
||||
isCreateable={false}
|
||||
isEditable={false}
|
||||
isViewable={false}
|
||||
|
Loading…
Reference in New Issue
Block a user