From c0a20c80a2ed3c93976d5ff2ced44a39a93f928b Mon Sep 17 00:00:00 2001 From: Nabarun Gogoi Date: Wed, 20 Dec 2023 10:16:10 +0530 Subject: [PATCH] Implement layout for Project settings tab panel (#10) * Implement tab functionality for settings pannel * Use material ui input component * Handle form state of general panel * Organize project components --------- Co-authored-by: neeraj --- .../{ => projects/project}/ActivityCard.tsx | 2 +- .../project}/DeploymentDetailsCard.tsx | 2 +- .../project/DeploymentsTabPanel.tsx} | 8 +- .../project/OverviewTabPanel.tsx} | 10 +-- .../project/ProjectTabs.tsx} | 22 ++--- .../projects/project/SettingsTabPanel.tsx | 83 +++++++++++++++++++ .../project/settings/GeneralTabPanel.tsx | 76 +++++++++++++++++ .../frontend/src/pages/projects/Project.tsx | 2 +- .../src/pages/projects/create/Success.tsx | 5 +- 9 files changed, 181 insertions(+), 29 deletions(-) rename packages/frontend/src/components/{ => projects/project}/ActivityCard.tsx (93%) rename packages/frontend/src/components/{ => projects/project}/DeploymentDetailsCard.tsx (95%) rename packages/frontend/src/components/{Deployments.tsx => projects/project/DeploymentsTabPanel.tsx} (87%) rename packages/frontend/src/components/{Overview.tsx => projects/project/OverviewTabPanel.tsx} (85%) rename packages/frontend/src/components/{Tab.tsx => projects/project/ProjectTabs.tsx} (77%) create mode 100644 packages/frontend/src/components/projects/project/SettingsTabPanel.tsx create mode 100644 packages/frontend/src/components/projects/project/settings/GeneralTabPanel.tsx diff --git a/packages/frontend/src/components/ActivityCard.tsx b/packages/frontend/src/components/projects/project/ActivityCard.tsx similarity index 93% rename from packages/frontend/src/components/ActivityCard.tsx rename to packages/frontend/src/components/projects/project/ActivityCard.tsx index f802989c..4574084a 100644 --- a/packages/frontend/src/components/ActivityCard.tsx +++ b/packages/frontend/src/components/projects/project/ActivityCard.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { relativeTime } from '../utils/time'; +import { relativeTime } from '../../../utils/time'; interface ActivityDetails { author: string; diff --git a/packages/frontend/src/components/DeploymentDetailsCard.tsx b/packages/frontend/src/components/projects/project/DeploymentDetailsCard.tsx similarity index 95% rename from packages/frontend/src/components/DeploymentDetailsCard.tsx rename to packages/frontend/src/components/projects/project/DeploymentDetailsCard.tsx index 8cb52ee2..fa6421dd 100644 --- a/packages/frontend/src/components/DeploymentDetailsCard.tsx +++ b/packages/frontend/src/components/projects/project/DeploymentDetailsCard.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import { relativeTime } from '../utils/time'; +import { relativeTime } from '../../../utils/time'; interface DeploymentDetails { title: string; diff --git a/packages/frontend/src/components/Deployments.tsx b/packages/frontend/src/components/projects/project/DeploymentsTabPanel.tsx similarity index 87% rename from packages/frontend/src/components/Deployments.tsx rename to packages/frontend/src/components/projects/project/DeploymentsTabPanel.tsx index 308f5b63..98ca4f74 100644 --- a/packages/frontend/src/components/Deployments.tsx +++ b/packages/frontend/src/components/projects/project/DeploymentsTabPanel.tsx @@ -1,15 +1,15 @@ import React from 'react'; -import deploymentDetails from '../assets/deployments.json'; +import deploymentDetails from '../../../assets/deployments.json'; import DeployDetailsCard from './DeploymentDetailsCard'; -import Dropdown from './Dropdown'; +import Dropdown from '../../Dropdown'; const STATUS_OPTIONS = [ { value: 'production', label: 'Production' }, { value: 'preview', label: 'Preview' }, ]; -const Deployments = () => { +const DeploymentsTabPanel = () => { return (
@@ -44,4 +44,4 @@ const Deployments = () => { ); }; -export default Deployments; +export default DeploymentsTabPanel; diff --git a/packages/frontend/src/components/Overview.tsx b/packages/frontend/src/components/projects/project/OverviewTabPanel.tsx similarity index 85% rename from packages/frontend/src/components/Overview.tsx rename to packages/frontend/src/components/projects/project/OverviewTabPanel.tsx index f56baa74..574e1cf9 100644 --- a/packages/frontend/src/components/Overview.tsx +++ b/packages/frontend/src/components/projects/project/OverviewTabPanel.tsx @@ -1,15 +1,15 @@ import React from 'react'; import ActivityCard from './ActivityCard'; -import activityDetails from '../assets/activities.json'; -import { ProjectDetails } from '../types/project'; -import { relativeTime } from '../utils/time'; +import activityDetails from '../../../assets/activities.json'; +import { ProjectDetails } from '../../../types/project'; +import { relativeTime } from '../../../utils/time'; interface OverviewProps { project: ProjectDetails; } -const Overview = ({ project }: OverviewProps) => ( +const OverviewTabPanel = ({ project }: OverviewProps) => (
@@ -54,4 +54,4 @@ const Overview = ({ project }: OverviewProps) => (
); -export default Overview; +export default OverviewTabPanel; diff --git a/packages/frontend/src/components/Tab.tsx b/packages/frontend/src/components/projects/project/ProjectTabs.tsx similarity index 77% rename from packages/frontend/src/components/Tab.tsx rename to packages/frontend/src/components/projects/project/ProjectTabs.tsx index 4b071610..b45e572b 100644 --- a/packages/frontend/src/components/Tab.tsx +++ b/packages/frontend/src/components/projects/project/ProjectTabs.tsx @@ -1,9 +1,10 @@ import React from 'react'; import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; -import Overview from './Overview'; -import Deployments from './Deployments'; -import { ProjectDetails } from '../types/project'; +import OverviewTabPanel from './OverviewTabPanel'; +import DeploymentsTabPanel from './DeploymentsTabPanel'; +import { ProjectDetails } from '../../../types/project'; +import SettingsTabPanel from './SettingsTabPanel'; interface ProjectTabsProps { project: ProjectDetails; @@ -26,15 +27,6 @@ const Integrations = () => (

); -const Settings = () => ( -
- Content of settings tab -

- It uses a dictionary of over 200 Latin words, combined with a handful of - model sentence. -

-
-); const ProjectTabs = ({ project }: ProjectTabsProps) => { return ( @@ -51,10 +43,10 @@ const ProjectTabs = ({ project }: ProjectTabsProps) => { Settings - + - + @@ -63,7 +55,7 @@ const ProjectTabs = ({ project }: ProjectTabsProps) => { - + ); diff --git a/packages/frontend/src/components/projects/project/SettingsTabPanel.tsx b/packages/frontend/src/components/projects/project/SettingsTabPanel.tsx new file mode 100644 index 00000000..e24626a1 --- /dev/null +++ b/packages/frontend/src/components/projects/project/SettingsTabPanel.tsx @@ -0,0 +1,83 @@ +import React, { createElement } from 'react'; + +import { + Tabs, + TabsHeader, + TabsBody, + Tab, + TabPanel, +} from '@material-tailwind/react'; + +import GeneralTabPanel from './settings/GeneralTabPanel'; + +const Domains = () => { + return
Domains
; +}; + +const EnvironmentVariables = () => { + return
Environment Variables
; +}; + +const Members = () => { + return
Members
; +}; + +const tabsData = [ + { + label: 'General', + icon: '^', + value: 'general', + component: GeneralTabPanel, + }, + { + label: 'Domains', + icon: '^', + value: 'domains', + component: Domains, + }, + { + label: 'Environment variables', + icon: '^', + value: 'environmentVariables', + component: EnvironmentVariables, + }, + { + label: 'Members', + icon: '^', + value: 'members', + component: Members, + }, +]; + +const SettingsTabPanel = () => { + return ( + <> + + + {tabsData.map(({ label, value, icon }) => ( + +
+
{icon}
+
{label}
+
+
+ ))} +
+ + {tabsData.map(({ value, component }) => ( + + {createElement(component)} + + ))} + +
+ + ); +}; + +export default SettingsTabPanel; diff --git a/packages/frontend/src/components/projects/project/settings/GeneralTabPanel.tsx b/packages/frontend/src/components/projects/project/settings/GeneralTabPanel.tsx new file mode 100644 index 00000000..32cfc9cd --- /dev/null +++ b/packages/frontend/src/components/projects/project/settings/GeneralTabPanel.tsx @@ -0,0 +1,76 @@ +import React from 'react'; +import { useForm } from 'react-hook-form'; + +import { Button } from '@material-tailwind/react'; +import { Input } from '@material-tailwind/react'; + +const GeneralTabPanel = () => { + const { handleSubmit, register } = useForm({ + defaultValues: { + appName: 'iglootools', + description: '', + }, + }); + + return ( +
{})}> +
+

Project info

+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ ); +}; + +export default GeneralTabPanel; diff --git a/packages/frontend/src/pages/projects/Project.tsx b/packages/frontend/src/pages/projects/Project.tsx index 37698041..f6e882b1 100644 --- a/packages/frontend/src/pages/projects/Project.tsx +++ b/packages/frontend/src/pages/projects/Project.tsx @@ -5,7 +5,7 @@ import { Button } from '@material-tailwind/react'; import HorizontalLine from '../../components/HorizontalLine'; import projects from '../../assets/projects.json'; -import ProjectTabs from '../../components/Tab'; +import ProjectTabs from '../../components/projects/project/ProjectTabs'; const getProject = (id: number) => { return projects.find((project) => { diff --git a/packages/frontend/src/pages/projects/create/Success.tsx b/packages/frontend/src/pages/projects/create/Success.tsx index 9873ceb8..d2fdd03b 100644 --- a/packages/frontend/src/pages/projects/create/Success.tsx +++ b/packages/frontend/src/pages/projects/create/Success.tsx @@ -1,7 +1,8 @@ import React from 'react'; -import { Button } from '@material-tailwind/react'; import { Link } from 'react-router-dom'; +import { Button } from '@material-tailwind/react'; + const Success = () => { return (
@@ -16,7 +17,7 @@ const Success = () => { Your project has been deployed at{' '} - ^www.iglootools.snowballtools.xyz + ^ www.iglootools.snowballtools.xyz