You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/06/11 22:40:55 UTC

[GitHub] [incubator-superset] etr2460 commented on a change in pull request #10041: feat: owners profile icon on dataset list view

etr2460 commented on a change in pull request #10041:
URL: https://github.com/apache/incubator-superset/pull/10041#discussion_r439107055



##########
File path: superset-frontend/src/components/AvatarIcon.tsx
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 React, { PureComponent } from 'react';
+import { Tooltip, OverlayTrigger } from 'react-bootstrap';
+import Avatar, { ConfigProvider } from 'react-avatar';
+
+interface Props {
+  firstName: string;
+  iconSize: string;
+  lastName: string;
+  tableName: string;
+  userName: string;
+}
+
+export default class AvatarIcon extends PureComponent<Props> {
+  render() {
+    const { tableName, firstName, lastName, userName, iconSize } = this.props;
+    const uniqueKey = tableName.concat('_', userName);
+    const fullName = firstName.concat(' ', lastName);
+    const colors = [

Review comment:
       can we pull this array out into a constant so that it doesn't get rebuilt on every render?

##########
File path: superset-frontend/src/components/AvatarIcon.tsx
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 React, { PureComponent } from 'react';
+import { Tooltip, OverlayTrigger } from 'react-bootstrap';
+import Avatar, { ConfigProvider } from 'react-avatar';
+
+interface Props {
+  firstName: string;
+  iconSize: string;
+  lastName: string;
+  tableName: string;
+  userName: string;
+}
+
+export default class AvatarIcon extends PureComponent<Props> {
+  render() {
+    const { tableName, firstName, lastName, userName, iconSize } = this.props;
+    const uniqueKey = tableName.concat('_', userName);
+    const fullName = firstName.concat(' ', lastName);
+    const colors = [
+      '#20A7C9',
+      '#59C189',
+      '#A868B6',
+      '#E04355',
+      '#FBC700',
+      '#FF7F43',
+    ];
+    return (
+      <ConfigProvider colors={colors}>
+        <OverlayTrigger
+          placement="right"
+          overlay={<Tooltip id={`${uniqueKey}-tooltip`}>{fullName}</Tooltip>}
+        >
+          <Avatar
+            key={`${uniqueKey}`}
+            name={fullName}
+            size={iconSize}
+            round
+            style={{ margin: '0px 5px' }}

Review comment:
       can we use the className attribute and apply a class to this instead of inlining styles?

##########
File path: superset-frontend/src/components/AvatarIcon.tsx
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 React, { PureComponent } from 'react';
+import { Tooltip, OverlayTrigger } from 'react-bootstrap';
+import Avatar, { ConfigProvider } from 'react-avatar';
+
+interface Props {
+  firstName: string;
+  iconSize: string;
+  lastName: string;
+  tableName: string;
+  userName: string;
+}
+
+export default class AvatarIcon extends PureComponent<Props> {
+  render() {
+    const { tableName, firstName, lastName, userName, iconSize } = this.props;
+    const uniqueKey = tableName.concat('_', userName);

Review comment:
       since unique key is only used in one place, instead of defining as a constant it might be cleaner to set it directly on the `key` attribute

##########
File path: superset-frontend/src/components/AvatarIcon.tsx
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 React, { PureComponent } from 'react';
+import { Tooltip, OverlayTrigger } from 'react-bootstrap';
+import Avatar, { ConfigProvider } from 'react-avatar';
+
+interface Props {
+  firstName: string;
+  iconSize: string;
+  lastName: string;
+  tableName: string;
+  userName: string;
+}
+
+export default class AvatarIcon extends PureComponent<Props> {

Review comment:
       Since this component only has a render function, maybe we should make it a functional component instead?

##########
File path: superset-frontend/src/components/AvatarIcon.tsx
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 React, { PureComponent } from 'react';
+import { Tooltip, OverlayTrigger } from 'react-bootstrap';
+import Avatar, { ConfigProvider } from 'react-avatar';
+
+interface Props {
+  firstName: string;
+  iconSize: string;
+  lastName: string;
+  tableName: string;
+  userName: string;
+}
+
+export default class AvatarIcon extends PureComponent<Props> {
+  render() {
+    const { tableName, firstName, lastName, userName, iconSize } = this.props;
+    const uniqueKey = tableName.concat('_', userName);

Review comment:
       nit: prefer `${tableName}_${userName}`

##########
File path: superset-frontend/src/components/AvatarIcon.tsx
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 React, { PureComponent } from 'react';
+import { Tooltip, OverlayTrigger } from 'react-bootstrap';
+import Avatar, { ConfigProvider } from 'react-avatar';
+
+interface Props {
+  firstName: string;
+  iconSize: string;
+  lastName: string;
+  tableName: string;
+  userName: string;
+}
+
+export default class AvatarIcon extends PureComponent<Props> {
+  render() {
+    const { tableName, firstName, lastName, userName, iconSize } = this.props;
+    const uniqueKey = tableName.concat('_', userName);
+    const fullName = firstName.concat(' ', lastName);

Review comment:
       nit: prefer `${firstName} ${lastName}`

##########
File path: superset-frontend/src/components/AvatarIcon.tsx
##########
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF 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 React, { PureComponent } from 'react';
+import { Tooltip, OverlayTrigger } from 'react-bootstrap';
+import Avatar, { ConfigProvider } from 'react-avatar';
+
+interface Props {
+  firstName: string;
+  iconSize: string;

Review comment:
       can this be a number instead? Seems a bit odd as a string and react-avatar seems to accept either a number of a string




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org