plane/web/components/integration/single-import.tsx
rahulramesha c16a5b9b71
[WEB-626] chore: fix sentry issues and refactor issue actions logic for issue layouts (#3650)
* restructure the logic to avoid throwing error if any dat is not found

* updated files for previous commit

* fix build errors

* remove throwing error if userId is undefined

* optionally chain display_name property to fix sentry issues

* add ooptional check

* change issue action logic to increase code maintainability and make sure to send only the updated date while updating the issue

* fix issue updation bugs

* fix module issues build error

* fix runtime errors
2024-03-06 20:47:38 +05:30

56 lines
1.9 KiB
TypeScript

// ui
import { Trash2 } from "lucide-react";
import { CustomMenu } from "@plane/ui";
// icons
// helpers
import { IMPORTERS_LIST } from "constants/workspace";
import { renderFormattedDate } from "helpers/date-time.helper";
// types
import { IImporterService } from "@plane/types";
// constants
type Props = {
service: IImporterService;
refreshing: boolean;
handleDelete: () => void;
};
export const SingleImport: React.FC<Props> = ({ service, refreshing, handleDelete }) => (
<div className="flex items-center justify-between gap-2 px-4 py-3">
<div>
<h4 className="flex items-center gap-2 text-sm">
<span>
Import from{" "}
<span className="font-medium">{IMPORTERS_LIST.find((i) => i.provider === service.service)?.title}</span> to{" "}
<span className="font-medium">{service.project_detail.name}</span>
</span>
<span
className={`rounded px-2 py-0.5 text-xs capitalize ${
service.status === "completed"
? "bg-green-500/20 text-green-500"
: service.status === "processing"
? "bg-yellow-500/20 text-yellow-500"
: service.status === "failed"
? "bg-red-500/20 text-red-500"
: ""
}`}
>
{refreshing ? "Refreshing..." : service.status}
</span>
</h4>
<div className="mt-2 flex items-center gap-2 text-xs text-custom-text-200">
<span>{renderFormattedDate(service.created_at)}</span>|
<span>Imported by {service.initiated_by_detail?.display_name}</span>
</div>
</div>
<CustomMenu ellipsis>
<CustomMenu.MenuItem onClick={handleDelete}>
<span className="flex items-center justify-start gap-2">
<Trash2 className="h-3.5 w-3.5" />
Delete import
</span>
</CustomMenu.MenuItem>
</CustomMenu>
</div>
);