فهرست منبع

HUE-9141 [frontend] Indicate read-only status in the document context popover

Johan Ahlen 5 سال پیش
والد
کامیت
6636cf0530

+ 2 - 8
desktop/core/src/desktop/js/ko/components/contextPopover/ko.contextPopover.js

@@ -34,6 +34,7 @@ import StorageContext from './storageContext';
 import { ASSIST_KEY_COMPONENT } from 'ko/components/assist/ko.assistKey';
 import componentUtils from 'ko/components/componentUtils';
 import { GET_KNOWN_CONFIG_EVENT } from 'utils/hueConfig';
+import { DOCUMENT_CONTEXT_FOOTER } from './ko.documentContextFooter';
 
 export const CONTEXT_POPOVER_CLASS = 'hue-popover';
 export const HIDE_CONTEXT_POPOVER_EVENT = 'context.popover.hide';
@@ -78,14 +79,7 @@ const SUPPORT_TEMPLATES = `
       <!-- ko if: isDocument -->
         <div class="context-popover-bottom-attributes">
         <!-- ko with: contents -->
-          <!-- ko if: data && data.last_modified -->
-          <div><span>${I18n(
-            'Modified'
-          )}</span> <span data-bind="momentFromNow: { data: data.last_modified, titleFormat: 'LLL Z' }"></span></div>
-          <!-- /ko -->
-          <!-- ko if: data && data.owner && data.owner !== window.LOGGED_USERNAME -->
-          <div><span>${I18n('Owner')}</span> <span data-bind="text: data.owner"></span></div>
-          <!-- /ko -->
+          <!-- ko component: { name: '${ DOCUMENT_CONTEXT_FOOTER }', params: { popoverData: $data } } --><!-- /ko -->
         <!-- /ko -->
         </div>
       <!-- /ko -->

+ 54 - 0
desktop/core/src/desktop/js/ko/components/contextPopover/ko.documentContextFooter.js

@@ -0,0 +1,54 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import * as ko from 'knockout';
+
+import componentUtils from 'ko/components/componentUtils';
+import I18n from 'utils/i18n';
+
+export const DOCUMENT_CONTEXT_FOOTER = 'document-context-footer';
+
+// prettier-ignore
+const TEMPLATE = `
+<!-- ko if: doc -->
+  <!-- ko if: doc.last_modified -->
+    <div><span>${I18n('Modified')}</span> <span data-bind="momentFromNow: { data: doc.last_modified, titleFormat: 'LLL Z' }"></span></div>
+  <!-- /ko -->
+  <!-- ko ifnot: ownedByMe -->
+    <div><span>${I18n('Owner')}</span> <span data-bind="text: doc.owner"></span></div>
+  <!-- /ko -->
+  <!-- ko if: readOnly -->
+    <div>${I18n('Read-only')}</div>
+  <!-- /ko -->
+<!-- /ko -->
+`;
+
+class DocumentContextFooter {
+  constructor(params) {
+    this.doc = params.popoverData.data;
+    this.ownedByMe = this.doc && this.doc.owner && this.doc.owner === window.LOGGED_USERNAME;
+
+    this.readOnly = ko.pureComputed(() => {
+      if (window.USER_IS_ADMIN || this.ownedByMe) {
+        return false;
+      }
+      const contents = ko.unwrap(params.popoverData.documentContents);
+      return contents && !contents.canSave;
+    });
+  }
+}
+
+componentUtils.registerComponent(DOCUMENT_CONTEXT_FOOTER, DocumentContextFooter, TEMPLATE);

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue3-extra.css


+ 2 - 2
desktop/core/src/desktop/static/desktop/less/components/hue-popover.less

@@ -332,10 +332,10 @@
   > div {
     display: inline-block;
     font-size: 12px;
-    margin-right: 5px;
+    margin-right: 10px;
+    color: @cui-gray-700;
 
     > span:first-child {
-      color: @cui-gray-700;
       margin-right: 3px;
     }
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است