Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

フィルタ設定への説明とガイドを追加 #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const MANABA_COURSES_LIST_URL =
'https://manaba.tsukuba.ac.jp/ct/home_course?chglistformat=list'
Comment on lines +1 to +2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この PR でやらなくてもいいけど定数を切り出すならこの辺も対応した方が良さそう

const raw = await (await fetch('https://manaba.tsukuba.ac.jp/ct/home')).text()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あと定数を切り出す先のディレクトリが config/ 以下なのには何か理由がある?

64 changes: 52 additions & 12 deletions src/content-scripts/manabaMainUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import { MainTheme } from '../uiTheme'
import BlackListSetting from '../ui/BlackListSetting'
import { readStorage, writeStorage } from '../background/utils'
import useSWR from 'swr'
import { MANABA_COURSES_LIST_URL } from '../config/const'

const App = () => {
const [progress, setProgress] = useState(0)
const [importing, setImporting] = useState(false)
const [importingText, setImportingText] = useState('')

const [editBlackList, setEditBlackList] = useState(false)
const [showCaution, setShowCaution] = useState(false)

useEffect(() => {
const listener = (request: Message) => {
Expand All @@ -36,6 +38,25 @@ const App = () => {
mutate: updateBlackListFeatureNotify,
} = useSWR('special-notify:black-list-feature', readStorage)

const handleGoingCourseListButtonClick = () => {
window.location.href = MANABA_COURSES_LIST_URL
}

const handleSettingButtonClick = async () => {
if (window.location.href === MANABA_COURSES_LIST_URL) {
setEditBlackList(true)
await writeStorage('special-notify:black-list-feature', true)
updateBlackListFeatureNotify(true)
} else {
setShowCaution(true)
}
}

const handleNoLongerDisplayButtonClick = async () => {
await writeStorage('special-notify:black-list-feature', true)
updateBlackListFeatureNotify(true)
}

return (
<MainTheme>
{!editBlackList && (
Expand All @@ -46,10 +67,28 @@ const App = () => {
action={<CircularProgress variant="static" value={progress} />}
/>
)}
<Snackbar
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
open={showCaution && !editBlackList}
message={
<>
<p>
この機能は
<a href={MANABA_COURSES_LIST_URL}>Manabaのコース一覧ページ</a>
でのみ使用できます
</p>
</>
}
action={
<Button color="secondary" onClick={handleGoingCourseListButtonClick}>
コース一覧ページへ
</Button>
Comment on lines +83 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://mui.com/material-ui/react-button/#text-button のように hrefをセットすれば onClick でハンドルする必要はなさそう

}
/>
{editBlackList && (
<Snackbar
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
open={editBlackList}
open={editBlackList && !showCaution}
message={
<>
<div>フィルタ設定中</div>
Expand All @@ -66,19 +105,20 @@ const App = () => {
{!blackListFeatureNotify && (
<Snackbar
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
open={!editBlackList}
open={!editBlackList && !showCaution}
message={'小テストやレポートも同期できるようになりました!'}
action={
<Button
color="secondary"
onClick={async () => {
setEditBlackList(true)
await writeStorage('special-notify:black-list-feature', true)
updateBlackListFeatureNotify(true)
}}
>
設定する
</Button>
<>
<Button color="primary" onClick={handleSettingButtonClick}>
設定する
</Button>
<Button
color="secondary"
onClick={handleNoLongerDisplayButtonClick}
>
もう表示しない
</Button>
</>
Comment on lines -72 to +121
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 設定しないでももう表示しないを選択できるように変更している

}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions src/popup/settingSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const SettingSection: React.FC = () => {
フィルタの設定
</WhiteButton>
<p>授業ごとや、カテゴリごとに同期するものを選択できます</p>
<p>この機能はManabaのコース一覧ページでのみ使用できます</p>
</section>
<FormControlLabel
control={
Expand Down