You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/08/03 09:28:05 UTC

[GitHub] [inlong] bluewang opened a new pull request, #5344: [INLONG-5235][Dashboard] Support users to modify passwords and modify personal keys

bluewang opened a new pull request, #5344:
URL: https://github.com/apache/inlong/pull/5344

   
   ### Prepare a Pull Request
   *(Change the title refer to the following example)*
   
   - Title Example: [INLONG-XYZ][Component] Title of the pull request
   
   *(The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)*
   
   - Fixes https://github.com/apache/inlong/issues/5235
   


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow commented on a diff in pull request #5344: [INLONG-5235][Dashboard] Support users to modify passwords and modify personal keys

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #5344:
URL: https://github.com/apache/inlong/pull/5344#discussion_r936561250


##########
inlong-dashboard/src/components/Layout/NavWidget/index.tsx:
##########
@@ -17,21 +17,31 @@
  * under the License.
  */
 
-import React from 'react';
+import React, { useState } from 'react';
 import { Dropdown, Menu } from 'antd';
 import { useHistory, useSelector, useDispatch, useRequest } from '@/hooks';
 import { State } from '@/models';
 import { useTranslation } from 'react-i18next';
 // import { FileTextOutlined } from '@/components/Icons';
 import LocaleSelect from './LocaleSelect';
 import styles from './index.module.less';
+import PasswordModel from './PasswordModel';
+import KeyModel from './KeyModel';

Review Comment:
   Does those `Model` need to be changed to `Modal`?



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] leezng commented on a diff in pull request #5344: [INLONG-5235][Dashboard] Support users to modify passwords and modify personal keys

Posted by GitBox <gi...@apache.org>.
leezng commented on code in PR #5344:
URL: https://github.com/apache/inlong/pull/5344#discussion_r936491699


##########
inlong-dashboard/src/components/Layout/NavWidget/KeyModel.tsx:
##########
@@ -0,0 +1,128 @@
+/*
+ * 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 { Modal, message } from 'antd';
+import { ModalProps } from 'antd/es/modal';
+import i18n from '@/i18n';
+import FormGenerator, { useForm } from '@/components/FormGenerator';
+import { useUpdateEffect, useRequest } from '@/hooks';
+import request from '@/utils/request';
+import { useTranslation } from 'react-i18next';
+
+export interface Props extends ModalProps {
+  id?: number;
+}
+
+const Comp: React.FC<Props> = ({ id, ...modalProps }) => {
+  const { t } = useTranslation();
+  const [form] = useForm();
+  const [userId, setId] = useState(null);
+  const [userData, setData] = useState({
+    id: null,
+    name: '',
+    version: null,
+    accountType: null,
+    validDays: null,
+  }) as any;
+
+  const content = [
+    {
+      type: 'input',
+      label: 'SecretKey',
+      name: 'secretKey',
+      rules: [{ required: true }],
+    },
+    {
+      type: 'input',
+      label: 'PublicKey',
+      name: 'publicKey',
+      rules: [{ required: true }],
+    },
+    {
+      type: 'input',
+      label: 'PrivateKey',
+      name: 'privateKey',
+      rules: [{ required: true }],
+    },
+  ];
+
+  const { run: getData } = useRequest(
+    {
+      url: `/user/currentUser`,
+      method: 'post',
+    },
+    {
+      manual: true,
+      onSuccess: result => {
+        form.setFieldsValue(result);
+        setId(result.id);
+      },
+    },
+  );
+
+  const { run: getDays } = useRequest(
+    {
+      url: `/user/get/${userId}`,
+    },
+    {
+      manual: true,
+      onSuccess: result => {
+        setData({
+          id: result.id,
+          name: result.name,
+          version: result.version,
+          validDays: result.validDays,
+          accountType: result.accountType,
+        });
+      },
+    },
+  );
+
+  const onOk = async () => {
+    const values = await form.validateFields();
+    const data = { ...userData, ...values };
+    console.log(data);

Review Comment:
   remove console



##########
inlong-dashboard/src/components/Layout/NavWidget/PasswordModel.tsx:
##########
@@ -0,0 +1,130 @@
+/*
+ * 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 { Modal, message } from 'antd';
+import { ModalProps } from 'antd/es/modal';
+import i18n from '@/i18n';
+import FormGenerator, { useForm } from '@/components/FormGenerator';
+import { useUpdateEffect, useRequest } from '@/hooks';
+import request from '@/utils/request';
+import { useTranslation } from 'react-i18next';
+
+export interface Props extends ModalProps {
+  id?: number;
+}
+
+const Comp: React.FC<Props> = ({ id, ...modalProps }) => {
+  const { t } = useTranslation();
+  const [form] = useForm();
+  const [userId, setId] = useState(null);
+  const [userData, setData] = useState({
+    id: null,
+    name: '',
+    version: null,
+    accountType: null,
+    validDays: null,
+  }) as any;
+
+  const content = [
+    {
+      type: 'password',
+      label: t('components.Layout.NavWidget.Password'),
+      name: 'password',
+      rules: [{ required: true }],
+    },
+    {
+      type: 'password',
+      label: t('components.Layout.NavWidget.NewPassword'),
+      name: 'newPassword',
+      rules: [{ required: true }],
+    },
+    {
+      type: 'password',
+      label: t('components.Layout.NavWidget.ConfirmPassword'),
+      name: 'confirmPassword',
+      rules: [{ required: true }],
+    },
+  ];
+
+  const { run: getData } = useRequest(
+    {
+      url: `/user/currentUser`,
+      method: 'post',
+    },
+    {
+      manual: true,
+      onSuccess: result => {
+        setId(result.id);
+      },
+    },
+  );
+
+  const { run: getDays } = useRequest(
+    {
+      url: `/user/get/${userId}`,
+    },
+    {
+      manual: true,
+      onSuccess: result => {
+        setData({
+          id: result.id,
+          name: result.name,
+          version: result.version,
+          validDays: result.validDays,
+          accountType: result.accountType,
+        });
+      },
+    },
+  );
+
+  const onOk = async () => {
+    const values = await form.validateFields();
+    if (values.newPassword !== values.confirmPassword) {
+      message.warning(i18n.t('components.Layout.NavWidget.Remind'));

Review Comment:
   The logic of checking whether the password is consistent before and after can refer to this: https://github.com/apache/inlong/blob/master/inlong-dashboard/src/components/AccessHelper/FieldsConfig/businessFields.tsx#L196



##########
inlong-dashboard/src/components/Layout/NavWidget/index.tsx:
##########
@@ -17,21 +17,31 @@
  * under the License.
  */
 
-import React from 'react';
+import React, { useState } from 'react';
 import { Dropdown, Menu } from 'antd';
 import { useHistory, useSelector, useDispatch, useRequest } from '@/hooks';
 import { State } from '@/models';
 import { useTranslation } from 'react-i18next';
 // import { FileTextOutlined } from '@/components/Icons';
 import LocaleSelect from './LocaleSelect';
 import styles from './index.module.less';
+import PassModel from './PasswordModel';

Review Comment:
   rename to `PasswordModel`



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] leezng commented on a diff in pull request #5344: [INLONG-5235][Dashboard] Support users to modify passwords and modify personal keys

Posted by GitBox <gi...@apache.org>.
leezng commented on code in PR #5344:
URL: https://github.com/apache/inlong/pull/5344#discussion_r936493376


##########
inlong-dashboard/src/components/Layout/NavWidget/index.tsx:
##########
@@ -17,21 +17,31 @@
  * under the License.
  */
 
-import React from 'react';
+import React, { useState } from 'react';
 import { Dropdown, Menu } from 'antd';
 import { useHistory, useSelector, useDispatch, useRequest } from '@/hooks';
 import { State } from '@/models';
 import { useTranslation } from 'react-i18next';
 // import { FileTextOutlined } from '@/components/Icons';
 import LocaleSelect from './LocaleSelect';
 import styles from './index.module.less';
+import PassModel from './PasswordModel';

Review Comment:
   rename to `PasswordModal`



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] leezng merged pull request #5344: [INLONG-5235][Dashboard] Support users to modify passwords and modify personal keys

Posted by GitBox <gi...@apache.org>.
leezng merged PR #5344:
URL: https://github.com/apache/inlong/pull/5344


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org