Skip to content

Commit 9b5d5e8

Browse files
authored
fix(web): missing loading animation on project import when there's empty project list [VIZ-2289] [VIZ-2290] (#1837)
1 parent b93acb6 commit 9b5d5e8

File tree

6 files changed

+41
-28
lines changed

6 files changed

+41
-28
lines changed

web/src/app/features/Dashboard/ContentsContainer/Projects/hooks.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,23 @@ export default (workspaceId?: string) => {
258258
};
259259
}, [wrapperRef, contentRef]);
260260

261+
const fileInputRef = useRef<HTMLInputElement>(null);
262+
263+
const handleImportCompleted = useCallback(() => {
264+
if (fileInputRef.current) {
265+
fileInputRef.current.value = "";
266+
}
267+
}, [fileInputRef]);
268+
261269
const {
262270
importStatus,
263271
handleProjectImport,
264272
handleProjectImportErrorDownload,
265273
handleProjectImportErrorClose
266274
} = useProjectImport({
267275
workspaceId,
268-
refetchProjectList: refetch
276+
refetchProjectList: refetch,
277+
onImportCompleted: handleImportCompleted
269278
});
270279

271280
// project remove
@@ -306,6 +315,7 @@ export default (workspaceId?: string) => {
306315
contentWidth,
307316
starredProjects,
308317
importStatus,
318+
fileInputRef,
309319
projectVisibility,
310320
showProjectCreator,
311321
closeProjectCreator,

web/src/app/features/Dashboard/ContentsContainer/Projects/index.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import ManagerEmptyContent from "@reearth/app/ui/components/ManagerBase/ManagerE
1111
import { ProjectImportStatus } from "@reearth/services/gql";
1212
import { useT } from "@reearth/services/i18n";
1313
import { styled, useTheme } from "@reearth/services/theme";
14-
import { FC, useMemo, useRef, Fragment } from "react";
14+
import { FC, useMemo, Fragment } from "react";
1515

1616
import useHooks from "./hooks";
1717
import ProjectGridViewItem from "./Project/ProjectGridViewItem";
@@ -32,6 +32,7 @@ const Projects: FC<{ workspaceId?: string }> = ({ workspaceId }) => {
3232
searchTerm,
3333
sortValue,
3434
importStatus,
35+
fileInputRef,
3536
projectVisibility,
3637
showProjectCreator,
3738
closeProjectCreator,
@@ -61,7 +62,9 @@ const Projects: FC<{ workspaceId?: string }> = ({ workspaceId }) => {
6162
[t]
6263
);
6364

64-
const fileInputRef = useRef<HTMLInputElement>(null);
65+
const hasImportingProject =
66+
importStatus === ProjectImportStatus.Processing ||
67+
importStatus === ProjectImportStatus.Uploading;
6568

6669
return (
6770
<ManagerWrapper
@@ -110,7 +113,7 @@ const Projects: FC<{ workspaceId?: string }> = ({ workspaceId }) => {
110113
searchPlaceholder={t("Search project")}
111114
onSearch={handleSearch}
112115
/>
113-
{filtedProjects?.length ? (
116+
{filtedProjects?.length || hasImportingProject ? (
114117
<ManagerContent data-testid="projects-manager-content">
115118
<ContentWrapper>
116119
<BreadcrumbContainer data-testid="projects-breadcrumb-container">
@@ -187,12 +190,11 @@ const Projects: FC<{ workspaceId?: string }> = ({ workspaceId }) => {
187190
layout={layout}
188191
data-testid={`projects-group-${layout}`}
189192
>
190-
{(importStatus === ProjectImportStatus.Processing ||
191-
importStatus === ProjectImportStatus.Uploading) &&
193+
{hasImportingProject &&
192194
(layout === "grid" ? (
193195
<ImportingCardContainer>
194-
<ImportCardPlaceholder />
195-
<ImportingCardFotter />
196+
<ImportingCardPlaceholder />
197+
<ImportingCardFooter />
196198
</ImportingCardContainer>
197199
) : (
198200
<ImportingListContainer />
@@ -364,44 +366,42 @@ const HiddenFileInput = styled("input")({
364366
display: "none"
365367
});
366368

367-
const ImportingCardContainer = styled("div")(({ theme }) => ({
369+
const ImportingCardContainer = styled("div")(() => ({
368370
display: "flex",
369-
flexDirection: "column",
370-
gap: theme.spacing.small,
371-
height: "218px",
372-
"@media (max-width: 567px)": {
373-
height: "171px"
374-
}
371+
flexDirection: "column"
375372
}));
376373

377374
const shimmerEffect = {
378375
background:
379-
"linear-gradient(90deg, #292929 0%, #474747 33.04%, #474747 58.56%, #292929 100.09%)",
376+
"linear-gradient(90deg, #292929 0%, #474747 30%, #474747 60%, #292929 100%)",
380377
backgroundSize: "400% 100%",
381-
animation: "shimmer 1.2s infinite ease-in-out",
378+
animation: "shimmer 3s infinite linear",
382379
"@keyframes shimmer": {
383-
"0%": { backgroundPosition: "-400px 0" },
384-
"100%": { backgroundPosition: "400px 0" }
380+
"0%": { backgroundPosition: "400% 0" },
381+
"100%": { backgroundPosition: "0 0" }
385382
}
386383
};
387384

388385
const ImportingListContainer = styled("div")(({ theme }) => ({
389386
display: "flex",
390387
flexDirection: "column",
391388
gap: theme.spacing.small,
392-
height: "25px",
389+
height: "50px",
393390
borderRadius: theme.radius.normal,
394391
...shimmerEffect
395392
}));
396393

397-
const ImportCardPlaceholder = styled("div")(({ theme }) => ({
394+
const ImportingCardPlaceholder = styled("div")(({ theme }) => ({
398395
flex: 1,
399396
borderRadius: theme.radius.normal,
397+
minHeight: "188px",
400398
...shimmerEffect
401399
}));
402400

403-
const ImportingCardFotter = styled("div")(({ theme }) => ({
404-
height: "20px",
401+
const ImportingCardFooter = styled("div")(({ theme }) => ({
402+
height: "18px",
403+
marginTop: "7px",
404+
marginBottom: "7px",
405405
borderRadius: theme.radius.normal,
406406
flexShrink: 0,
407407
...shimmerEffect

web/src/app/features/Dashboard/ContentsContainer/Projects/useProjectImport.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import { ChangeEvent, useCallback, useEffect, useState } from "react";
99

1010
export default ({
1111
workspaceId,
12-
refetchProjectList
12+
refetchProjectList,
13+
onImportCompleted
1314
}: {
1415
workspaceId?: string;
1516
refetchProjectList: () => void;
17+
onImportCompleted?: () => void;
1618
}) => {
1719
const [, setNotification] = useNotification();
1820
const t = useT();
@@ -81,6 +83,7 @@ export default ({
8183
: undefined
8284
);
8385
clearInterval(interval);
86+
onImportCompleted?.();
8487
break;
8588
case ProjectImportStatus.Success:
8689
setNotification({
@@ -90,6 +93,7 @@ export default ({
9093
refetchProjectList();
9194
setImportStatus(ProjectImportStatus.None);
9295
clearInterval(interval);
96+
onImportCompleted?.();
9397
break;
9498
case ProjectImportStatus.Processing:
9599
case ProjectImportStatus.Uploading:
@@ -108,6 +112,7 @@ export default ({
108112
refetchProjectList,
109113
refetchProject,
110114
setNotification,
115+
onImportCompleted,
111116
t
112117
]);
113118

web/src/services/api/project/useProjectImportExportMutations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ export const useProjectImportExportMutations = () => {
152152
status: "uploaded",
153153
project_id: temporary_project
154154
};
155-
setNotification({ type: "success", text: t("Upload completed.") });
156155
} catch (error) {
157156
setNotification({
158157
type: "error",

web/src/services/i18n/translations/en.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,6 @@ Successfully uninstalled plugin.: ''
616616
Failed to export project.: ''
617617
Successfully exported project!: ''
618618
Failed to upload the file.: ''
619-
Upload completed.: ''
620619
Failed to upload chunk 0.: ''
621620
Failed to import project.: ''
622621
Failed to create project.: ''

web/src/services/i18n/translations/ja.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ Time: 時刻
580580
Time Zone: タイムゾーン
581581
Zoom Level Editor: ズームレベルエディター
582582
Member Limit Exceeded: メンバー上限を超えました
583-
This workspace has exceeded the member limit for its current plan. Editing is temporarily disabled for all members. Please ask the workspace owner to remove extra members or upgrade the plan to restore access.: このワークスペースは、現在のプランのメンバー上限を超えています。すべてのメンバーの編集が一時的に無効になっています。ワークスペースの所有者に、追加のメンバーを削除するか、プランをアップグレードしてアクセスを復元するよう依頼してください。
583+
This workspace has exceeded the member limit for its current plan. Editing is temporarily disabled for all members. Please ask the workspace owner to remove extra members or upgrade the plan to restore access.: >-
584+
このワークスペースは、現在のプランのメンバー上限を超えています。すべてのメンバーの編集が一時的に無効になっています。ワークスペースの所有者に、追加のメンバーを削除するか、プランをアップグレードしてアクセスを復元するよう依頼してください。
584585
Failed to add one or more assets.: アセットの追加に失敗しました。
585586
Successfully added one or more assets.: アセットの追加に成功しました。
586587
Failed to delete one or more assets.: アセットの削除に失敗しました。
@@ -621,7 +622,6 @@ Successfully uninstalled plugin.: プラグインのアンインストールに
621622
Failed to export project.: プロジェクトのエクスポートに失敗しました。
622623
Successfully exported project!: プロジェクトのエクスポートに成功しました!
623624
Failed to upload the file.: ファイルのアップロードに失敗しました。
624-
Upload completed.: アップロードが完了しました。
625625
Failed to upload chunk 0.: チャンク 0 のアップロードに失敗しました。
626626
Failed to import project.: プロジェクトのインポートに失敗しました。
627627
Failed to create project.: プロジェクトの作成に失敗しました。

0 commit comments

Comments
 (0)