How to use the react-orbitjs.idFromRecordIdentity function in react-orbitjs

To help you get started, we’ve selected a few react-orbitjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / projects / show / overview / products / index.tsx View on Github external
export default function Products({ project }: IProps) {
  const { t } = useTranslations();
  const {
    dataStore,
    subscriptions: { products, organization },
  } = useOrbit({
    products: (q) => q.findRelatedRecords(project, 'products'),
    organization: (q) => q.findRelatedRecord(project, 'organization'),
    // cache busters
    userTasks: (q) => q.findRecords('userTask'),
    project: (q) => q.findRecord(project),
  });

  useLiveData(`projects/${idFromRecordIdentity(dataStore, project)}`);
  useLiveData(`products`);
  useLiveData(`user-tasks`);

  let productList;

  if (isEmpty(products)) {
    productList = (
      <div>
        <span data-test-project-product-empty-text="">{t('project.products.empty')}</span>
      </div>
    );
  } else {
    productList = products.map((product) =&gt; );
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / projects / show / display.tsx View on Github external
export default function ProjectShowDisplay({ project }: IProps) {
  const { t } = useTranslations();
  const { dataStore } = useOrbit();
  const { currentUser } = useCurrentUser();
  const { updateOwner, toggleArchiveProject } = useDataActions(project);
  const url = `projects/${idFromRecordIdentity(dataStore, project)}`;
  useLiveData(url);

  const claimOwnership = async () => {
    try {
      await updateOwner(currentUser);

      toast.success(t('project.claimSuccess'));
    } catch (e) {
      toast.error(e);
    }
  };

  if (!project || !project.attributes) {
    return null;
  }
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / projects / list / header / bulk-product-selection / product-selection.tsx View on Github external
    const ids = selectedRows.map((project) => idFromRecordIdentity(dataStore, project));
    const response = await authenticatedPost(`/api/product-actions`, {
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / ui / routes / projects / show / overview / products / selection-manager / product-selection.tsx View on Github external
const pollCallback = useCallback(async () => {
    if (workflowProjectUrl) {
      return true;
    }

    try {
      const url = `projects/${idFromRecordIdentity(dataStore, project)}`;
      const response = await authenticatedGet(`/api/${url}`);
      const json = await response.json();

      await pushPayload(dataStore, json);

      const fromCache = dataStore.cache.query((q) => q.findRecord(project));

      const { workflowProjectUrl } = attributesFor(fromCache);

      return workflowProjectUrl;
    } catch (e) {
      return false;
    }
  }, [dataStore, project, workflowProjectUrl]);
github sillsdev / appbuilder-portal / source / SIL.AppBuilder.Portal.Frontend / src / data / containers / resources / user-task / index.ts View on Github external
const pathToWorkflow = (task: TaskResource) => {
    if (!task) return null;

    const [product, , workflow] = relationsFromPath(dataStore, task, [
      'product',
      'productDefinition',
      'workflow',
    ]);
    const id = idFromRecordIdentity(dataStore, product);
    const { workflowBusinessFlow } = attributesFor(workflow);

    return `/flow/${workflowBusinessFlow}/${id}`;
  };