DatabasesTab.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { useContext } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import RouteTabList from '@/components/customTabList/RouteTabList';
  4. import Properties from './collections/properties/Properties';
  5. import { authContext } from '@/context';
  6. import Collections from './collections/Collections';
  7. import type { ITab } from '@/components/customTabList/Types';
  8. // Database tab pages
  9. export const DatabasesTab = (props: {
  10. databasePage: string; // current database page
  11. databaseName: string;
  12. tabClass: string; // tab class
  13. }) => {
  14. // context
  15. const { isManaged } = useContext(authContext);
  16. const { databaseName, tabClass, databasePage } = props;
  17. const { t: collectionTrans } = useTranslation('collection');
  18. const dbTab: ITab[] = [
  19. {
  20. label: collectionTrans('collections'),
  21. component: <Collections />,
  22. path: `collections`,
  23. },
  24. ];
  25. if (!isManaged) {
  26. dbTab.push({
  27. label: collectionTrans('properties'),
  28. component: <Properties type="database" target={databaseName} />,
  29. path: `properties`,
  30. });
  31. }
  32. const actionDbTab = dbTab.findIndex(t => t.path === databasePage);
  33. return (
  34. <RouteTabList
  35. tabs={dbTab}
  36. wrapperClass={tabClass}
  37. activeIndex={actionDbTab !== -1 ? actionDbTab : 0}
  38. />
  39. );
  40. };