title: i18n()

in src/views/knowledge-base/knowledge-base-actions.ts [455:563]


      title: i18n('New Article'),
      execute: onCreateArticle,
    });
  }

  const selectedAction = await showActionSheet(actions, showActionSheetWithOptions, '');

  if (selectedAction && selectedAction.execute) {
    selectedAction.execute();
  }
};

const toggleAllProjects = (
  collapse: boolean = true,
): ReduxAction => async (
  dispatch: ReduxThunkDispatch,
  getState: ReduxStateGetter,
) => {
  const {articles, articlesList} = getState().articles;
  logEvent({
    message: `${collapse ? 'Collapse' : 'Expand'} all Knowledge base projects`,
    analyticsId: ANALYTICS_ARTICLES_PAGE,
  });
  const updatedProjectData = (articles || []).reduce(
    (list: ProjectArticlesData[], item: ProjectArticlesData) =>
      list.concat(toggleProjectDataItem(item, true)),
    [],
  );
  dispatch(storeProjectData(updatedProjectData));
  const updatedArticlesList: ArticlesList = (articlesList || []).reduce(
    (list: ArticlesList, item: ArticlesListItem) =>
      list.concat(treeHelper.toggleProject(item, collapse)),
    [],
  );
  dispatch(storeArticlesList(updatedArticlesList));
  notify(
    `${collapse ? i18n('Projects collapsed') : i18n('Projects expanded')}`,
  );
};

export type KnowledgeBaseActions = {
  clearUserLastVisitedArticle: typeof clearUserLastVisitedArticle;
  updateProjectsFavorites: typeof updateProjectsFavorites;
  createList: typeof createArticleList;
  filterArticles: typeof filterArticles;
  getArticleChildren: typeof getArticleChildren;
  loadArticleList: typeof loadArticleList;
  loadArticlesDrafts: typeof loadArticlesDrafts;
  getArticlesQuery: typeof getArticlesQuery;
  loadCachedArticleList: typeof loadCachedArticleList;
  setNoFavoriteProjects: typeof setNoFavoriteProjects;
  showContextActions: typeof showContextActions;
  toggleAllProjects: typeof toggleAllProjects;
  toggleProjectFavorite: typeof toggleProjectFavorite;
  toggleProjectVisibility: typeof toggleProjectVisibility;
};
export {
  clearUserLastVisitedArticle,
  updateProjectsFavorites,
  createArticleList,
  filterArticles,
  getArticleChildren,
  loadArticleList,
  loadArticlesDrafts,
  getArticlesQuery,
  loadCachedArticleList,
  setNoFavoriteProjects,
  showContextActions,
  toggleAllProjects,
  toggleProjectFavorite,
  toggleProjectVisibility,
};

async function setArticlesCache(
  articles: ProjectArticlesData[] | null | undefined,
) {
  await flushStoragePart({
    articles,
  });
}

async function setArticlesListCache(articlesList: ArticlesList | null) {
  await flushStoragePart({
    articlesList,
  });
}

function storeArticlesList(articlesList: ArticlesList | null) {
  return async (dispatch: ReduxThunkDispatch) => {
    dispatch(setList(articlesList));
    setArticlesListCache(articlesList);
  };
}

function storeProjectData(
  projectArticlesData: ProjectArticlesData[] | null,
) {
  return async (dispatch: ReduxThunkDispatch) => {
    dispatch(setArticles(projectArticlesData));
    await setArticlesCache(projectArticlesData);
  };
}

function getProjectDataPromises(
  api: Api,
  projects: ArticleProject[],
): Array<Promise<ProjectArticlesData>> {
  return projects.map(async (project: ArticleProject) => {
    if (project.articles.collapsed) {