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 <neeraj.rtly@gmail.com>
This commit is contained in:
Nabarun Gogoi 2023-12-20 10:16:10 +05:30 committed by GitHub
parent 0b91771e90
commit c0a20c80a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 181 additions and 29 deletions

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { relativeTime } from '../utils/time'; import { relativeTime } from '../../../utils/time';
interface ActivityDetails { interface ActivityDetails {
author: string; author: string;

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { relativeTime } from '../utils/time'; import { relativeTime } from '../../../utils/time';
interface DeploymentDetails { interface DeploymentDetails {
title: string; title: string;

View File

@ -1,15 +1,15 @@
import React from 'react'; import React from 'react';
import deploymentDetails from '../assets/deployments.json'; import deploymentDetails from '../../../assets/deployments.json';
import DeployDetailsCard from './DeploymentDetailsCard'; import DeployDetailsCard from './DeploymentDetailsCard';
import Dropdown from './Dropdown'; import Dropdown from '../../Dropdown';
const STATUS_OPTIONS = [ const STATUS_OPTIONS = [
{ value: 'production', label: 'Production' }, { value: 'production', label: 'Production' },
{ value: 'preview', label: 'Preview' }, { value: 'preview', label: 'Preview' },
]; ];
const Deployments = () => { const DeploymentsTabPanel = () => {
return ( return (
<div className="p-4"> <div className="p-4">
<div className="grid grid-cols-4 gap-2 text-sm text-gray-600"> <div className="grid grid-cols-4 gap-2 text-sm text-gray-600">
@ -44,4 +44,4 @@ const Deployments = () => {
); );
}; };
export default Deployments; export default DeploymentsTabPanel;

View File

@ -1,15 +1,15 @@
import React from 'react'; import React from 'react';
import ActivityCard from './ActivityCard'; import ActivityCard from './ActivityCard';
import activityDetails from '../assets/activities.json'; import activityDetails from '../../../assets/activities.json';
import { ProjectDetails } from '../types/project'; import { ProjectDetails } from '../../../types/project';
import { relativeTime } from '../utils/time'; import { relativeTime } from '../../../utils/time';
interface OverviewProps { interface OverviewProps {
project: ProjectDetails; project: ProjectDetails;
} }
const Overview = ({ project }: OverviewProps) => ( const OverviewTabPanel = ({ project }: OverviewProps) => (
<div className="grid grid-cols-5"> <div className="grid grid-cols-5">
<div className="col-span-3 p-2"> <div className="col-span-3 p-2">
<div className="flex items-center gap-2 p-2 "> <div className="flex items-center gap-2 p-2 ">
@ -54,4 +54,4 @@ const Overview = ({ project }: OverviewProps) => (
</div> </div>
); );
export default Overview; export default OverviewTabPanel;

View File

@ -1,9 +1,10 @@
import React from 'react'; import React from 'react';
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
import Overview from './Overview'; import OverviewTabPanel from './OverviewTabPanel';
import Deployments from './Deployments'; import DeploymentsTabPanel from './DeploymentsTabPanel';
import { ProjectDetails } from '../types/project'; import { ProjectDetails } from '../../../types/project';
import SettingsTabPanel from './SettingsTabPanel';
interface ProjectTabsProps { interface ProjectTabsProps {
project: ProjectDetails; project: ProjectDetails;
@ -26,15 +27,6 @@ const Integrations = () => (
</p> </p>
</div> </div>
); );
const Settings = () => (
<div>
Content of settings tab
<p className="block">
It uses a dictionary of over 200 Latin words, combined with a handful of
model sentence.
</p>
</div>
);
const ProjectTabs = ({ project }: ProjectTabsProps) => { const ProjectTabs = ({ project }: ProjectTabsProps) => {
return ( return (
@ -51,10 +43,10 @@ const ProjectTabs = ({ project }: ProjectTabsProps) => {
<Tab className={'p-2 cursor-pointer'}>Settings</Tab> <Tab className={'p-2 cursor-pointer'}>Settings</Tab>
</TabList> </TabList>
<TabPanel> <TabPanel>
<Overview project={project} /> <OverviewTabPanel project={project} />
</TabPanel> </TabPanel>
<TabPanel> <TabPanel>
<Deployments /> <DeploymentsTabPanel />
</TabPanel> </TabPanel>
<TabPanel> <TabPanel>
<Database /> <Database />
@ -63,7 +55,7 @@ const ProjectTabs = ({ project }: ProjectTabsProps) => {
<Integrations /> <Integrations />
</TabPanel> </TabPanel>
<TabPanel> <TabPanel>
<Settings /> <SettingsTabPanel />
</TabPanel> </TabPanel>
</Tabs> </Tabs>
); );

View File

@ -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 <div>Domains</div>;
};
const EnvironmentVariables = () => {
return <div>Environment Variables</div>;
};
const Members = () => {
return <div>Members</div>;
};
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 (
<>
<Tabs value={'general'} orientation="vertical" className="my-6">
<TabsHeader
className="w-60 bg-transparent"
indicatorProps={{
className: 'bg-gray-900/10 shadow-none !text-gray-900',
}}
>
{tabsData.map(({ label, value, icon }) => (
<Tab key={value} value={value} className="flex justify-start">
<div className="flex gap-2">
<div>{icon}</div>
<div>{label}</div>
</div>
</Tab>
))}
</TabsHeader>
<TabsBody>
{tabsData.map(({ value, component }) => (
<TabPanel key={value} value={value} className="p-2">
{createElement(component)}
</TabPanel>
))}
</TabsBody>
</Tabs>
</>
);
};
export default SettingsTabPanel;

View File

@ -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 (
<form onSubmit={handleSubmit(() => {})}>
<div className="mb-4">
<h4>Project info</h4>
</div>
<div className="my-2 w-3/5">
<label
htmlFor="input"
className="block text-sm font-medium text-gray-800"
>
App name
</label>
<Input
id="input"
variant="outlined"
// TODO: Debug issue: https://github.com/creativetimofficial/material-tailwind/issues/427
crossOrigin={undefined}
size="md"
{...register('appName')}
/>
</div>
<div className="my-2 w-3/5">
<label
htmlFor="input"
className="block text-sm font-medium text-gray-800"
>
Description (Optional)
</label>
<Input
id="input"
variant="outlined"
crossOrigin={undefined}
size="md"
{...register('description')}
/>
</div>
<div className="my-2 w-3/5">
<label
htmlFor="input"
className="block text-sm font-medium text-gray-800"
>
Project ID
</label>
<Input
id="input"
crossOrigin={undefined}
variant="outlined"
value="62f87575-7a2b-4951-8156-9f9821j380d"
size="md"
disabled
/>
</div>
<div>
<Button type="submit" variant="gradient" size="sm">
Save
</Button>
</div>
</form>
);
};
export default GeneralTabPanel;

View File

@ -5,7 +5,7 @@ import { Button } from '@material-tailwind/react';
import HorizontalLine from '../../components/HorizontalLine'; import HorizontalLine from '../../components/HorizontalLine';
import projects from '../../assets/projects.json'; import projects from '../../assets/projects.json';
import ProjectTabs from '../../components/Tab'; import ProjectTabs from '../../components/projects/project/ProjectTabs';
const getProject = (id: number) => { const getProject = (id: number) => {
return projects.find((project) => { return projects.find((project) => {

View File

@ -1,7 +1,8 @@
import React from 'react'; import React from 'react';
import { Button } from '@material-tailwind/react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Button } from '@material-tailwind/react';
const Success = () => { const Success = () => {
return ( return (
<div className="flex justify-center"> <div className="flex justify-center">
@ -16,7 +17,7 @@ const Success = () => {
Your project has been deployed at{' '} Your project has been deployed at{' '}
<Link to="https://www.iglootools.snowballtools.xyz"> <Link to="https://www.iglootools.snowballtools.xyz">
<span className="text-blue-600"> <span className="text-blue-600">
^www.iglootools.snowballtools.xyz ^ www.iglootools.snowballtools.xyz
</span> </span>
</Link> </Link>
</span> </span>