Skip to content

Commit

Permalink
fix: fix file YSK Card open Action & YSK logo (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
CorrectRoadH authored Aug 8, 2024
1 parent 8437f88 commit 9d05bc2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 30 deletions.
30 changes: 21 additions & 9 deletions pkg/ysk/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ import (
)

type CartType string
type YSKCardIcon string

const (
CardTypeTask CartType = "task"
CardTypeLongNote CartType = "long-notice"
CardTypeShortNote CartType = "short-notice"
)

const (
FileIcon YSKCardIcon = "/modules/icewhale_files/appicon.svg"
DiskIcon YSKCardIcon = "/src/assets/img/storage/disk.png"
ZimaIcon YSKCardIcon = "/src/assets/img/zima.svg"
StorageIcon YSKCardIcon = "/src/assets/img/storage/storage.svg"
AppStoreIcon YSKCardIcon = "/src/assets/img/welcome/appstore.svg"
)

type RenderType string

const (
Expand All @@ -39,7 +48,12 @@ type YSKCard struct {
Content YSKCardContent `json:"content"`
}

func (ysk YSKCard) WithTaskContent(TitleIcon, TitleText string) YSKCard {
func (ysk YSKCard) WithId(id string) YSKCard {
ysk.Id = id
return ysk
}

func (ysk YSKCard) WithTaskContent(TitleIcon YSKCardIcon, TitleText string) YSKCard {
ysk.Content.TitleIcon = TitleIcon
ysk.Content.TitleText = TitleText
return ysk
Expand All @@ -57,7 +71,7 @@ func (yskCard YSKCard) WithProgress(label string, progress int) YSKCard {
}

type YSKCardContent struct {
TitleIcon string `json:"titleIcon" gorm:"column:title_icon"`
TitleIcon YSKCardIcon `json:"titleIcon" gorm:"column:title_icon"`
TitleText string `json:"titleText" gorm:"column:title_text"`
BodyProgress *YSKCardProgress `json:"bodyProgress,omitempty" gorm:"serializer:json"`
BodyIconWithText *YSKCardIconWithText `json:"bodyIconWithText,omitempty" gorm:"serializer:json"`
Expand All @@ -84,14 +98,14 @@ type YSKCardProgress struct {
}

type YSKCardIconWithText struct {
Icon string `json:"icon"`
Description string `json:"description"`
Icon YSKCardIcon `json:"icon"`
Description string `json:"description"`
}

type YSKCardListItem struct {
Icon string `json:"icon"`
Description string `json:"description"`
RightText string `json:"rightText"`
Icon YSKCardIcon `json:"icon"`
Description string `json:"description"`
RightText string `json:"rightText"`
}

type YSKCardFooterAction struct {
Expand All @@ -106,8 +120,6 @@ type YSKCardMessageBusAction struct {
Payload string `json:"payload"`
}

type YSKCardIcon = string

func ToCodegenYSKCard(card YSKCard) (codegen.YSKCard, error) {
jsonBody, err := json.Marshal(card)
if err != nil {
Expand Down
52 changes: 31 additions & 21 deletions utils/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var (
CardType: ysk.CardTypeTask,
RenderType: ysk.RenderTypeCardTask,
Content: ysk.YSKCardContent{
TitleIcon: "jellyfin logo",
TitleIcon: ysk.AppStoreIcon,
TitleText: "APP Installing",
BodyProgress: &ysk.YSKCardProgress{},
BodyIconWithText: nil,
Expand All @@ -24,22 +24,22 @@ var (
CardType: ysk.CardTypeLongNote,
RenderType: ysk.RenderTypeCardIconTextNotice,
Content: ysk.YSKCardContent{
TitleIcon: "ZimaOS-Logo",
TitleIcon: ysk.ZimaIcon,
TitleText: "Build data station",
BodyProgress: nil,
BodyIconWithText: &ysk.YSKCardIconWithText{
Icon: "disk",
Icon: ysk.DiskIcon,
Description: "For a data station with more storage capacity, it is recommended to add more hard drives.",
},
BodyList: nil,
FooterActions: []ysk.YSKCardFooterAction{
{
Side: ysk.ActionPositionLeft,
Side: ysk.ActionPositionRight,
Style: "primary",
Text: "Learn more",
MessageBus: ysk.YSKCardMessageBusAction{
Key: "casaos-ui/casaos-ui:app:mircoapp_communicate",
Payload: `{"access_id":"qWUS_pKWefbN-Bcxu3_nG","casaos_lang":"zh_cn","action":"open","peerType":"settings","name":"icewhale_settings","routerPath":"/storage"}`,
Payload: `{"action":"open","peerType":"settings","name":"icewhale_settings","routerPath":"/storage"}`,
},
},
},
Expand All @@ -51,22 +51,22 @@ var (
CardType: ysk.CardTypeLongNote,
RenderType: ysk.RenderTypeCardIconTextNotice,
Content: ysk.YSKCardContent{
TitleIcon: "ZimaOS-Logo",
TitleIcon: ysk.ZimaIcon,
TitleText: "Remote Access",
BodyProgress: nil,
BodyIconWithText: &ysk.YSKCardIconWithText{
Icon: "remote access",
Icon: ysk.ZimaIcon,
Description: "Configure Remote Access to access your home cloud remotely from anywhere.",
},
BodyList: nil,
FooterActions: []ysk.YSKCardFooterAction{
{
Side: ysk.ActionPositionLeft,
Side: ysk.ActionPositionRight,
Style: "primary",
Text: "Learn more",
MessageBus: ysk.YSKCardMessageBusAction{
Key: "casaos-ui/casaos-ui:app:mircoapp_communicate",
Payload: `{"access_id":"1733L6fM4PHol8kRssFvK","casaos_lang":"zh_cn","action":"open","peerType":"settings","name":"icewhale_settings","routerPath":"/network"}`,
Payload: `{"action":"open","peerType":"settings","name":"icewhale_settings","routerPath":"/network"}`,
},
},
},
Expand All @@ -78,22 +78,22 @@ var (
CardType: ysk.CardTypeLongNote,
RenderType: ysk.RenderTypeCardIconTextNotice,
Content: ysk.YSKCardContent{
TitleIcon: "ZimaOS-Logo",
TitleIcon: ysk.FileIcon,
TitleText: "File Management",
BodyProgress: nil,
BodyIconWithText: &ysk.YSKCardIconWithText{
Icon: "file management",
Icon: ysk.FileIcon,
Description: "Use Files to manage your data from different locations, such as your computer, phone, netdisk and server.",
},
BodyList: nil,
FooterActions: []ysk.YSKCardFooterAction{
{
Side: ysk.ActionPositionLeft,
Side: ysk.ActionPositionRight,
Style: "primary",
Text: "Learn more",
MessageBus: ysk.YSKCardMessageBusAction{
Key: "casaos-ui/casaos-ui:app:mircoapp_communicate",
Payload: "{'type':'file'}",
Key: "casaos-ui:open_files",
Payload: `{"url": "/modules/icewhale_files/#"}`,
},
},
},
Expand All @@ -105,7 +105,7 @@ var (
CardType: ysk.CardTypeShortNote,
RenderType: ysk.RenderTypeCardListNotice,
Content: ysk.YSKCardContent{
TitleIcon: "app store logo",
TitleIcon: ysk.AppStoreIcon,
TitleText: "有应用更新",
BodyList: []ysk.YSKCardListItem{
{
Expand All @@ -121,7 +121,7 @@ var (
},
FooterActions: []ysk.YSKCardFooterAction{
{
Side: ysk.ActionPositionLeft,
Side: ysk.ActionPositionRight,
Style: "primary",
Text: "更新所有",
MessageBus: ysk.YSKCardMessageBusAction{
Expand All @@ -138,20 +138,30 @@ var (
CardType: ysk.CardTypeLongNote,
RenderType: ysk.RenderTypeCardListNotice,
Content: ysk.YSKCardContent{
TitleIcon: "disk logo",
TitleText: "硬盘插入",
TitleIcon: ysk.ZimaIcon,
TitleText: "Found a new device",
BodyList: []ysk.YSKCardListItem{
{
Icon: "disk",
Icon: ysk.StorageIcon,
Description: "ZimaOS-HD",
RightText: "2TB",
}, {
Icon: "disk",
Icon: ysk.StorageIcon,
Description: "Safe-Storage",
RightText: "2TB",
},
},
FooterActions: nil,
FooterActions: []ysk.YSKCardFooterAction{
{
Side: ysk.ActionPositionRight,
Style: "primary",
Text: "Manage",
MessageBus: ysk.YSKCardMessageBusAction{
Key: "casaos-ui/casaos-ui:app:mircoapp_communicate",
Payload: `{"action":"open","peerType":"settings","name":"icewhale_settings","routerPath":"/storage"}`,
},
},
},
},
}
)

0 comments on commit 9d05bc2

Please sign in to comment.