From 250148c991fe5fed5bf5647d44011f050c02e94b Mon Sep 17 00:00:00 2001 From: srinivaspendem Date: Fri, 11 Aug 2023 21:24:28 +0530 Subject: [PATCH] improvement: added validation for the expired date --- .../components/command-palette/command-k.tsx | 4 +-- apps/app/components/exporter/export-modal.tsx | 2 +- apps/app/components/exporter/guide.tsx | 2 +- .../app/components/exporter/single-export.tsx | 30 ++++++++++++++----- .../components/integration/github/root.tsx | 4 +-- apps/app/components/integration/jira/root.tsx | 4 +-- apps/app/layouts/settings-navbar.tsx | 4 +-- .../settings/{export.tsx => exports.tsx} | 0 .../settings/{import.tsx => imports.tsx} | 0 9 files changed, 32 insertions(+), 18 deletions(-) rename apps/app/pages/[workspaceSlug]/settings/{export.tsx => exports.tsx} (100%) rename apps/app/pages/[workspaceSlug]/settings/{import.tsx => imports.tsx} (100%) diff --git a/apps/app/components/command-palette/command-k.tsx b/apps/app/components/command-palette/command-k.tsx index 66a145871..fc5c29615 100644 --- a/apps/app/components/command-palette/command-k.tsx +++ b/apps/app/components/command-palette/command-k.tsx @@ -731,7 +731,7 @@ export const CommandK: React.FC = ({ deleteIssue, isPaletteOpen, setIsPal redirect(`/${workspaceSlug}/settings/import`)} + onSelect={() => redirect(`/${workspaceSlug}/settings/imports`)} className="focus:outline-none" >
@@ -740,7 +740,7 @@ export const CommandK: React.FC = ({ deleteIssue, isPaletteOpen, setIsPal
redirect(`/${workspaceSlug}/settings/export`)} + onSelect={() => redirect(`/${workspaceSlug}/settings/exports`)} className="focus:outline-none" >
diff --git a/apps/app/components/exporter/export-modal.tsx b/apps/app/components/exporter/export-modal.tsx index 027f4c2cf..df4729265 100644 --- a/apps/app/components/exporter/export-modal.tsx +++ b/apps/app/components/exporter/export-modal.tsx @@ -63,7 +63,7 @@ export const Exporter: React.FC = ({ await CSVIntegrationService.exportCSVService(workspaceSlug as string, payload, user) .then(() => { mutateServices(); - router.push(`/${workspaceSlug}/settings/export`); + router.push(`/${workspaceSlug}/settings/exports`); setExportLoading(false); setToastAlert({ type: "success", diff --git a/apps/app/components/exporter/guide.tsx b/apps/app/components/exporter/guide.tsx index 24aeed508..82a4fd453 100644 --- a/apps/app/components/exporter/guide.tsx +++ b/apps/app/components/exporter/guide.tsx @@ -41,7 +41,7 @@ const IntegrationGuide = () => { ); const handleCsvClose = () => { - router.replace(`/plane/settings/export`); + router.replace(`/plane/settings/exports`); }; return ( diff --git a/apps/app/components/exporter/single-export.tsx b/apps/app/components/exporter/single-export.tsx index ad4638941..34eb1510a 100644 --- a/apps/app/components/exporter/single-export.tsx +++ b/apps/app/components/exporter/single-export.tsx @@ -16,6 +16,14 @@ type Props = { export const SingleExport: React.FC = ({ service, refreshing }) => { const provider = service.provider; const [isLoading, setIsLoading] = React.useState(false); + + const checkExpiry = (inputDateString: string) => { + const currentDate = new Date(); + const expiryDate = new Date(inputDateString); + expiryDate.setDate(expiryDate.getDate() + 7); + return expiryDate > currentDate; + }; + return (
@@ -53,14 +61,20 @@ export const SingleExport: React.FC = ({ service, refreshing }) => { Exported by {service?.initiated_by_detail?.display_name}
- {service.status == "completed" && ( -
- - - {isLoading ? "Downloading..." : "Download"} - - -
+ {checkExpiry(service.created_at) ? ( + <> + {service.status == "completed" && ( +
+ + + {isLoading ? "Downloading..." : "Download"} + + +
+ )} + + ) : ( +
Expired
)}
); diff --git a/apps/app/components/integration/github/root.tsx b/apps/app/components/integration/github/root.tsx index 403ac6e68..2e5d9e0c4 100644 --- a/apps/app/components/integration/github/root.tsx +++ b/apps/app/components/integration/github/root.tsx @@ -163,7 +163,7 @@ export const GithubImporterRoot: React.FC = ({ user }) => { await GithubIntegrationService.createGithubServiceImport(workspaceSlug as string, payload, user) .then(() => { - router.push(`/${workspaceSlug}/settings/import`); + router.push(`/${workspaceSlug}/settings/imports`); mutate(IMPORTER_SERVICES_LIST(workspaceSlug as string)); }) .catch(() => @@ -178,7 +178,7 @@ export const GithubImporterRoot: React.FC = ({ user }) => { return (
- +
Cancel import & go back
diff --git a/apps/app/components/integration/jira/root.tsx b/apps/app/components/integration/jira/root.tsx index c9baa0c37..b5c086431 100644 --- a/apps/app/components/integration/jira/root.tsx +++ b/apps/app/components/integration/jira/root.tsx @@ -92,7 +92,7 @@ export const JiraImporterRoot: React.FC = ({ user }) => { .createJiraImporter(workspaceSlug.toString(), data, user) .then(() => { mutate(IMPORTER_SERVICES_LIST(workspaceSlug.toString())); - router.push(`/${workspaceSlug}/settings/import`); + router.push(`/${workspaceSlug}/settings/imports`); }) .catch((err) => { console.log(err); @@ -109,7 +109,7 @@ export const JiraImporterRoot: React.FC = ({ user }) => { return (
- +
diff --git a/apps/app/layouts/settings-navbar.tsx b/apps/app/layouts/settings-navbar.tsx index 89cdcf651..462a4b6a0 100644 --- a/apps/app/layouts/settings-navbar.tsx +++ b/apps/app/layouts/settings-navbar.tsx @@ -31,11 +31,11 @@ const SettingsNavbar: React.FC = ({ profilePage = false }) => { }, { label: "Imports", - href: `/${workspaceSlug}/settings/import`, + href: `/${workspaceSlug}/settings/imports`, }, { label: "Exports", - href: `/${workspaceSlug}/settings/export`, + href: `/${workspaceSlug}/settings/exports`, }, ]; diff --git a/apps/app/pages/[workspaceSlug]/settings/export.tsx b/apps/app/pages/[workspaceSlug]/settings/exports.tsx similarity index 100% rename from apps/app/pages/[workspaceSlug]/settings/export.tsx rename to apps/app/pages/[workspaceSlug]/settings/exports.tsx diff --git a/apps/app/pages/[workspaceSlug]/settings/import.tsx b/apps/app/pages/[workspaceSlug]/settings/imports.tsx similarity index 100% rename from apps/app/pages/[workspaceSlug]/settings/import.tsx rename to apps/app/pages/[workspaceSlug]/settings/imports.tsx