当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mobx-state-tree.getEnv函数代码示例

本文整理汇总了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;
};
开发者ID:Othyus,项目名称:grafana,代码行数:29,代码来源:PermissionsStore.ts

示例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);
    },
  }));
开发者ID:xiequanqin,项目名称:grafana,代码行数:33,代码来源:NavStore.ts

示例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 = '';
 }),
开发者ID:xiequanqin,项目名称:grafana,代码行数:7,代码来源:AlertRule.ts

示例4: flow

    update: flow(function* load() {
      const backendSrv = getEnv(self).backendSrv;

      yield backendSrv.put(`/api/teams/${self.id}`, {
        name: self.name,
        email: self.email,
      });
    }),
开发者ID:cboggs,项目名称:grafana,代码行数:8,代码来源:TeamsStore.ts

示例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`;
    }),
开发者ID:GPegel,项目名称:grafana,代码行数:9,代码来源:FolderStore.ts

示例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`;
    }),
开发者ID:InvariantIO,项目名称:grafana,代码行数:10,代码来源:FolderStore.ts


注:本文中的mobx-state-tree.getEnv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。