Просмотр исходного кода

Improve attachment upload function

https://youtrack.weseek.co.jp/issue/GW-7759
- Improve Japanese translation on crop image modal
- Remove unused variable
- Append WIKI_PAGE attachmentType on attachment upload from wiki page
I Komang Mudana 3 лет назад
Родитель
Сommit
83aa5ce923

+ 1 - 1
packages/app/resource/locales/ja_JP/translation.json

@@ -1020,7 +1020,7 @@
   },
   },
   "crop_image_modal": {
   "crop_image_modal": {
     "image_crop": "画像の切り抜き",
     "image_crop": "画像の切り抜き",
-    "crop": "トリ",
+    "crop": "トリミング",
     "reset": "リセット",
     "reset": "リセット",
     "cancel": "キャンセル"
     "cancel": "キャンセル"
   }
   }

+ 4 - 2
packages/app/src/client/services/AdminCustomizeContainer.js

@@ -105,14 +105,16 @@ export default class AdminCustomizeContainer extends Container {
         currentCustomizeHeader: customizeParams.customizeHeader,
         currentCustomizeHeader: customizeParams.customizeHeader,
         currentCustomizeCss: customizeParams.customizeCss,
         currentCustomizeCss: customizeParams.customizeCss,
         currentCustomizeScript: customizeParams.customizeScript,
         currentCustomizeScript: customizeParams.customizeScript,
-        attachmentId: customizeParams.attachmentLogoId,
+        attachmentId: customizeParams.attachmentId,
         isDefaultLogo: customizeParams.isDefaultLogo,
         isDefaultLogo: customizeParams.isDefaultLogo,
         uploadedLogoSrc: customizeParams.uploadedLogoSrc,
         uploadedLogoSrc: customizeParams.uploadedLogoSrc,
         isUploadedLogo: customizeParams.uploadedLogoSrc,
         isUploadedLogo: customizeParams.uploadedLogoSrc,
       });
       });
       // search style name from object for display
       // search style name from object for display
       this.setState({ currentHighlightJsStyleName: this.state.highlightJsCssSelectorOptions[customizeParams.styleName].name });
       this.setState({ currentHighlightJsStyleName: this.state.highlightJsCssSelectorOptions[customizeParams.styleName].name });
-
+      if (customizeParams.attachmentId == null) {
+        this.setState({ isDefaultLogo: true, uploadedLogoSrc: DEFAULT_LOGO, isUploadedLogo: false });
+      }
 
 
     }
     }
     catch (err) {
     catch (err) {

+ 0 - 2
packages/app/src/server/models/config.ts

@@ -135,7 +135,6 @@ export const defaultCrowiConfigs: { [key: string]: any } = {
   'customize:isEnabledStaleNotification': false,
   'customize:isEnabledStaleNotification': false,
   'customize:isAllReplyShown': false,
   'customize:isAllReplyShown': false,
   'customize:isSearchScopeChildrenAsDefault': false,
   'customize:isSearchScopeChildrenAsDefault': false,
-  'customize:attachmentLogoId' : undefined,
   'customize:isDefaultLogo': true,
   'customize:isDefaultLogo': true,
   'customize:uploadedLogoSrc': undefined,
   'customize:uploadedLogoSrc': undefined,
 
 
@@ -246,7 +245,6 @@ schema.statics.getLocalconfig = function(crowi) {
     pageLimitationL: crowi.configManager.getConfig('crowi', 'customize:showPageLimitationL'),
     pageLimitationL: crowi.configManager.getConfig('crowi', 'customize:showPageLimitationL'),
     pageLimitationXL: crowi.configManager.getConfig('crowi', 'customize:showPageLimitationXL'),
     pageLimitationXL: crowi.configManager.getConfig('crowi', 'customize:showPageLimitationXL'),
     isDefaultLogo:  crowi.configManager.getConfig('crowi', 'customize:isDefaultLogo'),
     isDefaultLogo:  crowi.configManager.getConfig('crowi', 'customize:isDefaultLogo'),
-    attachmentLogoId: crowi.configManager.getConfig('crowi', 'customize:attachmentLogoId'),
     uploadedLogoSrc: crowi.configManager.getConfig('crowi', 'customize:uploadedLogoSrc'),
     uploadedLogoSrc: crowi.configManager.getConfig('crowi', 'customize:uploadedLogoSrc'),
   };
   };
 
 

+ 3 - 6
packages/app/src/server/routes/apiv3/customize-setting.js

@@ -182,7 +182,7 @@ module.exports = (crowi) => {
       customizeHeader: await crowi.configManager.getConfig('crowi', 'customize:header'),
       customizeHeader: await crowi.configManager.getConfig('crowi', 'customize:header'),
       customizeCss: await crowi.configManager.getConfig('crowi', 'customize:css'),
       customizeCss: await crowi.configManager.getConfig('crowi', 'customize:css'),
       customizeScript: await crowi.configManager.getConfig('crowi', 'customize:script'),
       customizeScript: await crowi.configManager.getConfig('crowi', 'customize:script'),
-      attachmentLogoId: await crowi.configManager.getConfig('crowi', 'customize:attachmentLogoId'),
+      attachmentId: await crowi.configManager.getConfig('crowi', 'customize:attachmentId'),
       isDefaultLogo: await crowi.configManager.getConfig('crowi', 'customize:isDefaultLogo'),
       isDefaultLogo: await crowi.configManager.getConfig('crowi', 'customize:isDefaultLogo'),
       uploadedLogoSrc: await crowi.configManager.getConfig('crowi', 'customize:uploadedLogoSrc'),
       uploadedLogoSrc: await crowi.configManager.getConfig('crowi', 'customize:uploadedLogoSrc'),
     };
     };
@@ -620,18 +620,15 @@ module.exports = (crowi) => {
   router.put('/customize-logo', loginRequiredStrictly, adminRequired, csrf, validator.logo, apiV3FormValidator, async(req, res) => {
   router.put('/customize-logo', loginRequiredStrictly, adminRequired, csrf, validator.logo, apiV3FormValidator, async(req, res) => {
 
 
     const { isDefaultLogo, attachmentId } = req.body;
     const { isDefaultLogo, attachmentId } = req.body;
-    // Set default logo when uploaded logo is empty
-
-    const attachmentLogoId = isDefaultLogo || attachmentId == null ? null : attachmentId;
 
 
     const requestParams = {
     const requestParams = {
-      'customize:attachmentLogoId': attachmentLogoId,
+      'customize:attachmentId': attachmentId,
       'customize:isDefaultLogo': isDefaultLogo,
       'customize:isDefaultLogo': isDefaultLogo,
     };
     };
     try {
     try {
       await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestParams);
       await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestParams);
       const customizedParams = {
       const customizedParams = {
-        attachmentId: await crowi.configManager.getConfig('crowi', 'customize:attachmentLogoId'),
+        attachmentId: await crowi.configManager.getConfig('crowi', 'customize:attachmentId'),
         isDefaultLogo: await crowi.configManager.getConfig('crowi', 'customize:isDefaultLogo'),
         isDefaultLogo: await crowi.configManager.getConfig('crowi', 'customize:isDefaultLogo'),
       };
       };
       return res.apiv3({ customizedParams });
       return res.apiv3({ customizedParams });

+ 4 - 4
packages/app/src/server/routes/attachment.js

@@ -453,7 +453,7 @@ module.exports = function(crowi, app) {
 
 
     let attachment;
     let attachment;
     try {
     try {
-      attachment = await attachmentService.createAttachment(file, req.user, pageId);
+      attachment = await attachmentService.createAttachment(file, req.user, pageId, 'WIKI_PAGE');
     }
     }
     catch (err) {
     catch (err) {
       logger.error(err);
       logger.error(err);
@@ -735,7 +735,7 @@ module.exports = function(crowi, app) {
     try {
     try {
       attachment = await attachmentService.createAttachment(file, req.user, null, attachmentType);
       attachment = await attachmentService.createAttachment(file, req.user, null, attachmentType);
       const attachmentConfigParams = {
       const attachmentConfigParams = {
-        'customize:attachmentLogoId': attachment.id,
+        'customize:attachmentId': attachment.id,
         'customize:uploadedLogoSrc': attachment.filePathProxied,
         'customize:uploadedLogoSrc': attachment.filePathProxied,
       };
       };
       await crowi.configManager.updateConfigsInTheSameNamespace('crowi', attachmentConfigParams);
       await crowi.configManager.updateConfigsInTheSameNamespace('crowi', attachmentConfigParams);
@@ -763,9 +763,9 @@ module.exports = function(crowi, app) {
 
 
     try {
     try {
       await attachmentService.removeAttachment(attachmentObjectId);
       await attachmentService.removeAttachment(attachmentObjectId);
-      // update attachmentLogoId immediately
+      // update attachmentId immediately
       const attachmentConfigParams = {
       const attachmentConfigParams = {
-        'customize:attachmentLogoId': null,
+        'customize:attachmentId': null,
         'customize:isDefaultLogo': true,
         'customize:isDefaultLogo': true,
       };
       };
       await crowi.configManager.updateConfigsInTheSameNamespace('crowi', attachmentConfigParams);
       await crowi.configManager.updateConfigsInTheSameNamespace('crowi', attachmentConfigParams);