From d35b7480e09bd67928fb0afea3a4a793797b2271 Mon Sep 17 00:00:00 2001 From: TechQuery Date: Wed, 28 Aug 2024 05:33:39 +0800 Subject: [PATCH] [refactor] simplify Announcement types & model [add] GitHub PR badges --- .github/pr-badge.yml | 17 +++++++ components/Message/MessageList.tsx | 26 ++++++----- components/Message/MessageModal.tsx | 19 ++++---- configuration/menu.ts | 2 +- models/Activity/Message.ts | 45 +++++-------------- models/Activity/index.ts | 12 ++--- package.json | 2 +- pages/activity/[name]/index.tsx | 6 +-- .../manage/{message.tsx => announcement.tsx} | 10 ++--- pnpm-lock.yaml | 10 ++--- 10 files changed, 75 insertions(+), 74 deletions(-) create mode 100644 .github/pr-badge.yml rename pages/activity/[name]/manage/{message.tsx => announcement.tsx} (91%) diff --git a/.github/pr-badge.yml b/.github/pr-badge.yml new file mode 100644 index 00000000..74005161 --- /dev/null +++ b/.github/pr-badge.yml @@ -0,0 +1,17 @@ +- icon: visualstudio + label: 'GitHub.dev' + message: 'PR-$prNumber' + color: 'blue' + url: 'https://github.dev/$owner/$repo/pull/$prNumber' + +- icon: github + label: 'GitHub codespaces' + message: 'PR-$prNumber' + color: 'black' + url: 'https://codespaces.new/$owner/$repo/pull/$prNumber' + +- icon: git + label: 'GitPod.io' + message: 'PR-$prNumber' + color: 'orange' + url: 'https://gitpod.io/?autostart=true#https://github.com/$owner/$repo/pull/$prNumber' diff --git a/components/Message/MessageList.tsx b/components/Message/MessageList.tsx index a6fe65ef..18ce66b8 100644 --- a/components/Message/MessageList.tsx +++ b/components/Message/MessageList.tsx @@ -1,15 +1,15 @@ import { faEdit, faTrash } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { Announcement } from '@kaiyuanshe/openhackathon-service'; import { observable } from 'mobx'; import { observer } from 'mobx-react'; import { ScrollList, ScrollListProps } from 'mobx-restful-table'; -import { FC, PureComponent } from 'react'; +import { Component, FC, PureComponent } from 'react'; import { Button, Form, Table } from 'react-bootstrap'; import { - Message, - MessageType, - MessageTypeName, + AnnouncementType, + AnnouncementTypeName, } from '../../models/Activity/Message'; import { i18n } from '../../models/Base/Translation'; import styles from '../../styles/participant.module.less'; @@ -17,13 +17,14 @@ import { XScrollListProps } from '../layout/ScrollList'; const { t } = i18n; -export interface MessageListLayoutProps extends XScrollListProps { +export interface AnnouncementListLayoutProps + extends XScrollListProps { hideControls?: boolean; onEdit?: (id: number) => any; onDelete?: (id: number) => any; } -export const MessageListLayout: FC = ({ +export const AnnouncementListLayout: FC = ({ defaultData = [], selectedIds = [], hideControls, @@ -90,7 +91,7 @@ export const MessageListLayout: FC = ({ {title} {content} - {MessageTypeName()[MessageType.Hackathon]} + {AnnouncementTypeName()[AnnouncementType.Hackathon]} - (this.selectedIds = list)} onEdit={() => (this.show = true)} onDelete={this.handleReset} /> - (this.show = false)} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9ea9d151..4a66ae31 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -118,8 +118,8 @@ importers: specifier: ^7.24.7 version: 7.24.7(@babel/core@7.25.2) '@kaiyuanshe/openhackathon-service': - specifier: ^0.17.0 - version: 0.17.0(mobx@6.13.1)(typescript@5.5.4) + specifier: ^0.18.0 + version: 0.18.0(mobx@6.13.1)(typescript@5.5.4) '@octokit/openapi-types': specifier: ^22.2.0 version: 22.2.0 @@ -959,8 +959,8 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@kaiyuanshe/openhackathon-service@0.17.0': - resolution: {integrity: sha512-mk0AXaH37J0QNxfoC6MoyklVLh23iKW5bpspXsptwnnQCz05CVwb50R1/+5NX+JhV0V3JuMdM6uIE3oSNVv1bQ==, tarball: https://npm.pkg.github.com/download/@kaiyuanshe/openhackathon-service/0.17.0/b3d16f1aef02388f52dcedb6cb394d646d9afcb9} + '@kaiyuanshe/openhackathon-service@0.18.0': + resolution: {integrity: sha512-Om8GM0rMrS+5atqUaWymveHfmeDXvf/svqzwDdR+An3Oqoj1DyQzhwYUcJFinoYlIUGXS+JUHtAGTZ9gy9u6YQ==, tarball: https://npm.pkg.github.com/download/@kaiyuanshe/openhackathon-service/0.18.0/e572f4ccdf8b14ea305284819e76393f746b8a2d} '@lit-labs/ssr-dom-shim@1.2.1': resolution: {integrity: sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==} @@ -5819,7 +5819,7 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 - '@kaiyuanshe/openhackathon-service@0.17.0(mobx@6.13.1)(typescript@5.5.4)': + '@kaiyuanshe/openhackathon-service@0.18.0(mobx@6.13.1)(typescript@5.5.4)': dependencies: '@octokit/openapi-types': 22.2.0 '@types/jsonwebtoken': 9.0.6