Skip to content

Commit

Permalink
chore(web): format
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Sep 12, 2022
1 parent 4dde800 commit 61d4b10
Show file tree
Hide file tree
Showing 15 changed files with 86 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,14 @@ const AddNewPluginContent: React.FC<Props> = ({
</Col>
<Col>
<Space size="middle">
<Button
type="default"
size="large"
onClick={handleClickSave}
loading={isSaveLoading}
>
<Button type="default" size="large" onClick={handleClickSave} loading={isSaveLoading}>
Save
</Button>
<Button
type="primary"
size="large"
onClick={handleClickPublish}
loading={isPublishLoading}
>
loading={isPublishLoading}>
Publish
</Button>
</Space>
Expand All @@ -79,8 +73,7 @@ const AddNewPluginContent: React.FC<Props> = ({
defaultActiveKey={currentTab}
tabBarStyle={{ margin: 0 }}
activeKey={currentTab}
onChange={handleClickDetailSetting}
>
onChange={handleClickDetailSetting}>
<TabPane tab="Package" key="1">
<PackageArea
githubUrl={githubUrl}
Expand Down
33 changes: 12 additions & 21 deletions web/src/components/molecules/AddNewPluginPage/PackageArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const PackageArea: React.FC<Props> = ({
handleParsePlugin,
handleChangeGithubUrl,
}) => {
const [currentRadio, changeRadio] = useState<
"Upload from local" | "GitHub repository"
>("Upload from local");
const [currentRadio, changeRadio] = useState<"Upload from local" | "GitHub repository">(
"Upload from local",
);
const handleChangeRadio = (e: RadioChangeEvent) => {
changeRadio(e.target.value);
};
Expand All @@ -43,12 +43,8 @@ const PackageArea: React.FC<Props> = ({
<Row justify="start">
<Col>
<Radio.Group onChange={handleChangeRadio} value={currentRadio}>
<Radio.Button value="Upload from local">
Upload from local
</Radio.Button>
<Radio.Button value="GitHub repository">
GitHub repository
</Radio.Button>
<Radio.Button value="Upload from local">Upload from local</Radio.Button>
<Radio.Button value="GitHub repository">GitHub repository</Radio.Button>
</Radio.Group>
</Col>
</Row>
Expand All @@ -60,39 +56,34 @@ const PackageArea: React.FC<Props> = ({
accept=".zip"
maxCount={1}
multiple={false}
beforeUpload={(file) => {
beforeUpload={file => {
const isZip = file.type === "application/zip";
if (!isZip) {
Message.error(`${file.name} is not a zip file`);
}
return isZip || Upload.LIST_IGNORE;
}}
customRequest={(info) => handleParsePlugin(info.file)}
onChange={(info) => {
customRequest={info => handleParsePlugin(info.file)}
onChange={info => {
const { status } = info.file;
if (status === "done") {
Message.success(
`${info.file.name} file uploaded successfully.`
);
Message.success(`${info.file.name} file uploaded successfully.`);
} else if (status === "error") {
Message.error(`${info.file.name} file upload failed.`);
}
}}
>
}}>
<p className="ant-upload-drag-icon">
<Icon icon="inbox" />
</p>
<p className="ant-upload-hint">
Click or drag file to this area to upload
</p>
<p className="ant-upload-hint">Click or drag file to this area to upload</p>
</Dragger>
</UploadArea>
) : (
<>
<Input
placeholder="github.com/xxx/xxx"
value={githubUrl}
onChange={(e) => {
onChange={e => {
handleChangeGithubUrl(e.target.value);
}}
/>
Expand Down
12 changes: 3 additions & 9 deletions web/src/components/molecules/AddNewPluginPage/SettingArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ export type Props = {
description: string;
handleUploadImages: (image: UploadRequestOption) => void;
};
const SettingArea: React.FC<Props> = ({
pluginName,
version,
description,
handleUploadImages,
}) => {
const SettingArea: React.FC<Props> = ({ pluginName, version, description, handleUploadImages }) => {
return (
<Wrapper>
<Space direction="vertical" size="middle" style={{ width: "100%" }}>
Expand All @@ -32,12 +27,11 @@ const SettingArea: React.FC<Props> = ({
<Upload
listType="picture"
accept="image/png, image/jpeg, image/jpg"
customRequest={(image) => {
customRequest={image => {
handleUploadImages(image);
}}
defaultFileList={[]}
multiple
>
multiple>
<Button icon={<Icon icon="upload" />} type="primary" ghost>
Upload Image
</Button>
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/molecules/MyPluginsPage/MyPluginsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const MyPluginsTable: React.FC<Props> = ({ data, handlePublishClick }) => {
title: "Plugin Name",
dataIndex: "name",
key: "name",
render: (text) => <BoldTitle>{text}</BoldTitle>,
render: text => <BoldTitle>{text}</BoldTitle>,
},
{
title: "Status",
Expand Down Expand Up @@ -62,7 +62,7 @@ const MyPluginsTable: React.FC<Props> = ({ data, handlePublishClick }) => {
title: "Action",
key: "action",
dataIndex: "id",
render: (id) => {
render: id => {
return (
<Row justify="space-around" style={{ maxWidth: "200px" }}>
{/* <Col>
Expand Down
3 changes: 1 addition & 2 deletions web/src/components/molecules/PluginsListCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const PluginsListCard: React.FC<Props> = ({
size="small"
bordered={false}
onClick={onClick}
bodyStyle={{ padding: "4px 0" }}
>
bodyStyle={{ padding: "4px 0" }}>
<Row justify="space-between" align="top">
<AuthorName>{author}</AuthorName>
<Space size="small">
Expand Down
74 changes: 35 additions & 39 deletions web/src/components/molecules/SearchArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,38 @@ export type Props = {
// },
// ];

const orderMenuItems: Array<{ label: string; key: number; value: PluginSort }> =
[
{
label: "ダウンロード数降順",
key: 1,
value: PluginSort.DownloadsAsc,
},
{
label: "ダウンロード数昇順",
key: 2,
value: PluginSort.DownloadsDesc,
},
{
label: "名前降順",
key: 3,
value: PluginSort.NameAsc,
},
{
label: "名前昇順",
key: 4,
value: PluginSort.NameDesc,
},
{
label: "公開日降順",
key: 5,
value: PluginSort.PublishedatAsc,
},
{
label: "公開日昇順",
key: 6,
value: PluginSort.PublishedatDesc,
},
];
const orderMenuItems: Array<{ label: string; key: number; value: PluginSort }> = [
{
label: "ダウンロード数降順",
key: 1,
value: PluginSort.DownloadsAsc,
},
{
label: "ダウンロード数昇順",
key: 2,
value: PluginSort.DownloadsDesc,
},
{
label: "名前降順",
key: 3,
value: PluginSort.NameAsc,
},
{
label: "名前昇順",
key: 4,
value: PluginSort.NameDesc,
},
{
label: "公開日降順",
key: 5,
value: PluginSort.PublishedatAsc,
},
{
label: "公開日昇順",
key: 6,
value: PluginSort.PublishedatDesc,
},
];

const SearchArea: React.FC<Props> = ({
onSearch,
Expand All @@ -74,14 +73,12 @@ const SearchArea: React.FC<Props> = ({
// updateDisplayMenuState(Number(e.key));
// };

const handleOrderMenuClick: MenuProps["onClick"] = (e) => {
const handleOrderMenuClick: MenuProps["onClick"] = e => {
updateOrderMenuState(Number(e.key));
};

// const displayMenu = <Menu onClick={handleDisplayMenuClick} items={displayMenuItems} />;
const orderMenu = (
<Menu onClick={handleOrderMenuClick} items={orderMenuItems} />
);
const orderMenu = <Menu onClick={handleOrderMenuClick} items={orderMenuItems} />;

return (
<StyledSpace size={16}>
Expand All @@ -106,8 +103,7 @@ const SearchArea: React.FC<Props> = ({
{isLoggedIn ? (
<Button
onClick={() => handleFavButtonClick(!isFavSelected)}
style={{ color: isFavSelected ? "#f57c4b" : "" }}
>
style={{ color: isFavSelected ? "#f57c4b" : "" }}>
<Space size="small">
お気に入り
<Icon icon="heart" />
Expand Down
4 changes: 1 addition & 3 deletions web/src/components/molecules/TopPage/TopPageContents.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import PluginsList, {
Plugin,
} from "@marketplace/components/molecules/PluginsList";
import PluginsList, { Plugin } from "@marketplace/components/molecules/PluginsList";
import SearchArea from "@marketplace/components/molecules/SearchArea";
import { styled } from "@marketplace/theme";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ const UpdatePluginContent: React.FC<Props> = ({
defaultActiveKey={currentTab}
tabBarStyle={{ margin: 0 }}
activeKey={currentTab}
onChange={handleClickDetailSetting}
>
onChange={handleClickDetailSetting}>
<TabPane tab="Package" key="1">
<PackageArea
githubUrl={githubUrl}
Expand Down
15 changes: 6 additions & 9 deletions web/src/components/organisms/AddNewPlugin/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Message from "@marketplace/components/atoms/Message";
import type { FileUploadType } from "@marketplace/components/molecules/AddNewPluginPage/PackageArea";
import {
useCreatePluginMutation,
useParsePluginMutation,
useUpdatePluginMutation,
} from "@marketplace/gql";
import { useCallback, useMemo } from "react";
import Message from "@marketplace/components/atoms/Message";

export default () => {
const [parsePluginMutation, { data: parsedData }] = useParsePluginMutation();
Expand All @@ -22,7 +22,7 @@ export default () => {
onError: () => Message.error(`Something went wrong on saving`),
});
},
[createPluginMutation]
[createPluginMutation],
);

const handleParsePluginMutation = useCallback(
Expand All @@ -33,13 +33,10 @@ export default () => {
repo: data.repo && data.repo,
},
onCompleted: () => Message.success("Your file is successfully loaded"),
onError: () =>
Message.error(
`Something went wrong on your ${data.file ? "File" : "URL"}`
),
onError: () => Message.error(`Something went wrong on your ${data.file ? "File" : "URL"}`),
});
},
[parsePluginMutation]
[parsePluginMutation],
);

const handleUpdatePluginMutation = useCallback(
Expand All @@ -54,7 +51,7 @@ export default () => {
onError: () => Message.error(`Something went wrong on updating`),
});
},
[updatePluginMutation]
[updatePluginMutation],
);

const parsedPlugin = useMemo(
Expand All @@ -73,7 +70,7 @@ export default () => {
: "",
}
: undefined,
[parsedData?.parsePlugin.plugin]
[parsedData?.parsePlugin.plugin],
);

return {
Expand Down
3 changes: 2 additions & 1 deletion web/src/components/organisms/AddNewPlugin/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Message from "@marketplace/components/atoms/Message";
import AddNewPluginPage from "@marketplace/components/molecules/AddNewPluginPage";
import type { FileUploadType } from "@marketplace/components/molecules/AddNewPluginPage/PackageArea";
import { UploadRequestOption } from "rc-upload/lib/interface";
import { useState } from "react";

import useHooks from "./hooks";
import Message from "@marketplace/components/atoms/Message";

export type Props = {};
const AddNewPlugin: React.FC<Props> = () => {
Expand Down
8 changes: 4 additions & 4 deletions web/src/components/organisms/Top/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default (searchText?: string, sort?: PluginSort, liked?: boolean) => {
});
await refetch();
},
[likePlugin, refetch]
[likePlugin, refetch],
);

const onUnlike = useCallback(
Expand All @@ -46,7 +46,7 @@ export default (searchText?: string, sort?: PluginSort, liked?: boolean) => {
});
await refetch();
},
[unlikePlugin, refetch]
[unlikePlugin, refetch],
);

const plugins = useMemo(
Expand All @@ -62,10 +62,10 @@ export default (searchText?: string, sort?: PluginSort, liked?: boolean) => {
like: p.like,
downloads: p.downloads,
}
: undefined
: undefined,
)
.filter((p): p is Plugin => !!p),
[data?.plugins]
[data?.plugins],
);

return {
Expand Down
Loading

0 comments on commit 61d4b10

Please sign in to comment.