You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/04/20 07:55:00 UTC

[GitHub] [apisix-dashboard] juxianzheng opened a new pull request, #2290: feat: added form function to authz-casbin plugin

juxianzheng opened a new pull request, #2290:
URL: https://github.com/apache/apisix-dashboard/pull/2290

   Please answer these questions before submitting a pull request, **or your PR will get closed**.
   
   **Why submit this pull request?**
   
   - [ ] Bugfix
   - [x] New feature provided
   - [ ] Improve performance
   - [ ] Backport patches
   
   **What changes will this PR take into?**
   
   Please update this section with detailed description.
   
   **Related issues**
   
   fix/resolve #0001
   
   **Checklist:**
   
       >Added form function to authz-casbin plugin


-- 
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: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix-dashboard] juxianzheng commented on pull request #2290: feat: added form function to authz-casbin plugin

Posted by GitBox <gi...@apache.org>.
juxianzheng commented on PR #2290:
URL: https://github.com/apache/apisix-dashboard/pull/2290#issuecomment-1103583339

   > ![图片](https://user-images.githubusercontent.com/72343596/164159612-605a9486-a26e-44ba-96fa-0f3c19b5fcc3.png) 应该修复这个测试
   
   


-- 
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: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix-dashboard] Baoyuantop commented on a diff in pull request #2290: feat: added form function to authz-casbin plugin

Posted by GitBox <gi...@apache.org>.
Baoyuantop commented on code in PR #2290:
URL: https://github.com/apache/apisix-dashboard/pull/2290#discussion_r886260491


##########
web/src/components/Plugin/UI/authz-casbin.tsx:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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 { useIntl } from "umi";
+import Form, { FormInstance } from "antd/es/form";
+import React, { useState } from "react";
+import { Radio, Input } from "antd";
+
+type Props = {
+  form: FormInstance;
+  schema: Record<string, any> | undefined;
+  ref?: any;
+  disabled?: boolean;
+}
+
+const FORM_ITEM_LAYOUT = {
+  labelCol: {
+    span: 7,
+  },
+  wrapperCol: {
+    span: 8,
+  },
+};
+
+const AuthzCasbin: React.FC<Props> = ({ form, schema }) => {
+  const { formatMessage } = useIntl();
+  const properties = schema?.properties
+  const [radioValue, setRadioValue] = useState('path');
+  const onChange = (e: any) => {
+    setRadioValue(e.target.value);
+  };
+
+  return (
+    <Form form={form} {...FORM_ITEM_LAYOUT}>
+      <Form.Item
+        name="Select"
+        label="Select"
+      >
+        <Radio.Group onChange={onChange} value={radioValue}  style={{width:'110%'}}>
+          <Radio value={'path'} onClick={() => setRadioValue('path')}>Config Path</Radio>
+          <Radio value={'custom'} onClick={() => setRadioValue('Without path')}>Custom text</Radio>

Review Comment:
   Whether onChange on `Radio.Group` and onClick on `Radio` will be duplicated?



##########
web/src/components/Plugin/UI/authz-casbin.tsx:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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 { useIntl } from "umi";
+import Form, { FormInstance } from "antd/es/form";
+import React, { useState } from "react";
+import { Radio, Input } from "antd";
+
+type Props = {
+  form: FormInstance;
+  schema: Record<string, any> | undefined;
+  ref?: any;
+  disabled?: boolean;
+}
+
+const FORM_ITEM_LAYOUT = {
+  labelCol: {
+    span: 7,
+  },
+  wrapperCol: {
+    span: 8,
+  },
+};
+
+const AuthzCasbin: React.FC<Props> = ({ form, schema }) => {
+  const { formatMessage } = useIntl();
+  const properties = schema?.properties
+  const [radioValue, setRadioValue] = useState('path');
+  const onChange = (e: any) => {
+    setRadioValue(e.target.value);
+  };
+
+  return (
+    <Form form={form} {...FORM_ITEM_LAYOUT}>
+      <Form.Item
+        name="Select"
+        label="Select"
+      >
+        <Radio.Group onChange={onChange} value={radioValue}  style={{width:'110%'}}>
+          <Radio value={'path'} onClick={() => setRadioValue('path')}>Config Path</Radio>

Review Comment:
   ```suggestion
             <Radio value='path' onClick={() => setRadioValue('path')}>Config Path</Radio>
   ```



-- 
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: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix-dashboard] guoqqqi commented on a diff in pull request #2290: feat: added form function to authz-casbin plugin

Posted by GitBox <gi...@apache.org>.
guoqqqi commented on code in PR #2290:
URL: https://github.com/apache/apisix-dashboard/pull/2290#discussion_r886864312


##########
web/src/components/Plugin/UI/authz-casbin.tsx:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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 { useIntl } from "umi";
+import Form, { FormInstance } from "antd/es/form";
+import React, { useState } from "react";
+import { Radio, Input } from "antd";
+
+type Props = {
+  form: FormInstance;
+  schema: Record<string, any> | undefined;
+  ref?: any;
+  disabled?: boolean;
+}
+
+const FORM_ITEM_LAYOUT = {
+  labelCol: {
+    span: 7,
+  },
+  wrapperCol: {
+    span: 8,
+  },
+};
+
+const AuthzCasbin: React.FC<Props> = ({ form, schema }) => {
+  const { formatMessage } = useIntl();
+  const properties = schema?.properties
+  const [radioValue, setRadioValue] = useState('path');
+  const onChange = (e: any) => {
+    setRadioValue(e.target.value);
+  };
+
+  return (
+    <Form form={form} {...FORM_ITEM_LAYOUT}>
+      <Form.Item
+        name="Select"
+        label="Select"
+      >
+        <Radio.Group onChange={onChange} value={radioValue}  style={{width:'110%'}}>
+          <Radio value={'path'} onClick={() => setRadioValue('path')}>Config Path</Radio>
+          <Radio value={'custom'} onClick={() => setRadioValue('Without path')}>Custom text</Radio>
+        </Radio.Group>
+      </Form.Item>
+      {radioValue === 'path' ?
+        <>
+          < Form.Item
+            name="model_path"
+            label="model_path"
+            rules={
+              [
+                {
+                  required: true,
+                  message: `${formatMessage({ id: 'component.global.pleaseEnter' })} model_path`,
+                },
+              ]}
+            initialValue={properties.model_path.default}
+            tooltip={formatMessage({ id: 'component.pauginForm.authz-casbin.model_path.tooltip' })}
+          >
+            <Input />
+          </Form.Item >
+          <Form.Item
+            name="policy_path"
+            label="policy_path"
+

Review Comment:
   Excess space



##########
web/src/components/Plugin/UI/authz-casbin.tsx:
##########
@@ -0,0 +1,155 @@
+/*
+ * 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 { useIntl } from "umi";
+import Form, { FormInstance } from "antd/es/form";
+import React, { useState } from "react";
+import { Radio, Input } from "antd";
+
+type Props = {
+  form: FormInstance;
+  schema: Record<string, any> | undefined;
+  ref?: any;
+  disabled?: boolean;
+}
+
+const FORM_ITEM_LAYOUT = {
+  labelCol: {
+    span: 7,
+  },
+  wrapperCol: {
+    span: 8,
+  },
+};
+
+const AuthzCasbin: React.FC<Props> = ({ form, schema }) => {
+  const { formatMessage } = useIntl();
+  const properties = schema?.properties
+  const [radioValue, setRadioValue] = useState('path');
+  const onChange = (e: any) => {
+    setRadioValue(e.target.value);
+  };
+
+  return (
+    <Form form={form} {...FORM_ITEM_LAYOUT}>
+      <Form.Item
+        name="Select"
+        label="Select"
+      >
+        <Radio.Group onChange={onChange} value={radioValue}  style={{width:'110%'}}>
+          <Radio value={'path'} onClick={() => setRadioValue('path')}>Config Path</Radio>
+          <Radio value={'custom'} onClick={() => setRadioValue('Without path')}>Custom text</Radio>
+        </Radio.Group>
+      </Form.Item>
+      {radioValue === 'path' ?
+        <>
+          < Form.Item
+            name="model_path"
+            label="model_path"
+            rules={
+              [
+                {
+                  required: true,
+                  message: `${formatMessage({ id: 'component.global.pleaseEnter' })} model_path`,
+                },
+              ]}
+            initialValue={properties.model_path.default}
+            tooltip={formatMessage({ id: 'component.pauginForm.authz-casbin.model_path.tooltip' })}
+          >
+            <Input />
+          </Form.Item >
+          <Form.Item
+            name="policy_path"
+            label="policy_path"
+
+            rules={[
+              {
+                required: true,
+                message: `${formatMessage({ id: 'component.global.pleaseEnter' })} policy_path`,
+              },
+            ]}
+            initialValue={properties.policy_path.default}
+            tooltip={formatMessage({ id: 'compoenet.pauginForm.authz-casbin.policy_path.tooltip' })}
+          >
+

Review Comment:
   Please format your code to remove the extra spaces before submitting your PR.



-- 
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: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix-dashboard] juxianzheng closed pull request #2290: feat: added form function to authz-casbin plugin

Posted by GitBox <gi...@apache.org>.
juxianzheng closed pull request #2290: feat: added form function to authz-casbin plugin
URL: https://github.com/apache/apisix-dashboard/pull/2290


-- 
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: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix-dashboard] juxianzheng commented on pull request #2290: feat: added form function to authz-casbin plugin

Posted by GitBox <gi...@apache.org>.
juxianzheng commented on PR #2290:
URL: https://github.com/apache/apisix-dashboard/pull/2290#issuecomment-1103584691

   Brother, you can say something clear?


-- 
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: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix-dashboard] guoqqqi commented on pull request #2290: feat: added form function to authz-casbin plugin

Posted by GitBox <gi...@apache.org>.
guoqqqi commented on PR #2290:
URL: https://github.com/apache/apisix-dashboard/pull/2290#issuecomment-1103497619

   ![image](https://user-images.githubusercontent.com/72343596/164159612-605a9486-a26e-44ba-96fa-0f3c19b5fcc3.png)
   should fix this test


-- 
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: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix-dashboard] LiteSun commented on a diff in pull request #2290: feat: added form function to authz-casbin plugin

Posted by GitBox <gi...@apache.org>.
LiteSun commented on code in PR #2290:
URL: https://github.com/apache/apisix-dashboard/pull/2290#discussion_r886254406


##########
web/cypress/integration/plugin/authz-casbin.spec.js:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.
+ */
+/* eslint-disable no-undef */
+
+context('text authz casbin plugin', () => {
+  const timeout = 5000;
+
+  const selector = {
+    pluginCardBordered: '.ant-card-bordered',
+    drawer: '.ant-drawer-content',
+    selectDropdown: '.ant-select-dropdown',
+    monacoMode: "[data-cy='monaco-mode']",
+    selectJSON: '.ant-select-dropdown [label=JSON]',
+    drawerFooter: '.ant-drawer-footer',
+    disabledSwitcher: '#disable',
+    checkedSwitcher: '.ant-switch-checked',
+    refresh: '.anticon-reload',
+    empty: '.ant-empty-normal',
+    conmodelPath: '#model_path',
+    conpolicyPath: '#policy_path',
+    conmodel: '#model',
+    conpolicy: '#policy',
+    username: '#username'
+  };
+
+  const data = {
+    authzCasbin: 'authz-casbin',
+    conmodelPath: '#/path/to/model.conf',
+    conpolicyPath: '#/path/to/policy.csv',
+    conmodel: '#/to/model.conf',
+    conpolicy: '#/to/policy.csv',
+    conusername: '#user',
+  };
+
+  beforeEach(() => {

Review Comment:
   ```suggestion
     before(() => {
   ```
   don't need to login before each case, using before will be better.



-- 
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: notifications-unsubscribe@apisix.apache.org

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