Răsfoiți Sursa

create not available for read only user

ryoji-s 2 ani în urmă
părinte
comite
a0755d042d

+ 2 - 6
apps/app/src/components/NotAvailableForGuest.tsx

@@ -2,23 +2,19 @@ import React from 'react';
 
 import { useTranslation } from 'next-i18next';
 
-import { useIsGuestUser, useIsReadOnlyUser } from '~/stores/context';
+import { useIsGuestUser } from '~/stores/context';
 
 import { NotAvailable } from './NotAvailable';
 
-
 type NotAvailableForGuestProps = {
   children: JSX.Element
 }
 
-// TODO: Update NotAvailableForGuest to be used even when isReadOnlyUser
-// https://redmine.weseek.co.jp/issues/121331
 export const NotAvailableForGuest = React.memo(({ children }: NotAvailableForGuestProps): JSX.Element => {
   const { t } = useTranslation();
   const { data: isGuestUser } = useIsGuestUser();
-  const { data: isReadOnlyUser } = useIsReadOnlyUser();
 
-  const isDisabled = !!isGuestUser || !!isReadOnlyUser;
+  const isDisabled = !!isGuestUser;
   const title = t('Not available for guest');
 
   return (

+ 28 - 0
apps/app/src/components/NotAvailableForReadOnlyUser.tsx

@@ -0,0 +1,28 @@
+import React from 'react';
+
+import { useTranslation } from 'next-i18next';
+
+import { useIsReadOnlyUser } from '~/stores/context';
+
+import { NotAvailable } from './NotAvailable';
+
+export const NotAvailableForReadOnlyUser: React.FC<{
+  children: JSX.Element
+}> = React.memo(({ children }) => {
+  const { t } = useTranslation();
+  const { data: isReadOnlyUser } = useIsReadOnlyUser();
+
+  const isDisabled = !!isReadOnlyUser;
+  const title = t('Not available for read only user');
+
+  return (
+    <NotAvailable
+      isDisabled={isDisabled}
+      title={title}
+      classNamePrefix="grw-not-available-for-read-only-user"
+    >
+      {children}
+    </NotAvailable>
+  );
+});
+NotAvailableForReadOnlyUser.displayName = 'NotAvailableForReadOnlyUser';