Skip to content

Commit

Permalink
feat: add singleton mode support.
Browse files Browse the repository at this point in the history
refactor: docs upload page.

refactor: index setting page danger zone.
  • Loading branch information
riccox committed Oct 10, 2024
1 parent 98f3878 commit eab7baf
Show file tree
Hide file tree
Showing 34 changed files with 358 additions and 265 deletions.
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions src/components/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useMatchRoute } from '@tanstack/react-router';
import { useTranslation } from 'react-i18next';
import { Breadcrumbs, BreadcrumbItem } from '@nextui-org/react';
import { useAppStore } from '@/store';
import { isSingletonMode } from '@/utils/conn';

export const DashBreadcrumb = () => {
const matchRoute = useMatchRoute();
Expand All @@ -11,22 +12,21 @@ export const DashBreadcrumb = () => {
const insKeysRoute = matchRoute({ to: '/ins/$insID/keys', fuzzy: true }) as unknown as { insID: string };
const insTasksRoute = matchRoute({ to: '/ins/$insID/tasks', fuzzy: true }) as unknown as { insID: string };
const indexRoute = matchRoute({ to: '/ins/$insID/index/$indexUID', fuzzy: true }) as unknown as { indexUID: string };
const indexDocsRoute = matchRoute({ to: '/ins/$insID/index/$indexUID/documents', fuzzy: true }) as unknown as {
indexUID: string;
};
const indexSettingRoute = matchRoute({ to: '/ins/$insID/index/$indexUID/setting', fuzzy: true }) as unknown as {
indexUID: string;
};
const indexDocsRoute = matchRoute({ to: '/ins/$insID/index/$indexUID/documents', fuzzy: true });
const indexDocsUploadRoute = matchRoute({ to: '/ins/$insID/index/$indexUID/documents/upload', fuzzy: true });
const indexSettingRoute = matchRoute({ to: '/ins/$insID/index/$indexUID/setting', fuzzy: true });

const currentInstance = useAppStore((state) => state.instances.find((i) => i.id === parseInt(insRoute.insID)));

console.log(11, isSingletonMode());

return (
<Breadcrumbs color="primary" variant="light">
<BreadcrumbItem href={import.meta.env.BASE_URL ?? '/'}>🏠</BreadcrumbItem>
{!isSingletonMode() && <BreadcrumbItem href={import.meta.env.BASE_URL ?? '/'}>🏠</BreadcrumbItem>}
{insRoute && (
<BreadcrumbItem
href={`/ins/${insRoute.insID}`}
>{`#${insRoute.insID} ${t('common:instance')} ${currentInstance?.name}`}</BreadcrumbItem>
<BreadcrumbItem href={`/ins/${insRoute.insID}`}>
{isSingletonMode() ? '🏠' : `#${insRoute.insID} ${t('common:instance')} ${currentInstance?.name}`}
</BreadcrumbItem>
)}
{insKeysRoute && <BreadcrumbItem href={`/ins/${insRoute.insID}/keys`}>{`${t('common:keys')}`}</BreadcrumbItem>}
{insTasksRoute && <BreadcrumbItem href={`/ins/${insRoute.insID}/tasks`}>{`${t('common:tasks')}`}</BreadcrumbItem>}
Expand All @@ -40,6 +40,11 @@ export const DashBreadcrumb = () => {
href={`/ins/${insRoute.insID}/index/${indexRoute.indexUID}/documents`}
>{`${t('documents')}`}</BreadcrumbItem>
)}
{indexDocsUploadRoute && (
<BreadcrumbItem
href={`/ins/${insRoute.insID}/index/${indexRoute.indexUID}/documents/upload`}
>{`${t('upload:title')}`}</BreadcrumbItem>
)}
{indexSettingRoute && (
<BreadcrumbItem
href={`/ins/${insRoute.insID}/index/${indexRoute.indexUID}/setting`}
Expand Down
12 changes: 5 additions & 7 deletions src/components/Footer/Copyright.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import { useTranslation } from 'react-i18next';
export const Copyright: FC = () => {
const { t } = useTranslation('footer');
return (
<div className={``}>
<p>
{t('powered_by') + ' '}
<a className={`hover:underline`} href={`https://ricco.riccox.com`} target="_blank" rel="noreferrer">
Ricco Xie
</a>
</p>
<div className={`text-nowrap`}>
{t('powered_by') + ' '}
<a className={`hover:underline`} href={`https://ricco.riccox.com`} target="_blank" rel="noreferrer">
Ricco Xie
</a>
</div>
);
};
13 changes: 13 additions & 0 deletions src/components/Footer/Singleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { isSingletonMode } from '@/utils/conn';
import { Tag } from '@douyinfe/semi-ui';
import type { FC } from 'react';
import { useTranslation } from 'react-i18next';

export const Singleton: FC = () => {
const { t } = useTranslation('common');
if (!isSingletonMode()) {
return <></>;
} else {
return <Tag size="small">{t('singleton_mode')}</Tag>;
}
};
2 changes: 1 addition & 1 deletion src/components/Footer/Version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const Version: FC = () => {
const gitHash = __GIT_HASH__ || 'unknown';

return (
<span>
<span className="text-nowrap">
{t('common:version')}: {gitHash.slice(0, 7)}
</span>
);
Expand Down
5 changes: 4 additions & 1 deletion src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@ import type { FC } from 'react';
import { Copyright } from '@/components/Footer/Copyright';
import { LangSelector } from '../lang';
import { Version } from './Version';
import { Singleton } from './Singleton';
import { cn } from '@/lib/cn';

interface Props {
className?: string;
}

export const Footer: FC<Props> = ({ className = '' }) => {
return (
<div className={`${className} gap-x-2 flex justify-center w-full text-neutral-400 text-xs`}>
<div className={cn(`gap-2 flex justify-center items-center w-full text-neutral-400 text-xs`, className)}>
<Copyright /> -
<Version /> -
<a className={`hover:underline`} href={`//github.com/riccox/meilisearch-ui`} target="_blank" rel="noreferrer">
Github
</a>
-
<LangSelector />
<Singleton />
</div>
);
};
Loading

0 comments on commit eab7baf

Please sign in to comment.