diff --git a/ui/.eslintrc.js b/ui/.eslintrc.js index c327641d..709d3e31 100644 --- a/ui/.eslintrc.js +++ b/ui/.eslintrc.js @@ -10,6 +10,7 @@ module.exports = { ], rules: { "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-empty-interface": "off" }, }; \ No newline at end of file diff --git a/ui/src/views/Repo.tsx b/ui/src/views/Repo.tsx index 81cf7687..63f50fec 100644 --- a/ui/src/views/Repo.tsx +++ b/ui/src/views/Repo.tsx @@ -10,7 +10,7 @@ import { init, activate, repoSlice as slice } from '../redux/repo' import ActivateButton from "../components/ActivateButton" import Main from './main' import RepoHome from './repoHome' -import RepoLock from "./RepoLock"; +import RepoLock from "./repoLock" import RepoDeploy from './RepoDeploy' import RepoRollabck from './RepoRollback' import RepoSettings from "./repoSettings" diff --git a/ui/src/components/LockList.tsx b/ui/src/views/repoLock/LockList.tsx similarity index 95% rename from ui/src/components/LockList.tsx rename to ui/src/views/repoLock/LockList.tsx index 2dd7cc60..1bd6a7fc 100644 --- a/ui/src/components/LockList.tsx +++ b/ui/src/views/repoLock/LockList.tsx @@ -6,10 +6,10 @@ import { import { LockOutlined, UnlockOutlined } from "@ant-design/icons" import moment from 'moment' -import { Env, Lock } from "../models" -import UserAvatar from './UserAvatar' +import { Env, Lock } from "../../models" +import UserAvatar from '../../components/UserAvatar' -interface LockListProps { +export interface LockListProps { envs: Env[] locks: Lock[] onClickLock(env: string): void diff --git a/ui/src/views/RepoLock.tsx b/ui/src/views/repoLock/index.tsx similarity index 72% rename from ui/src/views/RepoLock.tsx rename to ui/src/views/repoLock/index.tsx index 4bcdca00..40fa0b05 100644 --- a/ui/src/views/RepoLock.tsx +++ b/ui/src/views/repoLock/index.tsx @@ -4,18 +4,18 @@ import { useParams } from "react-router-dom"; import { PageHeader, Button } from 'antd' import { Result } from "antd" -import { useAppSelector, useAppDispatch } from "../redux/hooks" -import { fetchConfig, listLocks, lock, unlock, repoLockSlice as slice, setAutoUnlock} from "../redux/repoLock" -import LockList from '../components/LockList' +import { useAppSelector, useAppDispatch } from "../../redux/hooks" +import { fetchConfig, listLocks, lock, unlock, repoLockSlice as slice, setAutoUnlock} from "../../redux/repoLock" +import LockList, { LockListProps } from "./LockList" -interface Params { - namespace: string - name: string -} +export default (): JSX.Element => { + const { namespace, name } = useParams<{ + namespace: string + name: string + }>() -export default function RepoLock(): JSX.Element { - const { namespace, name } = useParams() const { display, config, locks } = useAppSelector(state => state.repoLock, shallowEqual) + const dispatch = useAppDispatch() useEffect(() => { @@ -29,6 +29,18 @@ export default function RepoLock(): JSX.Element { // eslint-disable-next-line }, [dispatch]) + const onClickLock = (env: string) => { + dispatch(lock(env)) + } + + const onClickUnlock = (env: string) => { + dispatch(unlock(env)) + } + + const onChangeExpiredAt = (env: string, expiredAt: Date) => { + dispatch(setAutoUnlock({env, expiredAt})) + } + if (!display) { return <> } @@ -50,17 +62,26 @@ export default function RepoLock(): JSX.Element { ) } - const onClickLock = (env: string) => { - dispatch(lock(env)) - } + return ( + + ) +} - const onClickUnlock = (env: string) => { - dispatch(unlock(env)) - } +interface RepoLockProps extends LockListProps {} - const onChangeExpiredAt = (env: string, expiredAt: Date) => { - dispatch(setAutoUnlock({env, expiredAt})) - } +function RepoLock({ + envs, + locks, + onChangeExpiredAt, + onClickLock, + onClickUnlock +}: RepoLockProps): JSX.Element { return
@@ -68,7 +89,7 @@ export default function RepoLock(): JSX.Element {
{ ) } -// eslint-disable-next-line interface RepoSettingsProps extends SettingFormProps {} function RepoSettings({