-
Notifications
You must be signed in to change notification settings - Fork 236
imprv: The delete button on the user home page is now hidden for unauthorized users. #9915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
e83f44c
68d5ee7
6f36ab2
054ae1e
29ecf94
a5f6584
7c63684
af4c526
3fe7cf7
37aff31
8fad48e
aad4d9c
5275fcc
79db193
40a9d05
69352d7
ad5da13
e46034f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ import type { | |
| import { | ||
| isIPageInfoForEntity, isIPageInfoForOperation, | ||
| } from '@growi/core'; | ||
| import { pagePathUtils } from '@growi/core/dist/utils'; | ||
| import { useRect } from '@growi/ui/dist/utils'; | ||
| import { useTranslation } from 'next-i18next'; | ||
| import { DropdownItem } from 'reactstrap'; | ||
|
|
@@ -17,7 +18,9 @@ import { | |
| } from '~/client/services/page-operation'; | ||
| import { toastError } from '~/client/util/toastr'; | ||
| import OpenDefaultAiAssistantButton from '~/features/openai/client/components/AiAssistant/OpenDefaultAiAssistantButton'; | ||
| import { useIsGuestUser, useIsReadOnlyUser, useIsSearchPage } from '~/stores-universal/context'; | ||
| import { | ||
| useIsGuestUser, useIsReadOnlyUser, useIsSearchPage, useIsUsersHomepageDeletionEnabled, | ||
| } from '~/stores-universal/context'; | ||
| import { | ||
| EditorMode, useEditorMode, | ||
| } from '~/stores-universal/ui'; | ||
|
|
@@ -27,7 +30,7 @@ import { | |
| } from '~/stores/ui'; | ||
| import loggerFactory from '~/utils/logger'; | ||
|
|
||
| import { useSWRxPageInfo, useSWRxTagsInfo } from '../../../stores/page'; | ||
| import { useSWRxPageInfo, useSWRxTagsInfo, useCurrentPagePath } from '../../../stores/page'; | ||
| import { useSWRxUsersList } from '../../../stores/user'; | ||
| import type { AdditionalMenuItemsRendererProps, ForceHideMenuItems } from '../Common/Dropdown/PageItemControl'; | ||
| import { | ||
|
|
@@ -134,6 +137,10 @@ const PageControlsSubstance = (props: PageControlsSubstanceProps): JSX.Element = | |
| const { data: editorMode } = useEditorMode(); | ||
| const { data: isDeviceLargerThanMd } = useIsDeviceLargerThanMd(); | ||
| const { data: isSearchPage } = useIsSearchPage(); | ||
| const { data: isUsersHomepageDeletionEnabled } = useIsUsersHomepageDeletionEnabled(); | ||
| const { data: currentPagePath } = useCurrentPagePath(); | ||
|
|
||
| const isUsersHomepage = currentPagePath == null ? false : pagePathUtils.isUsersHomepage(currentPagePath); | ||
|
|
||
| const { mutate: mutatePageInfo } = useSWRxPageInfo(pageId, shareLinkId); | ||
|
|
||
|
|
@@ -249,6 +256,18 @@ const PageControlsSubstance = (props: PageControlsSubstanceProps): JSX.Element = | |
| } | ||
| }, [expandContentWidth, isGuestUser, isReadOnlyUser, onClickSwitchContentWidth, pageId, pageInfo]); | ||
|
|
||
| const isEnableActions = useMemo(() => { | ||
| if (isGuestUser) { | ||
| return false; | ||
| } | ||
|
|
||
| if (isUsersHomepage && !isUsersHomepageDeletionEnabled) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| }, [isGuestUser, isUsersHomepage, isUsersHomepageDeletionEnabled]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currentPagePath が取得できていない (null) 場合を考慮してください 以下 AI の説明
const isUsersHomepage = pagePathUtils.isUsersHomepage(currentPagePath ?? '');ここで どうなるか?
結果として
要約
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currentPagePath はなにか、を本質的に考えないといけない currentPagePath が取得できないということは、システムグローバルに「今何のページを表示しているのか」を特定できていないということだ。 修正案currentPagePath が取得できていない場合は |
||
|
|
||
| const additionalMenuItemOnTopRenderer = useMemo(() => { | ||
| if (!isIPageInfoForEntity(pageInfo)) { | ||
| return undefined; | ||
|
|
@@ -332,7 +351,7 @@ const PageControlsSubstance = (props: PageControlsSubstanceProps): JSX.Element = | |
| <PageItemControl | ||
| pageId={pageId} | ||
| pageInfo={pageInfo} | ||
| isEnableActions={!isGuestUser} | ||
| isEnableActions={isEnableActions} | ||
| isReadOnlyUser={!!isReadOnlyUser} | ||
| forceHideMenuItems={forceHideMenuItemsWithAdditions} | ||
| additionalMenuItemOnTopRenderer={!isReadOnlyUser ? additionalMenuItemOnTopRenderer : undefined} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.