-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2946 from thematters/develop
Release: v4.11.0
- Loading branch information
Showing
47 changed files
with
493 additions
and
147 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run format -- --list-different && \ | ||
npm run lint | ||
npm run lint |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "matters-web", | ||
"version": "4.10.0", | ||
"version": "4.11.0", | ||
"description": "codebase of Matters' website", | ||
"sideEffects": false, | ||
"author": "Matters <[email protected]>", | ||
|
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
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import _find from 'lodash/find' | ||
import _isEmpty from 'lodash/isEmpty' | ||
import _pickBy from 'lodash/pickBy' | ||
import _some from 'lodash/some' | ||
import { useContext } from 'react' | ||
|
||
import { | ||
|
@@ -16,7 +14,6 @@ import { | |
Menu, | ||
ShareDialog, | ||
Translate, | ||
useRoute, | ||
ViewerContext, | ||
} from '~/components' | ||
|
||
|
@@ -54,8 +51,12 @@ export interface DropdownActionsControls { | |
// based on type | ||
inCard?: boolean | ||
inUserArticles?: boolean | ||
inTagDetailLatest?: boolean | ||
inTagDetailSelected?: boolean | ||
|
||
// tag | ||
tagDetailId?: string | ||
hasSetTagSelected?: boolean | ||
hasSetTagUnselected?: boolean | ||
hasRemoveTag?: boolean | ||
|
||
morePublicActions?: React.ReactNode | ||
} | ||
|
@@ -73,7 +74,7 @@ interface Controls { | |
hasSticky: boolean | ||
hasArchive: boolean | ||
hasSetTagSelected: boolean | ||
hasSetTagUnSelected: boolean | ||
hasSetTagUnselected: boolean | ||
hasRemoveTag: boolean | ||
hasEdit: boolean | ||
} | ||
|
@@ -90,6 +91,7 @@ type BaseDropdownActionsProps = DropdownActionsProps & Controls & DialogProps | |
|
||
const BaseDropdownActions = ({ | ||
article, | ||
tagDetailId, | ||
|
||
icon, | ||
size, | ||
|
@@ -105,7 +107,7 @@ const BaseDropdownActions = ({ | |
hasSticky, | ||
hasArchive, | ||
hasSetTagSelected, | ||
hasSetTagUnSelected, | ||
hasSetTagUnselected, | ||
hasRemoveTag, | ||
hasEdit, | ||
|
||
|
@@ -128,7 +130,7 @@ const BaseDropdownActions = ({ | |
hasSticky || | ||
hasArchive || | ||
hasSetTagSelected || | ||
hasSetTagUnSelected || | ||
hasSetTagUnselected || | ||
hasRemoveTag | ||
|
||
const Content = ({ isInDropdown }: { isInDropdown?: boolean }) => ( | ||
|
@@ -150,9 +152,15 @@ const BaseDropdownActions = ({ | |
{hasSticky && <StickyButton article={article} />} | ||
|
||
{hasArchive && <ArchiveArticle.Button openDialog={openArchiveDialog} />} | ||
{hasSetTagSelected && <SetTagSelectedButton article={article} />} | ||
{hasSetTagUnSelected && <SetTagUnselectedButton article={article} />} | ||
{hasRemoveTag && <RemoveTagButton article={article} />} | ||
{hasSetTagSelected && tagDetailId && ( | ||
<SetTagSelectedButton article={article} tagId={tagDetailId} /> | ||
)} | ||
{hasSetTagUnselected && tagDetailId && ( | ||
<SetTagUnselectedButton article={article} tagId={tagDetailId} /> | ||
)} | ||
{hasRemoveTag && tagDetailId && ( | ||
<RemoveTagButton article={article} tagId={tagDetailId} /> | ||
)} | ||
{hasEdit && <EditButton article={article} />} | ||
</Menu> | ||
) | ||
|
@@ -195,29 +203,15 @@ const DropdownActions = (props: DropdownActionsProps) => { | |
|
||
inCard, | ||
inUserArticles, | ||
inTagDetailLatest, | ||
inTagDetailSelected, | ||
|
||
hasSetTagSelected, | ||
hasSetTagUnselected, | ||
hasRemoveTag, | ||
} = props | ||
const { getQuery } = useRoute() | ||
const viewer = useContext(ViewerContext) | ||
|
||
const isArticleAuthor = viewer.id === article.author.id | ||
const isActive = article.articleState === 'active' | ||
const isInTagDetail = inTagDetailLatest || inTagDetailSelected | ||
|
||
// check permission if in tag detail | ||
let canEditTag = false | ||
if (isInTagDetail) { | ||
const tagId = getQuery('tagId') | ||
const tag = _find(article.tags || [], (item) => item.id === tagId) | ||
const isEditor = _some( | ||
tag?.editors || [], | ||
(editor) => editor.id === viewer.id | ||
) | ||
const isCreator = tag?.creator?.id === viewer.id | ||
canEditTag = | ||
isEditor || isCreator || viewer.info.email === '[email protected]' | ||
} | ||
|
||
const forbid = () => { | ||
window.dispatchEvent( | ||
|
@@ -247,9 +241,9 @@ const DropdownActions = (props: DropdownActionsProps) => { | |
!viewer.isInactive | ||
), | ||
hasArchive: isArticleAuthor && isActive && !viewer.isArchived, | ||
hasSetTagSelected: !!(inTagDetailLatest && canEditTag), | ||
hasSetTagUnSelected: !!(inTagDetailSelected && canEditTag), | ||
hasRemoveTag: !!(isInTagDetail && canEditTag), | ||
hasSetTagSelected: !!hasSetTagSelected, | ||
hasSetTagUnselected: !!hasSetTagUnselected, | ||
hasRemoveTag: !!hasRemoveTag, | ||
hasEdit: isActive && isArticleAuthor, | ||
} | ||
|
||
|
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
Oops, something went wrong.