-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from jairuigou/main
feat: Add plugin management
- Loading branch information
Showing
24 changed files
with
5,305 additions
and
2,556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,6 @@ | |
# vendor/ | ||
|
||
.idea | ||
.vscode | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
transform :{ | ||
'^.+\\.(ts|tsx)?$': 'ts-jest', | ||
}, | ||
transformIgnorePatterns: ['<rootDir>/node_modules/'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import { Dropdown, Menu, MenuItem, Button } from '@kubed/components'; | ||
import { Trash, Success, More } from '@kubed/icons'; | ||
|
||
type Props = { | ||
triggerAuditHandler: () => void; | ||
uninstallHandler: () => void; | ||
}; | ||
|
||
const DropdownMenu = ({ triggerAuditHandler, uninstallHandler }: Props) => { | ||
const menu = ( | ||
<Menu style={{ width: '200px' }}> | ||
<MenuItem icon={<Success />} onClick={triggerAuditHandler}> | ||
启动巡检 | ||
</MenuItem> | ||
<MenuItem icon={<Trash />} onClick={uninstallHandler}> | ||
卸载 | ||
</MenuItem> | ||
</Menu> | ||
); | ||
|
||
return ( | ||
<Dropdown content={menu} placement="bottom-end"> | ||
<Button variant="text" radius="lg" size="sm"> | ||
<More size={16} /> | ||
</Button> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default DropdownMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
interface Props { | ||
src?: string; | ||
iconLetter: string; | ||
iconSize: number; | ||
} | ||
|
||
const DefaultImgIcon = styled.span<Props>` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
background-color: #eff4f9; | ||
border-radius: 4px; | ||
font-weight: bold; | ||
width: ${({ iconSize }) => iconSize}px; | ||
height: ${({ iconSize }) => iconSize}px; | ||
font-size: ${({ iconSize }) => iconSize / 2}px; | ||
padding: ${({ iconSize }) => iconSize / 4}px; | ||
line-height: ${({ iconSize }) => (iconSize / 2 > 12 ? iconSize / 2 : 12)}px; | ||
`; | ||
|
||
const Image = ({ src, iconLetter, iconSize }: Props) => { | ||
const [loadError, setLoadError] = useState(false); | ||
if (loadError || !src) { | ||
return ( | ||
<DefaultImgIcon iconLetter={iconLetter} iconSize={iconSize}> | ||
{iconLetter.substring(0, 1).toLocaleUpperCase()} | ||
</DefaultImgIcon> | ||
); | ||
} | ||
return ( | ||
<img | ||
src={src} | ||
onError={() => { | ||
setLoadError(true); | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default Image; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import { Button } from '@kubed/components'; | ||
import { Download, Trash } from '@kubed/icons'; | ||
import { InstallState } from '../../libs/types'; | ||
|
||
type Props = { | ||
state: InstallState; | ||
onClick: () => void; | ||
}; | ||
|
||
const InstallSwitch = ({ state, onClick }: Props) => { | ||
let loading: boolean; | ||
let content: string; | ||
let color: string; | ||
let icon = <Download color="white" size="13px" />; | ||
|
||
if (state === 'installing') { | ||
loading = true; | ||
content = '安装中'; | ||
color = 'secondary'; | ||
icon = <Download color="white" size="13px" />; | ||
} else if (state == 'uninstalling') { | ||
loading = true; | ||
content = '卸载中'; | ||
color = 'error'; | ||
icon = <Trash color="white" size="13px" />; | ||
} else if (state === 'installed') { | ||
loading = false; | ||
content = '卸载'; | ||
color = 'error'; | ||
icon = <Trash color="white" size="13px" />; | ||
} else { | ||
loading = false; | ||
content = '安装'; | ||
color = 'secondary'; | ||
icon = <Download color="white" size="13px" />; | ||
} | ||
|
||
return ( | ||
<Button | ||
variant="filled" | ||
color={color} | ||
leftIcon={icon} | ||
loading={loading} | ||
shadow | ||
onClick={onClick} | ||
> | ||
{content} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default InstallSwitch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.