mintsweet commented on code in PR #3916:
URL: 
https://github.com/apache/incubator-devlake/pull/3916#discussion_r1046605660


##########
config-ui/src/components/blueprints/StartFromSelector.tsx:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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, {useCallback, useEffect} from 'react'
+import {Tag} from '@blueprintjs/core'
+import {TimePrecision} from "@blueprintjs/datetime"
+import {DateInput2} from "@blueprintjs/datetime2"
+import {format} from "date-fns"
+
+const StartFromSelector = (
+  {
+    placeholder = 'Select start from',
+    disabled = false,
+    date,
+    onSave,
+  }: {
+    placeholder?: string,
+    disabled?: boolean,
+    date: string | null,
+    onSave: (newDate: string | null, isUserChange?: boolean) => void,
+  }) => {
+
+  const formatDate = useCallback((date: Date) => format(date, "yyyy-MM-dd 
HH:mm"), []);
+  const parseDate = useCallback((str: string) => new Date(str), []);
+  const chooseDate = (date: Date) => {
+    onSave(format(date, "yyyy-MM-dd'T'HH:mm:ssxxx"))
+  }
+
+  const now = new Date()
+  now.setHours(0, 0, 0, 0)
+  const ago6m = new Date(now)
+  ago6m.setMonth(now.getMonth() - 6)
+  const ago90d = new Date(now)
+  ago90d.setDate(ago90d.getDate() - 90)
+  const ago30d = new Date(now)
+  ago30d.setDate(ago30d.getDate() - 30)
+  const ago1y = new Date(now)
+  ago1y.setUTCFullYear(ago1y.getFullYear() - 1)
+
+  useEffect(() => {
+    if (!date) {
+      onSave(ago6m.toISOString())
+    }
+  }, [date])
+
+  return (
+    <>
+      <div
+        className='start-from'
+      >
+        <div
+          className="123"
+          style={{display: 'flex', marginBottom: '10px'}}>
+          <Tag

Review Comment:
   Can use a config loop to survive?



##########
config-ui/src/components/blueprints/StartFromSelector.tsx:
##########
@@ -0,0 +1,113 @@
+/*
+ * 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, {useCallback, useEffect} from 'react'
+import {Tag} from '@blueprintjs/core'
+import {TimePrecision} from "@blueprintjs/datetime"
+import {DateInput2} from "@blueprintjs/datetime2"
+import {format} from "date-fns"
+
+const StartFromSelector = (
+  {
+    placeholder = 'Select start from',
+    disabled = false,
+    date,
+    onSave,
+  }: {
+    placeholder?: string,
+    disabled?: boolean,
+    date: string | null,
+    onSave: (newDate: string | null, isUserChange?: boolean) => void,
+  }) => {
+
+  const formatDate = useCallback((date: Date) => format(date, "yyyy-MM-dd 
HH:mm"), []);
+  const parseDate = useCallback((str: string) => new Date(str), []);
+  const chooseDate = (date: Date) => {
+    onSave(format(date, "yyyy-MM-dd'T'HH:mm:ssxxx"))
+  }
+
+  const now = new Date()

Review Comment:
   useMemo returns these values?



##########
config-ui/src/pages/blueprint/create/step-four/index.tsx:
##########
@@ -108,12 +111,20 @@ export const StepFour = () => {
 
   return (
     <S.Card>
-      <h2>Set Sync Frequency</h2>
-      <p style={{ margin: '10px 0' }}>{description}</p>
+      <h2>Set Sync Policy</h2>
       <Divider />
+      <div className='block'>
+          <h4>Time Filter *</h4>
+          <p>Select the data range you wish to collect. DevLake will collect 
the last six months of data by default.</p>
+          <StartFromSelector
+            date={createdDateAfter}
+            onSave={onChangeCreatedDateAfter}
+          />
+      </div>
       <div className='block'>
         <h3>Frequency</h3>
         <p>Blueprints will run recurringly based on the sync frequency.</p>
+        <p style={{ margin: '10px 0' }}>{description}</p>

Review Comment:
   You can put it here first, I will modify it later



##########
config-ui/package.json:
##########
@@ -24,6 +25,7 @@
     "babel-plugin-module-resolver": "^4.1.0",
     "cron-parser": "^4.3.0",
     "cron-validate": "^1.4.3",
+    "date-fns": "^2.29.3",

Review Comment:
   Why is another time library introduced? Can `dayjs` not meet the demand?



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

Reply via email to