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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to