Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) => );
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;
}
const ids = selectedRows.map((project) => idFromRecordIdentity(dataStore, project));
const response = await authenticatedPost(`/api/product-actions`, {
const productIds = products.map((product) => idFromRecordIdentity(dataStore, product));
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]);
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}`;
};