nytai commented on a change in pull request #8979: [dashboard] new, bulk 
actions for delete & export
URL: 
https://github.com/apache/incubator-superset/pull/8979#discussion_r369723084
 
 

 ##########
 File path: superset/assets/src/components/ConfirmStatusChange.tsx
 ##########
 @@ -0,0 +1,87 @@
+/**
+ * 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 { t } from '@superset-ui/translation';
+import * as React from 'react';
+// @ts-ignore
+import { Button, Modal } from 'react-bootstrap';
+
+type ShowCallback = (callback: (e: any) => any) => (event: any) => any;
+
+interface Props {
+  title: string | React.ReactNode;
+  description: string | React.ReactNode;
+  children: (confirm: ShowCallback) => React.ReactNode;
+}
+
+interface State {
+  open: boolean;
+  callback: (e: React.MouseEvent) => void;
+}
+const defaultCallback = () => { console.error('ConfirmStatusChange invoked 
with the default callback, please provide a function to be called on confirm'); 
};
+export default class ConfirmStatusChange extends React.Component<Props, State> 
{
+
+  public state = {
+    callback: defaultCallback,
+    open: false,
+  };
+
+  public show: ShowCallback = (callback) => (event) => {
 
 Review comment:
   The callback is held in the closure state until the event triggers at which 
point it's put into the components state and the modal pops up. Holding the 
callback in state only happens when the modal is open and we're just waiting 
for user confirmation before executing the original function. Show can be 
called multiple times with different callbacks and each callback won't be 
placed into the state until right before they're about to be executed/cancel 
(via the modal). Since only one modal can be open at a time I think this makes 
sense. 
   
   What isn't configurable is the message displayed to the user, so that does 
limit the number of confirmation prompts this can be used with. Passing the 
title and description to `show` may make sense to enable multiple confirmation 
messages. 

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


With regards,
Apache Git Services

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

Reply via email to