本文整理汇总了TypeScript中mobx-state-tree.getEnv函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getEnv函数的具体用法?TypeScript getEnv怎么用?TypeScript getEnv使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getEnv函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getEnv
const updateItems = self => {
self.error = null;
const backendSrv = getEnv(self).backendSrv;
const updated = [];
for (let item of self.items) {
if (item.inherited) {
continue;
}
updated.push({
id: item.id,
userId: item.userId,
teamId: item.teamId,
role: item.role,
permission: item.permission,
});
}
let res;
try {
res = backendSrv.post(`/api/dashboards/id/${self.dashboardId}/acl`, {
items: updated,
});
} catch (error) {
self.error = error;
}
return res;
};
示例2: load
.actions(self => ({
load(...args) {
let children = getEnv(self).navTree;
let main, node;
let parents = [];
for (let id of args) {
node = children.find(el => el.id === id);
if (!node) {
throw new Error(`NavItem with id ${id} not found`);
}
children = node.children;
parents.push(node);
}
main = parents[parents.length - 2];
if (main.children) {
for (let item of main.children) {
item.active = false;
if (item.url === node.url) {
item.active = true;
}
}
}
self.main = NavItem.create(main);
self.node = NavItem.create(node);
},
}));
示例3: flow
togglePaused: flow(function* togglePaused() {
const backendSrv = getEnv(self).backendSrv;
const payload = { paused: !self.isPaused };
const res = yield backendSrv.post(`/api/alerts/${self.id}/pause`, payload);
setStateFields(self, res.state);
self.info = '';
}),
示例4: flow
update: flow(function* load() {
const backendSrv = getEnv(self).backendSrv;
yield backendSrv.put(`/api/teams/${self.id}`, {
name: self.name,
email: self.email,
});
}),
示例5: flow
saveFolder: flow(function* saveFolder(dashboard: any, options: any) {
const backendSrv = getEnv(self).backendSrv;
dashboard.title = self.folder.title.trim();
const res = yield backendSrv.saveFolder(dashboard, options);
self.folder.url = res.url;
return `${self.folder.url}/settings`;
}),
示例6: flow
saveFolder: flow(function* saveFolder(options: any) {
const backendSrv = getEnv(self).backendSrv;
self.folder.title = self.folder.title.trim();
const res = yield backendSrv.updateFolder(self.folder, options);
self.folder.url = res.url;
self.folder.version = res.version;
return `${self.folder.url}/settings`;
}),