This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip(frontend): refactor SelfService inner components into multiple co…
…mponents
- Loading branch information
Showing
3 changed files
with
78 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
frontend/src/components/self-service/SelfServiceTabRun.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import EmptyState from "@/components/common/EmptyState.tsx"; | ||
|
||
interface Props { | ||
catalogSlug: string | ||
} | ||
|
||
export default function SelfServiceTabRun({catalogSlug}: Props) { | ||
console.log(catalogSlug); | ||
|
||
return <> | ||
<div className="my-5"> | ||
<EmptyState text="No Runs" subText="This catalog has no runs"/> | ||
</div> | ||
</> | ||
} |
59 changes: 59 additions & 0 deletions
59
frontend/src/components/self-service/SelfServiceTabService.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import {useState} from "react"; | ||
import {TargetIcon} from "lucide-react"; | ||
import {TrashIcon} from "@heroicons/react/24/outline"; | ||
import EmptyState from "@/components/common/EmptyState.tsx"; | ||
import SelfServiceCard from "@/components/self-service/SelfServiceCard.tsx"; | ||
import {Transition} from "@headlessui/react"; | ||
import SelfServiceSlideOver from "@/components/self-service/SelfServiceSlideOver.tsx"; | ||
|
||
|
||
function getIcon(icon?: string): JSX.Element { | ||
switch (icon?.toLowerCase()) { | ||
case 'target': | ||
return <TargetIcon className="h-6 w-6" aria-hidden="true"/> | ||
case 'trash': | ||
return <TrashIcon className="h-6 w-6" aria-hidden="true"/> | ||
default: | ||
return <TargetIcon className="h-6 w-6" aria-hidden="true"/> | ||
} | ||
} | ||
|
||
interface Props { | ||
catalogSlug: string | ||
services: any[] | ||
} | ||
|
||
export default function SelfServiceTabService({catalogSlug, services}: Props) { | ||
const [showSideOver, setShowSideOver] = useState({show: false, service: {}}) // pass service | ||
|
||
if (services.length === 0) { | ||
return <div className="my-5"> | ||
<EmptyState text="No Fields" subText="This service has no fields."/> | ||
</div> | ||
} | ||
|
||
return <> | ||
<div className="my-5 divide-y divide-gray-200 overflow-hidden rounded-lg bg-gray-200 shadow sm:grid sm:grid-cols-3 sm:gap-px sm:divide-y-0"> | ||
{ | ||
services.map((service, idx) => { | ||
return <SelfServiceCard | ||
key={service.name} | ||
title={service.name} | ||
description={service.description} | ||
icon={getIcon(service.icon)} | ||
index={idx} | ||
totalCards={services.length} | ||
onClick={() => { | ||
setShowSideOver({show: true, service: service}) | ||
}}/> | ||
}) | ||
} | ||
</div> | ||
<Transition show={showSideOver.show}> | ||
<SelfServiceSlideOver service={showSideOver.service} onClose={() => setShowSideOver({ | ||
show: false, | ||
service: showSideOver.service | ||
})} catalogSlug={catalogSlug}/> | ||
</Transition> | ||
</> | ||
} |