This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Table Component * adjust spacing in story * put classes directly into tailwind table * add table test * added `xadmin` route for accessing the new admin panel * added surface main theme * improvements in tailwind table * Improve modal styles * Add Callout Text component * remove engine canvas and fix table style * Use popover state for modal * fix conflicts * Added copy text component * added project table data and fix pagination * added confirm dialog and fix border styles * added AddEditProjectModal dialog and Label component * added layout for update engine * added checkbox, select components wire up UpdateEngineModal * added functionalities for AddProject * add project submit * add multiple modal support * update project functionality * correct multiple modal rendering behavior * added toggle tailwind * added user permission modal * Add scrollbar to table * Add tooltip component tailwind doesnot seem to support nested pseudo element in styles, for eg: `hover:before:`. Hence, raw CSS is used here. TODO: to be updated with alternative implementation when found. * Show loading indicator when projects are being loaded * Improve Sidebar styles * regression on loading spinner * additional styles to table to accomodate max width --------- Co-authored-by: aditya-mitra <[email protected]>
- Loading branch information
1 parent
4a41fbf
commit 508e17c
Showing
44 changed files
with
3,038 additions
and
88 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
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
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
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
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,116 @@ | ||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
import { ThemeState } from '@etherealengine/client-core/src/common/services/ThemeService' | ||
import { useRemoveEngineCanvas } from '@etherealengine/client-core/src/hooks/useRemoveEngineCanvas' | ||
import PopupMenu from '@etherealengine/ui/src/primitives/tailwind/PopupMenu' | ||
import React, { useEffect } from 'react' | ||
import { | ||
HiArrowRightOnRectangle, | ||
HiCog8Tooth, | ||
HiCube, | ||
HiFolder, | ||
HiOutlineHome, | ||
HiOutlineMapPin, | ||
HiOutlineTableCells, | ||
HiPlay, | ||
HiServer, | ||
HiSquaresPlus, | ||
HiUser, | ||
HiUserCircle | ||
} from 'react-icons/hi2' | ||
import { RiSendPlaneFill } from 'react-icons/ri' | ||
import AdminProject from './components/project' | ||
|
||
const sideBarItems = [ | ||
{ label: 'Dashboard', icon: <HiOutlineHome /> }, | ||
{ label: 'Projects', icon: <HiOutlineTableCells /> }, | ||
{ label: 'Location', icon: <HiOutlineMapPin /> }, | ||
{ label: 'Instances', icon: <HiCube /> }, | ||
{ label: 'Servers', icon: <HiServer /> }, | ||
{ label: 'Avatars', icon: <HiUserCircle /> }, | ||
{ label: 'Plugins', icon: <HiSquaresPlus /> }, | ||
// {label: 'Teams', icon: <HiUsers />}, | ||
{ label: 'Users', icon: <HiUser /> }, | ||
{ label: 'Invites', icon: <RiSendPlaneFill /> }, | ||
{ label: 'Recordings', icon: <HiPlay /> }, | ||
{ label: 'Files', icon: <HiFolder /> }, | ||
{ label: 'Settings', icon: <HiCog8Tooth /> } | ||
] | ||
|
||
const AdminSidebar = () => { | ||
return ( | ||
<aside className="bg-theme-surfaceMain mx-8 min-w-[15vw] rounded-lg px-2 py-4"> | ||
<ul className="space-y-2"> | ||
{sideBarItems.map((item) => ( | ||
<li key={item.label}> | ||
<a | ||
href="#" | ||
className="text-theme-secondary flex items-center gap-3 rounded-xl px-2 py-3 hover:bg-[#212226]" | ||
> | ||
{item.icon} | ||
{item.label} | ||
</a> | ||
</li> | ||
))} | ||
<li> | ||
<a href="#" className="text-theme-secondary my-2 flex items-center rounded-sm px-2 py-3 hover:bg-[#212226]"> | ||
<HiArrowRightOnRectangle /> | ||
Log Out | ||
</a> | ||
</li> | ||
</ul> | ||
</aside> | ||
) | ||
} | ||
|
||
const Admin = () => { | ||
useRemoveEngineCanvas() | ||
useEffect(() => { | ||
ThemeState.setTheme('dark') | ||
}, []) | ||
return ( | ||
<main className="pointer-events-auto mt-6 flex gap-1.5"> | ||
{/* only for multitenancy | ||
<nav className="w-full px-8 py-4 mb-1.5 flex items-center justify-between bg-theme-surfaceMain"> | ||
<img src={EELogo} className="h-8 w-8" /> | ||
<div className="h-full flex items-center gap-8"> | ||
<Text theme='secondary'>Dashboard</Text> | ||
<div className='flex items-center border-b border-b-blue-400'><Text>Admin</Text></div> | ||
<Text theme='secondary'>Store</Text> | ||
<Text theme='secondary'>Documentation</Text> | ||
</div> | ||
<img src={EELogo} className="h-8 w-8" /> | ||
</nav> */} | ||
<AdminSidebar /> | ||
<div className="w-[80%]"> | ||
<AdminProject /> | ||
</div> | ||
<PopupMenu /> | ||
</main> | ||
) | ||
} | ||
|
||
export default Admin |
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,122 @@ | ||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
import React, { ReactNode } from 'react' | ||
import { HiArrowSmallDown, HiArrowSmallUp } from 'react-icons/hi2' | ||
|
||
import { FeathersOrder, useFind } from '@etherealengine/spatial/src/common/functions/FeathersHooks' | ||
import LoadingCircle from '@etherealengine/ui/src/primitives/tailwind/LoadingCircle' | ||
import Table, { | ||
TableBody, | ||
TableCell, | ||
TableHeadRow, | ||
TableHeaderCell, | ||
TablePagination, | ||
TableRow | ||
} from '@etherealengine/ui/src/primitives/tailwind/Table' | ||
|
||
export interface ITableHeadCell { | ||
id: string | number | ||
label: string | ||
sortable?: boolean | ||
className?: string | ||
} | ||
|
||
interface TableHeadProps { | ||
onRequestSort: (property: string | number, order: FeathersOrder) => void | ||
order: FeathersOrder | ||
orderBy: string | number | ||
columns: ITableHeadCell[] | ||
} | ||
|
||
const TableHead = ({ order, orderBy, onRequestSort, columns }: TableHeadProps) => { | ||
const SortArrow = ({ columnId }: { columnId: string | number }) => { | ||
if (columnId === orderBy) { | ||
if (order === 1) { | ||
return <HiArrowSmallUp onClick={() => onRequestSort(columnId, -1)} /> | ||
} | ||
return <HiArrowSmallDown onClick={() => onRequestSort(columnId, 1)} /> | ||
} | ||
return <HiArrowSmallUp className={'opacity-0 hover:opacity-50'} /> | ||
} | ||
|
||
return ( | ||
<TableHeadRow> | ||
{columns.map((column) => ( | ||
<TableHeaderCell key={column.id} className={column.className}> | ||
{column.sortable ? ( | ||
<span className="flex items-center gap-2"> | ||
{column.label} | ||
{<SortArrow columnId={column.id} />} | ||
</span> | ||
) : ( | ||
column.label | ||
)} | ||
</TableHeaderCell> | ||
))} | ||
</TableHeadRow> | ||
) | ||
} | ||
|
||
interface DataTableProps { | ||
query: ReturnType<typeof useFind> | ||
rows: Record<string | 'className' | 'id', string | ReactNode>[] | ||
columns: ITableHeadCell[] | ||
} | ||
|
||
const DataTable = ({ query, columns, rows }: DataTableProps) => { | ||
const [orderBy, order] = (Object.entries(query.sort)[0] as [string | number, FeathersOrder]) ?? ['', 0] | ||
|
||
return query.status !== 'success' ? ( | ||
<div className="flex h-96 w-full items-center justify-center"> | ||
<LoadingCircle className="flex w-1/4 items-center justify-center" /> | ||
</div> | ||
) : ( | ||
<Table> | ||
<TableHead | ||
order={order} | ||
orderBy={orderBy} | ||
onRequestSort={(property, order) => query.setSort({ [property]: order })} | ||
columns={columns} | ||
/> | ||
<TableBody> | ||
{rows.map((row, rowIdx) => ( | ||
<TableRow key={typeof row['id'] === 'string' ? row['id'] : rowIdx}> | ||
{columns.map((column, columnIdx) => ( | ||
<TableCell key={columnIdx}>{row[column.id]}</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
<TablePagination | ||
totalPages={Math.ceil(query.total / query.limit)} | ||
currentPage={query.page} | ||
onPageChange={(newPage) => query.setPage(newPage)} | ||
/> | ||
</Table> | ||
) | ||
} | ||
|
||
export default DataTable |
43 changes: 43 additions & 0 deletions
43
packages/client/src/pages/admin2/common/constants/project.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,43 @@ | ||
/* | ||
CPAL-1.0 License | ||
The contents of this file are subject to the Common Public Attribution License | ||
Version 1.0. (the "License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE. | ||
The License is based on the Mozilla Public License Version 1.1, but Sections 14 | ||
and 15 have been added to cover use of software over a computer network and | ||
provide for limited attribution for the Original Developer. In addition, | ||
Exhibit A has been modified to be consistent with Exhibit B. | ||
Software distributed under the License is distributed on an "AS IS" basis, | ||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the | ||
specific language governing rights and limitations under the License. | ||
The Original Code is Ethereal Engine. | ||
The Original Developer is the Initial Developer. The Initial Developer of the | ||
Original Code is the Ethereal Engine team. | ||
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023 | ||
Ethereal Engine. All Rights Reserved. | ||
*/ | ||
|
||
import { t } from 'i18next' | ||
import { ITableHeadCell } from '../Table' | ||
|
||
type IdType = 'name' | 'projectVersion' | 'commitSHA' | 'commitDate' | 'actions' | ||
|
||
export type ProjectRowType = Record<IdType, string | JSX.Element | undefined> | ||
|
||
interface IProjectColumn extends ITableHeadCell { | ||
id: IdType | ||
} | ||
|
||
export const projectsColumns: IProjectColumn[] = [ | ||
{ id: 'name', sortable: true, label: t('admin:components.project.columns.name') }, | ||
{ id: 'projectVersion', label: t('admin:components.project.columns.projectVersion') }, | ||
{ id: 'commitSHA', label: t('admin:components.project.columns.commitSHA') }, | ||
{ id: 'commitDate', sortable: true, label: t('admin:components.project.columns.commitDate') }, | ||
{ id: 'actions', label: t('admin:components.project.columns.actions') } | ||
] |
Oops, something went wrong.