Skip to content

Commit

Permalink
Merge pull request #3745 from illacloud/fix/bugs_0305_02
Browse files Browse the repository at this point in the history
fix: 🐛 select created resource & change subpage
  • Loading branch information
AruSeito authored Mar 5, 2024
2 parents a7a5148 + b44b33e commit 414c378
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
ILLA_MIXPANEL_BUILDER_PAGE_NAME,
MixpanelTrackProvider,
} from "@illa-public/mixpanel-utils"
import { getInitialContent } from "@illa-public/public-configs"
import { Resource } from "@illa-public/public-types"
import {
ACTION_MODAL_WIDTH,
Expand All @@ -13,7 +14,11 @@ import { FC, useState } from "react"
import { useTranslation } from "react-i18next"
import { useDispatch, useSelector } from "react-redux"
import { Modal, Space, TriggerProvider } from "@illa-design/react"
import { getCachedAction } from "@/redux/config/configSelector"
import {
getCachedAction,
getSelectedAction,
} from "@/redux/config/configSelector"
import { configActions } from "@/redux/config/configSlice"
import { getAllResources } from "@/redux/resource/resourceSelector"
import { resourceActions } from "@/redux/resource/resourceSlice"
import { track } from "@/utils/mixpanelHelper"
Expand All @@ -33,17 +38,31 @@ const PanelHeader: FC = () => {
const resourceList = useSelector(getAllResources)

const action = useSelector(getCachedAction)!!
const selectedAction = useSelector(getSelectedAction)!!

const dispatch = useDispatch()

const createOrUpdateResourceCallback = (
resource: Resource,
isUpdate: boolean,
) => {
setEditorVisible(false)
setGeneratorVisible(false)
if (isUpdate) {
dispatch(resourceActions.updateResourceItemReducer(resource))
} else {
dispatch(resourceActions.addResourceItemReducer(resource))
dispatch(
configActions.updateCachedAction({
...action,
actionType: resource.resourceType,
resourceID: resource.resourceID,
content:
selectedAction.actionType === resource.resourceType
? selectedAction.content
: getInitialContent(resource.resourceType),
}),
)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export const getCurrentDisplayName = (
sectionViewConfigs: any[],
viewSortedKey: string[],
defaultViewKey: string,
defaultViewPath: string,
isProduction: boolean,
viewPath: string | undefined,
currentViewIndex: number,
) => {
if (!Array.isArray(sectionViewConfigs) || !Array.isArray(viewSortedKey))
return "sub-page1"
const defaultedViewConfig = sectionViewConfigs.find(
(item) => item.key === defaultViewKey,
(item) => item.path === defaultViewPath,
)
const defaultedViewKey = viewSortedKey.includes(
defaultedViewConfig?.viewDisplayName,
Expand Down

0 comments on commit 414c378

Please sign in to comment.