@sanity/workflow-studio-plugin 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -484,9 +484,12 @@ function formatShortAgo(value, now) {
484
484
  }
485
485
 
486
486
  function formatShortSpan(value, now) {
487
- const d = new Date(value);
488
- if (Number.isNaN(d.getTime())) return "—";
489
- const seconds = Math.floor((now.getTime() - d.getTime()) / 1e3);
487
+ return shortSpanOf(new Date(value), now);
488
+ }
489
+
490
+ function shortSpanOf(from, now) {
491
+ if (from === void 0 || Number.isNaN(from.getTime())) return "—";
492
+ const seconds = Math.floor((now.getTime() - from.getTime()) / 1e3);
490
493
  if (seconds < 60) return "now";
491
494
  const minutes = Math.floor(seconds / 60);
492
495
  if (minutes < 60) return `${minutes}m`;
@@ -801,6 +804,10 @@ function assigneesOf(entries) {
801
804
  return entries.flatMap(entry => entry._type === "assignees" ? entry.value : []);
802
805
  }
803
806
 
807
+ function userIdsOf(assignees) {
808
+ return assignees.flatMap(assignee => assignee.type === "user" ? [ assignee.id ] : []);
809
+ }
810
+
804
811
  function assigneeEdit(current, next) {
805
812
  const changed = changedAssignee(current, next);
806
813
  if (changed !== void 0) return next.some(item => sameAssignee(item, changed)) ? {
@@ -980,8 +987,15 @@ const ACTIVITY_STATUS_LABEL = {
980
987
  skipped: "Skipped"
981
988
  };
982
989
 
990
+ function isHandsOff(args) {
991
+ return args.classification === "autonomous" && args.completesWithoutCaller === "yes";
992
+ }
993
+
983
994
  function showsAutomatedPill(activityEval) {
984
- return !isTerminalActivityStatus(activityEval.status) && activityEval.classification === "autonomous" && activityEval.autonomy.completesWithoutCaller === "yes";
995
+ return !isTerminalActivityStatus(activityEval.status) && isHandsOff({
996
+ classification: activityEval.classification,
997
+ completesWithoutCaller: activityEval.autonomy.completesWithoutCaller
998
+ });
985
999
  }
986
1000
 
987
1001
  function showsBlockedTag(activityEval) {
@@ -1394,6 +1408,10 @@ function disambiguatedNames(displays) {
1394
1408
  return displays.map(display => (counts.get(display.name) ?? 0) < 2 || display.loginProvider === void 0 ? display.name : `${display.name} (${providerTitle(display.loginProvider) ?? display.loginProvider})`);
1395
1409
  }
1396
1410
 
1411
+ function uniqueIds(ids) {
1412
+ return [ ...new Set(ids) ];
1413
+ }
1414
+
1397
1415
  function useUserDisplays(ids) {
1398
1416
  const {members: members} = useProjectMembers(), {users: users} = useStudioProjectUsers(), meRaw = useCurrentUser(), me = useMemo(() => meRaw === null ? null : {
1399
1417
  ...meRaw,
@@ -4556,7 +4574,7 @@ function AvatarButton({avatar: avatar, onClick: onClick, onMouseDown: onMouseDow
4556
4574
  }
4557
4575
 
4558
4576
  function RowAssignees({assignees: assignees, hint: hint}) {
4559
- const ids = assignees.flatMap(item => item.type === "user" ? [ item.id ] : []), vocabulary = useProjectMembers(), roles = assignees.flatMap(item => item.type === "role" ? [ memberRoleFor(vocabulary, item.role) ] : []), displays = useUserDisplays(ids);
4577
+ const ids = userIdsOf(assignees), vocabulary = useProjectMembers(), roles = assignees.flatMap(item => item.type === "role" ? [ memberRoleFor(vocabulary, item.role) ] : []), displays = useUserDisplays(ids);
4560
4578
  if (ids.length === 0 && roles.length === 0) return null;
4561
4579
  const bothKinds = roles.length > 0 && displays.length > 0;
4562
4580
  /* @__PURE__ */
@@ -5813,6 +5831,13 @@ function GroupHeading({busy: busy, count: count, title: title, end: end}) {
5813
5831
 
5814
5832
  const EMPTY_METRIC_OPACITY = .5;
5815
5833
 
5834
+ function labelledImgProps(label) {
5835
+ return label === void 0 ? {} : {
5836
+ "aria-label": label,
5837
+ role: "img"
5838
+ };
5839
+ }
5840
+
5816
5841
  function MetricText({children: children, tone: tone}) {
5817
5842
  return tone === void 0 ? /* @__PURE__ */ jsx(Text, {
5818
5843
  muted: !0,
@@ -5825,33 +5850,41 @@ function MetricText({children: children, tone: tone}) {
5825
5850
  });
5826
5851
  }
5827
5852
 
5828
- function MetricPair({Icon: Icon, empty: empty, face: face, tone: tone, value: value}) {
5853
+ function MetricPair({face: face, ...lockup}) {
5829
5854
  /* @__PURE__ */
5830
5855
  return jsx(HoverHint, {
5831
5856
  ...face,
5832
- children: /* @__PURE__ */ jsxs(Flex, {
5833
- align: "center",
5834
- gap: 2,
5835
- style: empty ? {
5836
- opacity: EMPTY_METRIC_OPACITY
5837
- } : void 0,
5838
- children: [
5839
- /* @__PURE__ */ jsx(MetricText, {
5840
- tone: tone,
5841
- children: /* @__PURE__ */ jsx(Icon, {
5842
- style: {
5843
- color: "inherit"
5844
- }
5845
- })
5846
- }),
5847
- /* @__PURE__ */ jsx(MetricText, {
5848
- tone: tone,
5849
- children: value
5850
- }) ]
5857
+ children: /* @__PURE__ */ jsx(MetricLockup, {
5858
+ ...lockup
5851
5859
  })
5852
5860
  });
5853
5861
  }
5854
5862
 
5863
+ function MetricLockup({Icon: Icon, empty: empty, label: label, tone: tone, value: value}) {
5864
+ /* @__PURE__ */
5865
+ return jsxs(Flex, {
5866
+ align: "center",
5867
+ gap: 2,
5868
+ style: empty ? {
5869
+ opacity: EMPTY_METRIC_OPACITY
5870
+ } : void 0,
5871
+ ...labelledImgProps(label),
5872
+ children: [
5873
+ /* @__PURE__ */ jsx(MetricText, {
5874
+ tone: tone,
5875
+ children: /* @__PURE__ */ jsx(Icon, {
5876
+ style: {
5877
+ color: "inherit"
5878
+ }
5879
+ })
5880
+ }),
5881
+ /* @__PURE__ */ jsx(MetricText, {
5882
+ tone: tone,
5883
+ children: value
5884
+ }) ]
5885
+ });
5886
+ }
5887
+
5855
5888
  function AlertGlyph({Icon: Icon, hint: hint, label: label, tone: tone}) {
5856
5889
  /* @__PURE__ */
5857
5890
  return jsx(HoverHint, {
@@ -5860,10 +5893,7 @@ function AlertGlyph({Icon: Icon, hint: hint, label: label, tone: tone}) {
5860
5893
  size: 1,
5861
5894
  tone: tone,
5862
5895
  children: /* @__PURE__ */ jsx(Icon, {
5863
- ...label === void 0 ? {} : {
5864
- "aria-label": label,
5865
- role: "img"
5866
- },
5896
+ ...labelledImgProps(label),
5867
5897
  style: {
5868
5898
  color: "inherit"
5869
5899
  }
@@ -5872,6 +5902,37 @@ function AlertGlyph({Icon: Icon, hint: hint, label: label, tone: tone}) {
5872
5902
  });
5873
5903
  }
5874
5904
 
5905
+ function AlertChip({Icon: Icon, hint: hint, label: label, tone: tone}) {
5906
+ const glyph = useTextIconSize(), disc = glyph + useSpaceToken(1) * 2;
5907
+ /* @__PURE__ */
5908
+ return jsx(HoverHint, {
5909
+ text: hint,
5910
+ children: /* @__PURE__ */ jsx(Card, {
5911
+ radius: "full",
5912
+ style: {
5913
+ alignItems: "center",
5914
+ display: "flex",
5915
+ height: disc,
5916
+ justifyContent: "center",
5917
+ width: disc
5918
+ },
5919
+ tone: tone,
5920
+ children: /* @__PURE__ */ jsx(TextWithTone, {
5921
+ size: 1,
5922
+ tone: tone,
5923
+ children: /* @__PURE__ */ jsx(Icon, {
5924
+ ...labelledImgProps(label),
5925
+ style: {
5926
+ color: "inherit",
5927
+ height: glyph,
5928
+ width: glyph
5929
+ }
5930
+ })
5931
+ })
5932
+ })
5933
+ });
5934
+ }
5935
+
5875
5936
  function ActivityDateControl({instanceId: instanceId, state: state, surface: surface, dueDates: dueDates}) {
5876
5937
  const editField = useEditField(surface), {save: save} = useSaveField({
5877
5938
  instanceId: instanceId
@@ -6485,7 +6546,7 @@ function AvatarCapAligned({children: children}) {
6485
6546
  }
6486
6547
 
6487
6548
  function AssigneesFace({assignees: assignees}) {
6488
- const vocabulary = useProjectMembers(), userIds = assignees.flatMap(a => a.type === "user" ? [ a.id ] : []), roles = assignees.flatMap(a => a.type === "role" ? [ roleLabelFor(vocabulary, a.role) ] : []);
6549
+ const vocabulary = useProjectMembers(), userIds = userIdsOf(assignees), roles = assignees.flatMap(a => a.type === "role" ? [ roleLabelFor(vocabulary, a.role) ] : []);
6489
6550
  /* @__PURE__ */
6490
6551
  return jsxs(Fragment, {
6491
6552
  children: [ userIds.length > 0 ? /* @__PURE__ */ jsx(AvatarCapAligned, {
@@ -11645,4 +11706,4 @@ function WorkflowRootInput(props) {
11645
11706
  });
11646
11707
  }
11647
11708
 
11648
- export { AbortWorkflowDialog, ActivityDetailDialog, ActivityLog, AgoStamp, AlertGlyph, CodeChip, CountedHeading, DismissablePopover, DocPreviewLink, DocRefFace, EmptyState, HoverHint, InstanceFaultNote, InstanceSnapshotBody, InvalidDocNotice, LoadingRow, LogEventOnMount, MetaRow, MetricPair, NoteBanner, RUN_SEARCH_PARAM, RoleAssignedNotice, RowAssignees, SpinnerSlot, TOOL_TABS, TabSwitch, UnreadableDocsNote, WORKFLOW_API_VERSION, WorkflowBoardWorkflowSelected, WorkflowDefinitionDetailViewed, WorkflowInstanceDetailViewed, WorkflowTitleSeedDrifted, WorkflowToolOpened, assigneesOf, countBy, definitionFingerprint, definitionsRouteOf, describeError, dueDatesOf, findActivity, formatShortDateTime, formatTimeAgo, gdrLocality, identityOf, instanceBreadcrumb, instanceTitle, isDueDatePast, isEvaluationStale, isLiveEntry, isOpenActivityStatus, landingState, mappingIssueDetail, namesNoDeployedDefinition, openActivityGone, openableSchemaType, parseStoredDateValue, readDeployedDefinitions, stageTitle, tabSelectionNavigates, toolRoute, toolTabState, useAssignmentIdentity, useAvatarSize, useCapTrimFor, useContainerToken, useCurrentUserId, useDefinition, useLogEventOnMount, useMinuteClock, useProjectMembers, useRadiusToken, useReleaseTitles, useSpaceToken, useTextIconSize, useUserDisplays, useWorkflowContext, useWorkflowInstanceEntry, workflowDefaultDocumentNode, workflowState, workflowStudioPlugin, workflowsView };
11709
+ export { AbortWorkflowDialog, ActivityDetailDialog, ActivityLog, AgoStamp, AlertChip, AlertGlyph, CodeChip, CountedHeading, DismissablePopover, DocPreviewLink, DocRefFace, EmptyState, HoverHint, InstanceFaultNote, InstanceSnapshotBody, InvalidDocNotice, LoadingRow, LogEventOnMount, MetaRow, MetricLockup, MetricPair, NoteBanner, RUN_SEARCH_PARAM, RoleAssignedNotice, SpinnerSlot, TOOL_TABS, TabSwitch, UnreadableDocsNote, WORKFLOW_API_VERSION, WorkflowBoardWorkflowSelected, WorkflowDefinitionDetailViewed, WorkflowInstanceDetailViewed, WorkflowTitleSeedDrifted, WorkflowToolOpened, activityLabel, assigneesOf, countBy, definitionFingerprint, definitionsRouteOf, describeError, disambiguatedNames, dueDatesOf, findActivity, formatShortDateTime, formatTimeAgo, gdrLocality, identityOf, instanceBreadcrumb, instanceTitle, isDueDatePast, isEvaluationStale, isHandsOff, isLiveEntry, isOpenActivityStatus, landingState, mappingIssueDetail, namesNoDeployedDefinition, openActivityGone, openableSchemaType, parseStoredDateValue, readDeployedDefinitions, shortSpanOf, stageTitle, tabSelectionNavigates, toolRoute, toolTabState, uniqueIds, useAssignmentIdentity, useAvatarSize, useCapTrimFor, useContainerToken, useCurrentUserId, useDefinition, useLogEventOnMount, useMinuteClock, useProjectMembers, useRadiusToken, useReleaseTitles, useSpaceToken, useTextIconSize, useUserDisplays, useWorkflowContext, useWorkflowInstanceEntry, userIdsOf, workflowDefaultDocumentNode, workflowState, workflowStudioPlugin, workflowsView };