-
Notifications
You must be signed in to change notification settings - Fork 217
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
fix: Custom logo not displayed on shared page #7205
fix: Custom logo not displayed on shared page #7205
Conversation
if (isBlandLogo) { | ||
req.isSharedPage = true; | ||
return next(); | ||
} |
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.
attachmentType が BRAND_LOGO の attachment は relatedPage が null となるため、42 行目以降の処理は不要にして、shared page で表示できるようにしました。
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.
- brand logo かどうかの判定ロジックは Attachment model or service に持っていく
req.isSharedPage = true;
セットするのは不自然- そもそも shared page からのアクセスだろうがそれ以外からのアクセスだろうが、brand logo は pass させたいわけだから
- certifyBrandLogo middleware をつくるか、または
/attachment/brand-logo
route を作っちゃうか
if (isBlandLogo) { | ||
req.isSharedPage = true; | ||
return next(); | ||
} |
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.
- brand logo かどうかの判定ロジックは Attachment model or service に持っていく
req.isSharedPage = true;
セットするのは不自然- そもそも shared page からのアクセスだろうがそれ以外からのアクセスだろうが、brand logo は pass させたいわけだから
- certifyBrandLogo middleware をつくるか、または
/attachment/brand-logo
route を作っちゃうか
@@ -106,6 +107,8 @@ module.exports = function(crowi, app) { | |||
app.post('/_api/admin/import/qiita' , loginRequiredStrictly , adminRequired , csrfProtection, addActivity, admin.api.importDataFromQiita); | |||
app.post('/_api/admin/import/testQiitaAPI' , loginRequiredStrictly , adminRequired , csrfProtection, addActivity, admin.api.testQiitaAPI); | |||
|
|||
app.get('/attachment/brand-logo/:id([0-9a-z]{24})' , certifyBrandLogo, loginRequired, attachment.api.get); |
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.
メンテナスモード時に考慮して API を新設しました
別 PR の FB に対応したものになります
#7204 (comment)
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.
/attachment/brand-logo
固定でいいね
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.
固定にしました
next(); | ||
}; | ||
|
||
}; |
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.
- Brand logo か判断するための express middleware
loginRequired
を通過させるための変数isBrandLogo
を追加しました
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.
id ではなく type で取得する
(BRAND_LOGO type のドキュメントは1つしか存在しないはず)
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.
修正しました
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.
route を分けたからここでの存在確認いらないね。
この middleware は無条件で req.isBrandLogo = true
をセットしていい。
attachment が存在しなかったら attachment.api.getBrandLogo
が 404 を返す
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.
修正しました
@@ -718,7 +718,7 @@ module.exports = (crowi) => { | |||
try { | |||
attachment = await attachmentService.createAttachment(file, req.user, null, AttachmentType.BRAND_LOGO); | |||
const attachmentConfigParams = { | |||
'customize:customizedLogoSrc': attachment.filePathProxied, | |||
'customize:customizedLogoSrc': attachment.brandLogoFilePathProxied, |
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.
/attachment/brand-logo/{filePath}
で保存されるように修正しました
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.
/attachment/brand-logo
固定でいいね
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.
固定にしたので、customize:customizedLogoSrc
は廃止にしました
next(); | ||
}; | ||
|
||
}; |
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.
id ではなく type で取得する
(BRAND_LOGO type のドキュメントは1つしか存在しないはず)
@@ -51,6 +51,10 @@ module.exports = function(crowi) { | |||
return `/attachment/${this._id}`; | |||
}); | |||
|
|||
attachmentSchema.virtual('brandLogoFilePathProxied').get(function() { | |||
return `/attachment/brand-logo/${this._id}`; | |||
}); |
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.
不要
@@ -718,7 +718,7 @@ module.exports = (crowi) => { | |||
try { | |||
attachment = await attachmentService.createAttachment(file, req.user, null, AttachmentType.BRAND_LOGO); | |||
const attachmentConfigParams = { | |||
'customize:customizedLogoSrc': attachment.filePathProxied, | |||
'customize:customizedLogoSrc': attachment.brandLogoFilePathProxied, |
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.
/attachment/brand-logo
固定でいいね
@@ -106,6 +107,8 @@ module.exports = function(crowi, app) { | |||
app.post('/_api/admin/import/qiita' , loginRequiredStrictly , adminRequired , csrfProtection, addActivity, admin.api.importDataFromQiita); | |||
app.post('/_api/admin/import/testQiitaAPI' , loginRequiredStrictly , adminRequired , csrfProtection, addActivity, admin.api.testQiitaAPI); | |||
|
|||
app.get('/attachment/brand-logo/:id([0-9a-z]{24})' , certifyBrandLogo, loginRequired, attachment.api.get); |
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.
/attachment/brand-logo
固定でいいね
next(); | ||
}; | ||
|
||
}; |
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.
修正しました
packages/app/src/components/Admin/Customize/CustomizeLogoSetting.tsx
Outdated
Show resolved
Hide resolved
@@ -77,6 +79,11 @@ class AttachmentService { | |||
return; | |||
} | |||
|
|||
async isBrandLogoExist() { | |||
const Attachment = this.crowi.model('Attachment'); | |||
return await Attachment.findOne({ attachmentType: AttachmentType.BRAND_LOGO }) != null; |
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.
count が 1 以上かどうかというクエリにしてください
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.
修正しました
packages/app/src/pages/_app.page.tsx
Outdated
@@ -63,7 +63,8 @@ function GrowiApp({ Component, pageProps }: GrowiAppProps): JSX.Element { | |||
useSiteUrl(commonPageProps.siteUrl); | |||
useConfidential(commonPageProps.confidential); | |||
useGrowiVersion(commonPageProps.growiVersion); | |||
useCustomizedLogoSrc(commonPageProps.customizedLogoSrc); | |||
useIsDefaultLogo(commonPageProps.isDefaultLogo); | |||
useIsCustomizedLogoUploaded(commonPageProps.isCustomizedLogoUploaded); |
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.
ここは元のままでいい
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.
「デフォルトロゴが選択されているかどうか」と 「カスタムロゴがアップロードされているかどうか」は別問題なのでこのままにしました。useCustomizedLogoSrc (カスタムロゴのソース) と useIsCustomizedLogoUploaded (カスタムロゴがアップロードされているかどうかの boolean ) の使われ方はほぼ同じで、フロントエンドで src を使う必要がないので後者を残しました。
|
||
return ( | ||
<nav id="grw-navbar" className={`navbar grw-navbar ${styles['grw-navbar']} navbar-expand navbar-dark sticky-top mb-0 px-0`}> | ||
{/* Brand Logo */} | ||
<div className="navbar-brand mr-0"> | ||
<Link href="/" prefetch={false}> | ||
<a className="grw-logo d-block"> | ||
<GrowiNavbarLogo logoSrc={customizedLogoSrc}/> | ||
<GrowiNavbarLogo isDefaultLogo={isDefaultLogo} isCustomizedLogoUploaded={isCustomizedLogoUploaded}/> |
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.
ここは元のままでいい
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.
isDefaultLogo
だけで判断できるようにしました
currentUser, | ||
isDefaultLogo, | ||
isCustomizedLogoUploaded, |
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.
- customizedLogoSrc props は元に戻し、DB から取得した src を入れる
next(); | ||
}; | ||
|
||
}; |
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.
route を分けたからここでの存在確認いらないね。
この middleware は無条件で req.isBrandLogo = true
をセットしていい。
attachment が存在しなかったら attachment.api.getBrandLogo
が 404 を返す
reg-suit detected visual differences. Check this report, and review them. 🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴🔴 🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵🔵 What do the circles mean?The number of circles represent the number of changed images.🔴 : Changed items, ⚪ : New items, ⚫ : Deleted items, and 🔵 Passed items How can I change the check status?If reviewers approve this PR, the reg context status will be green automatically. |
Task
#112434 [GROWI][Next.js] カスタムロゴ設定した状態で、任意のページのsharelink にアクセスすると、ロゴが表示されない
└ #112474 修正