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 2022/05/04 18:00:53 UTC

[GitHub] [superset] ktmud opened a new pull request, #19954: chore: convert URLShortLinkButton to typescript

ktmud opened a new pull request, #19954:
URL: https://github.com/apache/superset/pull/19954

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   
   Convert URLShortLinkButton to TypeScript (tsx) in preparation for bigger refactor where we support including `activeTabs` in dashboard urls (currently you can only highlight one tab using `location.hash`).
   
   No visible changes in the UI.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] codecov[bot] commented on pull request #19954: chore: convert URLShortLinkButton to typescript

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #19954:
URL: https://github.com/apache/superset/pull/19954#issuecomment-1117684776

   # [Codecov](https://codecov.io/gh/apache/superset/pull/19954?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#19954](https://codecov.io/gh/apache/superset/pull/19954?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c66bd11) into [master](https://codecov.io/gh/apache/superset/commit/06b7dea34a4626c487692e6ffe1368e66d59415b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (06b7dea) will **increase** coverage by `0.00%`.
   > The diff coverage is `94.44%`.
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #19954   +/-   ##
   =======================================
     Coverage   66.54%   66.54%           
   =======================================
     Files        1714     1714           
     Lines       65102    65104    +2     
     Branches     6725     6729    +4     
   =======================================
   + Hits        43321    43323    +2     
     Misses      20069    20069           
     Partials     1712     1712           
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | javascript | `51.26% <94.44%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/19954?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...ontend/src/components/URLShortLinkButton/index.tsx](https://codecov.io/gh/apache/superset/pull/19954/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2NvbXBvbmVudHMvVVJMU2hvcnRMaW5rQnV0dG9uL2luZGV4LnRzeA==) | `94.44% <94.44%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/superset/pull/19954?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/superset/pull/19954?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [06b7dea...c66bd11](https://codecov.io/gh/apache/superset/pull/19954?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] ktmud merged pull request #19954: chore: convert URLShortLinkButton to typescript

Posted by GitBox <gi...@apache.org>.
ktmud merged PR #19954:
URL: https://github.com/apache/superset/pull/19954


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] ktmud commented on a diff in pull request #19954: chore: convert URLShortLinkButton to typescript

Posted by GitBox <gi...@apache.org>.
ktmud commented on code in PR #19954:
URL: https://github.com/apache/superset/pull/19954#discussion_r866031300


##########
superset-frontend/src/dashboard/components/gridComponents/Header.jsx:
##########
@@ -176,11 +176,7 @@ class Header extends React.PureComponent {
                   showTooltip={false}
                 />
                 {!editMode && (
-                  <AnchorLink
-                    anchorLinkId={component.id}
-                    filters={filters}
-                    showShortLinkButton
-                  />
+                  <AnchorLink id={component.id} dashboardId={dashboardId} />

Review Comment:
   Adding `dashboardId` fixes the bug where the copy button doesn't copy the right URL for section headers in dashboards.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] ktmud commented on pull request #19954: chore: convert URLShortLinkButton to typescript

Posted by GitBox <gi...@apache.org>.
ktmud commented on PR #19954:
URL: https://github.com/apache/superset/pull/19954#issuecomment-1119022647

   Merging to unblock followup PRs


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] villebro commented on a diff in pull request #19954: chore: convert URLShortLinkButton to typescript

Posted by GitBox <gi...@apache.org>.
villebro commented on code in PR #19954:
URL: https://github.com/apache/superset/pull/19954#discussion_r865802088


##########
superset-frontend/src/components/URLShortLinkButton/index.tsx:
##########
@@ -0,0 +1,99 @@
+/**
+ * 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, { useState } from 'react';
+import { t } from '@superset-ui/core';
+import Popover, { PopoverProps } from 'src/components/Popover';
+import CopyToClipboard from 'src/components/CopyToClipboard';
+import { getDashboardPermalink, getUrlParam } from 'src/utils/urlUtils';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { URL_PARAMS } from 'src/constants';
+import { getFilterValue } from 'src/dashboard/components/nativeFilters/FilterBar/keyValue';
+
+export type URLShortLinkButtonProps = {
+  dashboardId?: number;
+  anchorLinkId?: string;
+  emailSubject?: string;
+  emailContent?: string;
+  placement?: PopoverProps['placement'];
+};
+
+export default function URLShortLinkButton({
+  dashboardId,
+  anchorLinkId,
+  emailContent = '',
+  emailSubject = '',
+  placement = 'left',
+}: URLShortLinkButtonProps) {
+  const [shortUrl, setShortUrl] = useState('');
+  const { addDangerToast } = useToasts();
+
+  const getCopyUrl = async () => {
+    if (dashboardId) {

Review Comment:
   This got me wondering, can we really have this component without `dashboardId` being populated: And based on a quick search, this appears to be the only component that's using this, and there `dashboardId` is always set: https://github.com/apache/superset/blob/902ac053722ada89f817156a0af38ec03f27376c/superset-frontend/src/components/AnchorLink/index.jsx#L28 So I think we can clean this up further by making `dashboardId` a mandatory prop in `URLShortLinkButtonProps`.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] villebro commented on a diff in pull request #19954: chore: convert URLShortLinkButton to typescript

Posted by GitBox <gi...@apache.org>.
villebro commented on code in PR #19954:
URL: https://github.com/apache/superset/pull/19954#discussion_r865802088


##########
superset-frontend/src/components/URLShortLinkButton/index.tsx:
##########
@@ -0,0 +1,99 @@
+/**
+ * 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, { useState } from 'react';
+import { t } from '@superset-ui/core';
+import Popover, { PopoverProps } from 'src/components/Popover';
+import CopyToClipboard from 'src/components/CopyToClipboard';
+import { getDashboardPermalink, getUrlParam } from 'src/utils/urlUtils';
+import { useToasts } from 'src/components/MessageToasts/withToasts';
+import { URL_PARAMS } from 'src/constants';
+import { getFilterValue } from 'src/dashboard/components/nativeFilters/FilterBar/keyValue';
+
+export type URLShortLinkButtonProps = {
+  dashboardId?: number;
+  anchorLinkId?: string;
+  emailSubject?: string;
+  emailContent?: string;
+  placement?: PopoverProps['placement'];
+};
+
+export default function URLShortLinkButton({
+  dashboardId,
+  anchorLinkId,
+  emailContent = '',
+  emailSubject = '',
+  placement = 'left',
+}: URLShortLinkButtonProps) {
+  const [shortUrl, setShortUrl] = useState('');
+  const { addDangerToast } = useToasts();
+
+  const getCopyUrl = async () => {
+    if (dashboardId) {

Review Comment:
   This got me wondering, can we really have this component without `dashboardId` being populated: And based on a quick search, this appears to be the only component that's using this, and there `dashboardId` is always set: https://github.com/apache/superset/blob/902ac053722ada89f817156a0af38ec03f27376c/superset-frontend/src/components/AnchorLink/index.jsx#L28 So I think we can clean this up further by making `dashboardId` mandatory in `URLShortLinkButtonProps`.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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


[GitHub] [superset] ktmud commented on pull request #19954: chore: convert URLShortLinkButton to typescript

Posted by GitBox <gi...@apache.org>.
ktmud commented on PR #19954:
URL: https://github.com/apache/superset/pull/19954#issuecomment-1118689254

   @villebro I made more changes to this PR:
   
   - Converted `AnchorLink` component to tsx, too
   - Moved both AnchorLink and URLShortLinkButton to `src/dashboards` since they really are dashboard only components.
   - Renamed `AnchorLinkProps["anchorLinkId"]` to `AnchorLinkProps["id"]`


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

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