-
Notifications
You must be signed in to change notification settings - Fork 219
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
Feat/5569 5603 without proxy accordion #3599
Feat/5569 5603 without proxy accordion #3599
Conversation
…m/weseek/growi into feat/5569-without-proxy-accordion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしました。確認お願いします
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
コメントしました。確認お願いします
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Outdated
Show resolved
Hide resolved
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettingsAccordion.jsx
Outdated
Show resolved
Hide resolved
const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set()); | ||
|
||
const onToggleAccordionHandler = (i) => { | ||
const accordionIndexes = new Set(openAccordionIndexes); | ||
if (accordionIndexes.has(i)) { | ||
accordionIndexes.delete(i); | ||
} | ||
else { | ||
accordionIndexes.add(i); | ||
} | ||
setOpenAccordionIndexes(accordionIndexes); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考:
growi/src/client/js/components/Admin/ExportArchiveData/SelectCollectionsModal.jsx
Lines 41 to 56 in b803efd
toggleCheckbox(e) { | |
const { target } = e; | |
const { name, checked } = target; | |
this.setState((prevState) => { | |
const selectedCollections = new Set(prevState.selectedCollections); | |
if (checked) { | |
selectedCollections.add(name); | |
} | |
else { | |
selectedCollections.delete(name); | |
} | |
return { selectedCollections }; | |
}); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど、state がすでに Set オブジェクトの場合毎回 new Set で初期化するのは無駄だと思いましたがどうですかね...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最近知ったんですけど、関数内で現在の state を参照して操作するのではなく prevState を操作した方が正しそう?
今回は直さなくていいですが
const onToggleAccordionHandler = (i) => {
setOpenAccordionIndexes((prevOpenAccordionIndexes)=>{
const accordionIndexes = prevOpenAccordionIndexes
if (accordionIndexes.has(i)) {
accordionIndexes.delete(i);
}
else {
accordionIndexes.add(i);
}
return accordionIndexes;
}
}
参考:https://zenn.dev/stin/articles/use-appropriate-api#%E7%B5%90%E8%AB%96
const accordionIndexes = new Set(openAccordionIndexes); | ||
if (accordionIndexes.has(i)) { | ||
accordionIndexes.delete(i); | ||
} | ||
else { | ||
accordionIndexes.add(i); | ||
} | ||
setOpenAccordionIndexes(accordionIndexes); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これだと毎回 Set オブジェクトを生成し直していますね。
const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set()); | ||
|
||
const onToggleAccordionHandler = (i) => { | ||
const accordionIndexes = new Set(openAccordionIndexes); | ||
if (accordionIndexes.has(i)) { | ||
accordionIndexes.delete(i); | ||
} | ||
else { | ||
accordionIndexes.add(i); | ||
} | ||
setOpenAccordionIndexes(accordionIndexes); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set()); | |
const onToggleAccordionHandler = (i) => { | |
const accordionIndexes = new Set(openAccordionIndexes); | |
if (accordionIndexes.has(i)) { | |
accordionIndexes.delete(i); | |
} | |
else { | |
accordionIndexes.add(i); | |
} | |
setOpenAccordionIndexes(accordionIndexes); | |
}; | |
const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set([])); | |
const onToggleAccordionHandler = (i) => { | |
if (accordionIndexes.has(i)) { | |
setOpenAccordionIndexes(accordionIndexes.delete(i)); | |
} | |
else { | |
setOpenAccordionIndexes(accordionIndexes.add(i)); | |
} | |
}; |
これで動くような?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちら、試しましたが動きませんでした。
const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set([]));
const onToggleAccordionHandler = (i) => {
if (openAccordionIndexes.has(i)) {
setOpenAccordionIndexes(openAccordionIndexes.delete(i));
}
else {
setOpenAccordionIndexes(openAccordionIndexes.add(i));
}
};
const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set()); | ||
|
||
const onToggleAccordionHandler = (i) => { | ||
const accordionIndexes = new Set(openAccordionIndexes); | ||
if (accordionIndexes.has(i)) { | ||
accordionIndexes.delete(i); | ||
} | ||
else { | ||
accordionIndexes.add(i); | ||
} | ||
setOpenAccordionIndexes(accordionIndexes); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど、state がすでに Set オブジェクトの場合毎回 new Set で初期化するのは無駄だと思いましたがどうですかね...
const [openAccordionIndexes, setOpenAccordionIndexes] = useState(new Set()); | ||
|
||
const onToggleAccordionHandler = (i) => { | ||
const accordionIndexes = new Set(openAccordionIndexes); | ||
if (accordionIndexes.has(i)) { | ||
accordionIndexes.delete(i); | ||
} | ||
else { | ||
accordionIndexes.add(i); | ||
} | ||
setOpenAccordionIndexes(accordionIndexes); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最近知ったんですけど、関数内で現在の state を参照して操作するのではなく prevState を操作した方が正しそう?
今回は直さなくていいですが
const onToggleAccordionHandler = (i) => {
setOpenAccordionIndexes((prevOpenAccordionIndexes)=>{
const accordionIndexes = prevOpenAccordionIndexes
if (accordionIndexes.has(i)) {
accordionIndexes.delete(i);
}
else {
accordionIndexes.add(i);
}
return accordionIndexes;
}
}
参考:https://zenn.dev/stin/articles/use-appropriate-api#%E7%B5%90%E8%AB%96
const onToggleAccordionHandler = (i) => { | ||
const accordionIndexes = new Set(openAccordionIndexes); | ||
if (accordionIndexes.has(i)) { | ||
accordionIndexes.delete(i); | ||
} | ||
else { | ||
accordionIndexes.add(i); | ||
} | ||
setOpenAccordionIndexes(accordionIndexes); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今後、完了した step によって accordion の開閉をコントロールするのだとしたら index ではなく key を保存した方が良さそうな気がしました。
必要であれば後ほどのタスクで対応するようにお願いします
Without Proxy設定画面内にアコーディオンを追加しました。
【英語】
【日本語】
【中国語】