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(web): publish multiple items #1295

Merged
merged 4 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 0 additions & 7 deletions web/src/components/molecules/Asset/AssetListTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,6 @@ const AssetListTable: React.FC<Props> = ({
(props: any) => {
return (
<Space size={4}>
<Button
type="link"
size="small"
icon={<Icon icon="clear" />}
onClick={props.onCleanSelected}>
{t("Deselect")}
</Button>
<DownloadButton
displayDefaultIcon
size="small"
Expand Down
6 changes: 6 additions & 0 deletions web/src/components/molecules/Content/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Props = {
contentTableFields?: ContentTableField[];
loading: boolean;
deleteLoading: boolean;
publishLoading: boolean;
unpublishLoading: boolean;
contentTableColumns?: ExtendedColumns[];
modelsMenu: React.ReactNode;
Expand All @@ -45,6 +46,7 @@ type Props = {
onSearchTerm: (term?: string) => void;
onFilterChange: (filter?: ConditionInput[]) => void;
onContentTableChange: (page: number, pageSize: number, sorter?: ItemSort) => void;
onPublish: (itemIds: string[]) => Promise<void>;
onUnpublish: (itemIds: string[]) => Promise<void>;
onItemSelect: (itemId: string) => void;
setSelectedItems: (input: { selectedRows: { itemId: string; version?: string }[] }) => void;
Expand Down Expand Up @@ -72,6 +74,7 @@ const ContentListMolecule: React.FC<Props> = ({
modelsMenu,
loading,
deleteLoading,
publishLoading,
unpublishLoading,
selectedItem,
selectedItems,
Expand All @@ -88,6 +91,7 @@ const ContentListMolecule: React.FC<Props> = ({
requestModalTotalCount,
requestModalPage,
requestModalPageSize,
onPublish,
onUnpublish,
onAddItemToRequest,
onAddItemToRequestModalClose,
Expand Down Expand Up @@ -145,9 +149,11 @@ const ContentListMolecule: React.FC<Props> = ({
pageSize={pageSize}
loading={loading}
deleteLoading={deleteLoading}
publishLoading={publishLoading}
unpublishLoading={unpublishLoading}
selectedItem={selectedItem}
selectedItems={selectedItems}
onPublish={onPublish}
onUnpublish={onUnpublish}
onSearchTerm={onSearchTerm}
onFilterChange={onFilterChange}
Expand Down
49 changes: 41 additions & 8 deletions web/src/components/molecules/Content/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import CustomTag from "@reearth-cms/components/atoms/CustomTag";
import Dropdown, { MenuProps } from "@reearth-cms/components/atoms/Dropdown";
import Icon from "@reearth-cms/components/atoms/Icon";
import Input from "@reearth-cms/components/atoms/Input";
import Modal from "@reearth-cms/components/atoms/Modal";
import {
TableRowSelection,
ListToolBarProps,
Expand Down Expand Up @@ -56,6 +57,7 @@ type Props = {
contentTableColumns?: ExtendedColumns[];
loading: boolean;
deleteLoading: boolean;
publishLoading: boolean;
unpublishLoading: boolean;
selectedItem?: Item;
selectedItems: { selectedRows: { itemId: string; version?: string }[] };
Expand All @@ -77,6 +79,7 @@ type Props = {
setSelectedItems: (input: { selectedRows: { itemId: string; version?: string }[] }) => void;
onItemEdit: (itemId: string) => void;
onItemDelete: (itemIds: string[]) => Promise<void>;
onPublish: (itemIds: string[]) => Promise<void>;
onUnpublish: (itemIds: string[]) => Promise<void>;
onItemsReload: () => void;
requests: Request[];
Expand All @@ -94,6 +97,7 @@ const ContentTable: React.FC<Props> = ({
contentTableColumns,
loading,
deleteLoading,
publishLoading,
unpublishLoading,
selectedItem,
selectedItems,
Expand All @@ -113,6 +117,7 @@ const ContentTable: React.FC<Props> = ({
onAddItemToRequest,
onAddItemToRequestModalClose,
onAddItemToRequestModalOpen,
onPublish,
onUnpublish,
onSearchTerm,
onFilterChange,
Expand Down Expand Up @@ -289,11 +294,37 @@ const ContentTable: React.FC<Props> = ({
[selectedItems, setSelectedItems],
);

const publishConfirm = useCallback(
(itemIds: string[]) => {
Modal.confirm({
title: t("Publish items"),
content: t("All selected items will be published. You can unpublish them anytime."),
icon: <Icon icon="exclamationCircle" />,
cancelText: t("No"),
okText: t("Yes"),
async onOk() {
await onPublish(itemIds);
},
});
},
[onPublish, t],
);
caichi-t marked this conversation as resolved.
Show resolved Hide resolved

const alertOptions = useCallback(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(props: any) => {
return (
<Space size={4}>
<Button
type="link"
size="small"
icon={<Icon icon="upload" />}
onClick={() => {
publishConfirm(props.selectedRowKeys);
}}
loading={publishLoading}>
{t("Publish")}
</Button>
caichi-t marked this conversation as resolved.
Show resolved Hide resolved
<Button
type="link"
size="small"
Expand All @@ -309,13 +340,6 @@ const ContentTable: React.FC<Props> = ({
loading={unpublishLoading}>
{t("Unpublish")}
</Button>
<Button
type="link"
size="small"
icon={<Icon icon="clear" />}
onClick={props.onCleanSelected}>
{t("Deselect")}
</Button>
<Button
type="link"
size="small"
Expand All @@ -328,7 +352,16 @@ const ContentTable: React.FC<Props> = ({
</Space>
);
},
[deleteLoading, onAddItemToRequestModalOpen, onItemDelete, onUnpublish, t, unpublishLoading],
[
deleteLoading,
onAddItemToRequestModalOpen,
onItemDelete,
onUnpublish,
publishConfirm,
publishLoading,
t,
unpublishLoading,
],
);

const defaultFilterValues = useRef<DefaultFilterValueType[]>([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@ const IntegrationTable: React.FC<Props> = ({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(props: any) => (
<Space size={4}>
<Button
type="link"
size="small"
icon={<Icon icon="clear" />}
onClick={props.onCleanSelected}>
{t("Deselect")}
</Button>
<Button
type="link"
size="small"
Expand Down
7 changes: 0 additions & 7 deletions web/src/components/molecules/Request/Table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,6 @@ const RequestListTable: React.FC<Props> = ({
(props: any) => {
return (
<Space size={4}>
<Button
type="link"
size="small"
icon={<Icon icon="clear" />}
onClick={props.onCleanSelected}>
{t("Deselect")}
</Button>
<Button
type="link"
size="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default () => {
currentProject,
requests,
addItemToRequestModalShown,
handlePublish,
handleUnpublish,
handleAddItemToRequest,
handleAddItemToRequestModalClose,
Expand All @@ -70,6 +71,7 @@ export default () => {
handleRequestSearchTerm,
handleRequestTableReload,
loading: requestModalLoading,
publishLoading,
unpublishLoading,
totalCount: requestModalTotalCount,
page: requestModalPage,
Expand Down Expand Up @@ -527,6 +529,7 @@ export default () => {
currentModel,
loading,
deleteLoading,
publishLoading,
unpublishLoading,
contentTableFields,
contentTableColumns,
Expand All @@ -548,6 +551,7 @@ export default () => {
requestModalTotalCount,
requestModalPage,
requestModalPageSize,
handlePublish,
handleUnpublish,
handleBulkAddItemToRequest,
handleAddItemToRequestModalClose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ContentList: React.FC = () => {
selectedItems,
loading,
deleteLoading,
publishLoading,
unpublishLoading,
totalCount,
views,
Expand All @@ -35,6 +36,7 @@ const ContentList: React.FC = () => {
requestModalPage,
requestModalPageSize,
handleBulkAddItemToRequest: handleAddItemToRequest,
handlePublish,
handleUnpublish,
handleAddItemToRequestModalClose,
handleAddItemToRequestModalOpen,
Expand Down Expand Up @@ -97,6 +99,7 @@ const ContentList: React.FC = () => {
collapsed={collapsedModelMenu}
loading={loading}
deleteLoading={deleteLoading}
publishLoading={publishLoading}
unpublishLoading={unpublishLoading}
currentView={currentView}
setCurrentView={setCurrentView}
Expand All @@ -118,6 +121,7 @@ const ContentList: React.FC = () => {
onCollapse={collapseModelMenu}
onItemsReload={handleItemsReload}
onItemEdit={handleNavigateToItemEditForm}
onPublish={handlePublish}
onUnpublish={handleUnpublish}
onItemDelete={handleItemDelete}
onItemAdd={handleNavigateToItemForm}
Expand Down
7 changes: 4 additions & 3 deletions web/src/i18n/translations/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Status: ''
Created At: ''
ID: ''
input search text: ''
Deselect: ''
Delete: ''
Upload Asset: ''
Auto Unzip: ''
Expand Down Expand Up @@ -176,6 +175,10 @@ is not empty: ''
Ascending: ''
Descending: ''
Confirm: ''
Publish items: ''
All selected items will be published. You can unpublish them anytime.: ''
'No': ''
'Yes': ''
Filter: ''
Add Filter: ''
Add Sort: ''
Expand Down Expand Up @@ -210,8 +213,6 @@ Please input the appropriate role for this member!: ''
Are you sure to remove these members?: ''
Are you sure to remove this member?: ''
Remove this member from workspace means this member will not view any content of this workspace.: ''
'Yes': ''
'No': ''
Are you sure to leave this workspace?: ''
Leave this workspace means you will not view any content of this workspace.: ''
Thumbnail: ''
Expand Down
7 changes: 4 additions & 3 deletions web/src/i18n/translations/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Status: ステータス
Created At: 作成日時
ID: ''
input search text: 検索
Deselect: 選択解除
Delete: 削除
Upload Asset: アセットをアップロード
Auto Unzip: 自動解凍
Expand Down Expand Up @@ -176,6 +175,10 @@ is not empty: 空でない
Ascending: 昇順
Descending: 降順
Confirm: 確認
Publish items: アイテムを公開
All selected items will be published. You can unpublish them anytime.: 選択したアイテムはすべて公開されます。アイテムはいつでも非公開にすることができます。
'No': いいえ
'Yes': はい
caichi-t marked this conversation as resolved.
Show resolved Hide resolved
Filter: フィルター
Add Filter: 絞り込む
Add Sort: 並び替える
Expand Down Expand Up @@ -210,8 +213,6 @@ Please input the appropriate role for this member!: このメンバーに付与
Are you sure to remove these members?: 本当にこれらのメンバーをワークスペースから削除してもよろしいですか?
Are you sure to remove this member?: 本当にこのメンバーをワークスペースから削除してもよろしいですか?
Remove this member from workspace means this member will not view any content of this workspace.: メンバーをワークスペースから削除すると、そのメンバーはワークスペース内のいかなるコンテンツも閲覧することができなくなります。
'Yes': はい
'No': いいえ
Are you sure to leave this workspace?: 本当にこのワークスペースを離れてもよろしいですか?
Leave this workspace means you will not view any content of this workspace.: ワークスペースを離れると、ワークスペース内のいかなるコンテンツも閲覧することができなくなります。
Thumbnail: サムネイル
Expand Down
Loading