當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。