mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Improve add model initialization
This commit is contained in:
parent
69ee6a6f7e
commit
5b27f939b8
@ -18,7 +18,11 @@ import * as ModelBackend from "./backend/ModelBackend";
|
|||||||
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
||||||
import * as Setting from "./Setting";
|
import * as Setting from "./Setting";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import TextArea from "antd/es/input/TextArea";
|
|
||||||
|
import {Controlled as CodeMirror} from "react-codemirror2";
|
||||||
|
import "codemirror/lib/codemirror.css";
|
||||||
|
|
||||||
|
require("codemirror/mode/properties/properties");
|
||||||
|
|
||||||
const {Option} = Select;
|
const {Option} = Select;
|
||||||
|
|
||||||
@ -135,9 +139,15 @@ class ModelEditPage extends React.Component {
|
|||||||
{Setting.getLabel(i18next.t("model:Model text"), i18next.t("model:Model text - Tooltip"))} :
|
{Setting.getLabel(i18next.t("model:Model text"), i18next.t("model:Model text - Tooltip"))} :
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={22}>
|
<Col span={22}>
|
||||||
<TextArea rows={10} value={this.state.model.modelText} onChange={e => {
|
<div style={{width: "100%"}} >
|
||||||
this.updateModelField("modelText", e.target.value);
|
<CodeMirror
|
||||||
}} />
|
value={this.state.model.modelText}
|
||||||
|
options={{mode: "properties", theme: "default"}}
|
||||||
|
onBeforeChange={(editor, data, value) => {
|
||||||
|
this.updateModelField("modelText", value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row style={{marginTop: "20px"}} >
|
<Row style={{marginTop: "20px"}} >
|
||||||
|
@ -22,6 +22,21 @@ import i18next from "i18next";
|
|||||||
import BaseListPage from "./BaseListPage";
|
import BaseListPage from "./BaseListPage";
|
||||||
import PopconfirmModal from "./common/modal/PopconfirmModal";
|
import PopconfirmModal from "./common/modal/PopconfirmModal";
|
||||||
|
|
||||||
|
const rbacModel = `[request_definition]
|
||||||
|
r = sub, obj, act
|
||||||
|
|
||||||
|
[policy_definition]
|
||||||
|
p = sub, obj, act
|
||||||
|
|
||||||
|
[role_definition]
|
||||||
|
g = _, _
|
||||||
|
|
||||||
|
[policy_effect]
|
||||||
|
e = some(where (p.eft == allow))
|
||||||
|
|
||||||
|
[matchers]
|
||||||
|
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act`;
|
||||||
|
|
||||||
class ModelListPage extends BaseListPage {
|
class ModelListPage extends BaseListPage {
|
||||||
newModel() {
|
newModel() {
|
||||||
const randomName = Setting.getRandomName();
|
const randomName = Setting.getRandomName();
|
||||||
@ -30,7 +45,7 @@ class ModelListPage extends BaseListPage {
|
|||||||
name: `model_${randomName}`,
|
name: `model_${randomName}`,
|
||||||
createdTime: moment().format(),
|
createdTime: moment().format(),
|
||||||
displayName: `New Model - ${randomName}`,
|
displayName: `New Model - ${randomName}`,
|
||||||
modelText: "",
|
modelText: rbacModel,
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user