You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/03/29 13:57:58 UTC

[GitHub] [airflow] bbovenzi opened a new pull request #15068: Add query mutations to new UI

bbovenzi opened a new pull request #15068:
URL: https://github.com/apache/airflow/pull/15068


   Establishing practices of handling POST/PATCH/PUT http actions with React Query. Closes #15019
   
   - Can now toggle  a dag active/inactive
   - Can trigger a new dagrun
   - Test for active/inactive toggle
   - Move a table row to its own component
   - Use toasts for error or success messages
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


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



[GitHub] [airflow] ryanahamilton commented on a change in pull request #15068: Add query mutations to new UI

Posted by GitBox <gi...@apache.org>.
ryanahamilton commented on a change in pull request #15068:
URL: https://github.com/apache/airflow/pull/15068#discussion_r603420994



##########
File path: airflow/ui/src/api/index.ts
##########
@@ -75,3 +84,112 @@ export function useVersion() {
     (): Promise<Version> => axios.get('/version'),
   );
 }
+
+export function useTriggerRun(dagId: Dag['dagId']) {
+  const queryClient = useQueryClient();
+  const toast = useToast();
+  return useMutation(
+    (trigger: TriggerRunRequest) => axios.post(`dags/${dagId}/dagRuns`, camelToSnakeCase(trigger)),
+    {
+      onSettled: (res, error) => {
+        if (error) {
+          toast({
+            title: 'Error triggering DAG',
+            description: (error as Error).message,
+            status: 'error',
+            duration: 3000,
+            isClosable: true,

Review comment:
       Not for this PR, but we should refactor so that the default values are consistent per status value so we don't have to define every time.




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



[GitHub] [airflow] github-actions[bot] commented on pull request #15068: Add query mutations to new UI

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #15068:
URL: https://github.com/apache/airflow/pull/15068#issuecomment-809579524


   [The Workflow run](https://github.com/apache/airflow/actions/runs/698722338) is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.


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



[GitHub] [airflow] github-actions[bot] commented on pull request #15068: Add query mutations to new UI

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #15068:
URL: https://github.com/apache/airflow/pull/15068#issuecomment-809765317


   The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.


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



[GitHub] [airflow] ryanahamilton merged pull request #15068: Add query mutations to new UI

Posted by GitBox <gi...@apache.org>.
ryanahamilton merged pull request #15068:
URL: https://github.com/apache/airflow/pull/15068


   


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



[GitHub] [airflow] ryanahamilton commented on a change in pull request #15068: Add query mutations to new UI

Posted by GitBox <gi...@apache.org>.
ryanahamilton commented on a change in pull request #15068:
URL: https://github.com/apache/airflow/pull/15068#discussion_r603539284



##########
File path: airflow/ui/src/utils/index.ts
##########
@@ -0,0 +1,34 @@
+/*!
+ * 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.
+ */
+
+export const isObject = (obj: any) => Object.prototype.toString.call(obj) === '[object Object]';
+
+export const camelToSnakeCase = (obj: Record<string, any>) => {

Review comment:
       I know we're already using `humps` elsewhere in the app. Could we be using `humps.decamelize` here instead of DIY?

##########
File path: airflow/ui/src/api/index.ts
##########
@@ -75,3 +84,112 @@ export function useVersion() {
     (): Promise<Version> => axios.get('/version'),
   );
 }
+
+export function useTriggerRun(dagId: Dag['dagId']) {
+  const queryClient = useQueryClient();
+  const toast = useToast();
+  return useMutation(
+    (trigger: TriggerRunRequest) => axios.post(`dags/${dagId}/dagRuns`, camelToSnakeCase(trigger)),
+    {
+      onSettled: (res, error) => {
+        if (error) {
+          toast({
+            title: 'Error triggering DAG',
+            description: (error as Error).message,
+            status: 'error',
+            duration: 3000,
+            isClosable: true,

Review comment:
       Not for this PR, but we should refactor so that the default values are consistent per status value.




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