Skip to content
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

feat: Add a button to open PageCreateModal in the new page creation lead #8774

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/app/public/static/locales/en_US/commons.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

"create_page_dropdown": {
"new_page": "Create New Page",
"open_page_create_modal": "Open new page create modal",
"todays": {
"desc": "Create today's memo",
"memo": "memo"
Expand Down
1 change: 1 addition & 0 deletions apps/app/public/static/locales/fr_FR/commons.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

"create_page_dropdown": {
"new_page": "Créer nouvelle page",
"open_page_create_modal": "Ouvrir une nouvelle page créer une fenêtre modale",
"todays": {
"desc": "Créer le mémo du jour",
"memo": "mémo"
Expand Down
1 change: 1 addition & 0 deletions apps/app/public/static/locales/ja_JP/commons.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

"create_page_dropdown": {
"new_page": "新規ページ作成",
"open_page_create_modal": "新規ページ作成モーダルを表示",
"todays": {
"desc": "今日のメモを作成",
"memo": "メモ"
Expand Down
1 change: 1 addition & 0 deletions apps/app/public/static/locales/zh_CN/commons.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@

"create_page_dropdown": {
"new_page": "新页面",
"open_page_create_modal": "打开新页面创建模式",
"todays": {
"desc": "Create today's memo",
"memo": "memo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { LabelType } from '~/interfaces/template';

type DropendMenuProps = {
onClickCreateNewPage: () => Promise<void>
onClickOpenPageCreateModal: () => void
onClickCreateTodaysMemo: () => Promise<void>
onClickCreateTemplate?: (label: LabelType) => Promise<void>
todaysPath: string | null,
Expand All @@ -16,6 +17,7 @@ type DropendMenuProps = {
export const DropendMenu = React.memo((props: DropendMenuProps): JSX.Element => {
const {
onClickCreateNewPage,
onClickOpenPageCreateModal,
onClickCreateTodaysMemo,
onClickCreateTemplate,
todaysPath,
Expand All @@ -34,6 +36,13 @@ export const DropendMenu = React.memo((props: DropendMenuProps): JSX.Element =>
{t('create_page_dropdown.new_page')}
</DropdownItem>

<DropdownItem
onClick={onClickOpenPageCreateModal}
>
{t('create_page_dropdown.open_page_create_modal')}
</DropdownItem>


{ todaysPath != null && (
<>
<DropdownItem divider />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Dropdown } from 'reactstrap';

import { useCreateTemplatePage } from '~/client/services/create-page';
import { useToastrOnError } from '~/client/services/use-toastr-on-error';
import { usePageCreateModal } from '~/stores/modal';
import { useCurrentPagePath } from '~/stores/page';

import { CreateButton } from './CreateButton';
import { DropendMenu } from './DropendMenu';
Expand All @@ -16,6 +18,9 @@ export const PageCreateButton = React.memo((): JSX.Element => {

const [dropdownOpen, setDropdownOpen] = useState(false);

const { open: openPageCreateModal } = usePageCreateModal();
const { data: currentPagePath } = useCurrentPagePath();

const { createNewPage, isCreating: isNewPageCreating } = useCreateNewPage();
// TODO: https://redmine.weseek.co.jp/issues/138806
const { createTodaysMemo, isCreating: isTodaysPageCreating, todaysPath } = useCreateTodaysMemo();
Expand Down Expand Up @@ -64,6 +69,7 @@ export const PageCreateButton = React.memo((): JSX.Element => {
<DropendToggle />
<DropendMenu
onClickCreateNewPage={createNewPageWithToastr}
onClickOpenPageCreateModal={() => openPageCreateModal(currentPagePath)}
onClickCreateTodaysMemo={createTodaysMemoWithToastr}
onClickCreateTemplate={isTemplatePageCreatable ? createTemplateWithToastr : undefined}
todaysPath={todaysPath}
Expand Down
Loading