Skip to content

Commit

Permalink
Merge branch 'feat/app' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
echoxyc committed Jul 6, 2023
2 parents b2422ec + 79d83ea commit 9028f2b
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const AppCard: FC<AppCardProps> = (props) => {
{canEditApp ? (
<Button
size="small"
variant="text"
colorScheme="grayBlue"
leftIcon={<PenIcon />}
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fetchCopyApp } from "@/services/apps"
import { BASIC_APP_CONFIG } from "@/config/newAppConfig"
import { fetchCopyApp, fetchCreateApp } from "@/services/apps"

const APP_NAME_MAX_LENGTH = 128
const COPY_SUFFIX = " Copy"
Expand All @@ -7,3 +8,10 @@ export const duplicateApp = (appId: string, appName?: string) => {
const newAppName = `${(appName || "").slice(0, trimmedLength)}${COPY_SUFFIX}`
return fetchCopyApp(appId, newAppName)
}

export const createApp = (appName = "Untitled app") => {
return fetchCreateApp({
appName,
initScheme: BASIC_APP_CONFIG,
})
}
44 changes: 41 additions & 3 deletions apps/builder/src/page/Dashboard/DashboardApps/contentBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import { FC, useEffect, useMemo } from "react"
import { useDispatch, useSelector } from "react-redux"
import { useAsyncValue, useNavigate, useParams } from "react-router-dom"
import useMeasure from "react-use-measure"
import { Empty, List } from "@illa-design/react"
import {
Button,
Empty,
EmptyIcon,
List,
PlusIcon,
globalColor,
illaPrefix,
} from "@illa-design/react"
import {
ILLA_MIXPANEL_BUILDER_PAGE_NAME,
ILLA_MIXPANEL_EVENT_TYPE,
Expand All @@ -15,16 +23,19 @@ import { track } from "@/utils/mixpanelHelper"
import {
CARD_GAP_SIZE,
CARD_WIDTH,
emptyStyle,
fullWidthStyle,
listContainerStyle,
} from "./style"

interface AppsContentBodyProps {
canEditApp: boolean
loading: boolean
onCreatedApp: () => void
}

export const AppsContentBody: FC<AppsContentBodyProps> = (props) => {
const { canEditApp } = props
const { canEditApp, loading, onCreatedApp } = props
const { data: appsList } = useAsyncValue() as {
data: DashboardApp[]
}
Expand Down Expand Up @@ -120,7 +131,34 @@ export const AppsContentBody: FC<AppsContentBodyProps> = (props) => {
}}
/>
)}
{finalAppsList.length == 0 && <Empty paddingVertical="120px" />}
{finalAppsList.length === 0 && (
<Empty
paddingVertical="120px"
icon={
<EmptyIcon
size="48px"
color={globalColor(`--${illaPrefix}-grayBlue-02`)}
/>
}
description={
<div css={emptyStyle}>
<div>Empty</div>
<div>
<Button
colorScheme="grayBlue"
loading={loading}
leftIcon={<PlusIcon />}
onClick={() => {
onCreatedApp()
}}
>
Create your first app
</Button>
</div>
</div>
}
/>
)}
</div>
)
}
23 changes: 12 additions & 11 deletions apps/builder/src/page/Dashboard/DashboardApps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useNavigate,
useParams,
} from "react-router-dom"
import { Button, useMessage } from "@illa-design/react"
import { Button, PlusIcon, useMessage } from "@illa-design/react"
import { BASIC_APP_CONFIG } from "@/config/newAppConfig"
import { Avatar } from "@/illa-public-component/Avatar"
import {
Expand Down Expand Up @@ -73,7 +73,10 @@ export const DashboardApps: FC = () => {
ACTION_MANAGE.CREATE_APP,
)

const createApp = useCallback(() => {
const handleCreateApp = useCallback(() => {
track(ILLA_MIXPANEL_EVENT_TYPE.CLICK, ILLA_MIXPANEL_BUILDER_PAGE_NAME.APP, {
element: "create_new_app",
})
if (loading) return
setLoading(true)
fetchCreateApp({
Expand Down Expand Up @@ -156,15 +159,9 @@ export const DashboardApps: FC = () => {
<Button
ml="4px"
colorScheme="techPurple"
leftIcon={<PlusIcon />}
loading={loading}
onClick={() => {
track(
ILLA_MIXPANEL_EVENT_TYPE.CLICK,
ILLA_MIXPANEL_BUILDER_PAGE_NAME.APP,
{ element: "create_new_app" },
)
createApp()
}}
onClick={handleCreateApp}
>
{t("create_new_app")}
</Button>
Expand All @@ -173,7 +170,11 @@ export const DashboardApps: FC = () => {
</div>
<Suspense fallback={<DashBoardLoading />}>
<Await resolve={appList} errorElement={<DashboardErrorElement />}>
<AppsContentBody canEditApp={canEditApp} />
<AppsContentBody
canEditApp={canEditApp}
onCreatedApp={handleCreateApp}
loading={loading}
/>
</Await>
</Suspense>
</div>
Expand Down
11 changes: 11 additions & 0 deletions apps/builder/src/page/Dashboard/DashboardApps/style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,14 @@ export const hoverStyle = css`
}
}
`

export const emptyStyle: SerializedStyles = css`
padding: 8px;
display: flex;
flex-direction: column;
gap: 8px;
justify-content: center;
color: ${globalColor(`--${illaPrefix}-grayBlue-02`)};
font-weight: 600;
line-height: 22px;
`

0 comments on commit 9028f2b

Please sign in to comment.