@ynput/ayon-addon-dev 0.2.0 → 0.3.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.
package/AGENTS.md CHANGED
@@ -185,6 +185,6 @@ import { ayonAddonLint } from '@ynput/ayon-addon-dev/eslint'
185
185
  export default defineConfig([..., ...ayonAddonLint])
186
186
  ```
187
187
 
188
- Flags imports that bypass AYON's copies: `react-router-dom`, `react-router` and `react-toastify`
189
- (use `@ynput/ayon-addon`), `@ynput/ayon-addon/host`, and a manifest importing
188
+ Flags imports that bypass AYON's copies: `react-router-dom`, `react-router`, `react-toastify` and
189
+ `use-query-params` (use `@ynput/ayon-addon`), `@ynput/ayon-addon/host`, and a manifest importing
190
190
  `@ynput/ayon-addon` instead of `@ynput/ayon-addon/manifest`.
package/dist/eslint.js CHANGED
@@ -17,6 +17,7 @@ export const ayonAddonLint = [
17
17
  viaAddonApi('react-router-dom', 'the router hooks and Link'),
18
18
  viaAddonApi('react-router', 'the router hooks and Link'),
19
19
  viaAddonApi('react-toastify', 'toast'),
20
+ viaAddonApi('use-query-params', 'useQueryParam, useQueryParams and the params'),
20
21
  {
21
22
  name: '@ynput/ayon-addon/host',
22
23
  message: '@ynput/ayon-addon/host is for AYON itself, not for addons.',
@@ -2,17 +2,19 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useCallback, createContext, useContext, useState, useMemo, useEffect, useSyncExternalStore, Component, StrictMode } from "react";
3
3
  import { createRoot } from "react-dom/client";
4
4
  import { provideHost, isKnownSlot, getRegistry, contributionTitle, getHost, registerManifest, setManifestsLoading } from "@ynput/ayon-addon/host";
5
- import { useGetProjectFoldersQuery, useGetCurrentUserQuery, usersApi, useListProjectsQuery, useGetEntitiesDetailsPanelQuery, useGetProjectQuery, useGetUsersAssigneeQuery, createStandaloneStore } from "@ynput/ayon-frontend-shared/api";
6
- import { AddonMoreMenu, AddonEntityPicker, SlicerHost, ProjectPageLayoutHost, JsonViewer, AddonButton, useAddonCustomizeSections, useAddonTableShortcuts, shortcutEntities, SettingsPanel, AddonDialog, useStudioPageSlotContext, useProjectPageSlotContext, SplitterStyles, LoginPage, AddonServices } from "@ynput/ayon-frontend-shared/components";
5
+ import { useGetProjectFoldersQuery, useGetCurrentUserQuery, usersApi, useListProjectsQuery, useGetEntitiesDetailsPanelQuery, useGetUsersQuery, useGetProjectQuery, useGetUsersAssigneeQuery, createStandaloneStore } from "@ynput/ayon-frontend-shared/api";
6
+ import { AddonMoreMenu, AddonEntityPicker, SlicerHost, ProjectPageLayoutHost, JsonViewer, AddonButton, useUserDetailsSlotContext, useAddonUserMenuItems, AddonUserDetailsSections, useAddonCustomizeSections, useAddonTableShortcuts, shortcutEntities, SettingsPanel, AddonDialog, useStudioPageSlotContext, useProjectPageSlotContext, SplitterStyles, LoginPage, AddonServices } from "@ynput/ayon-frontend-shared/components";
7
7
  import { useGlobalContext, usePowerpack, useMenuContext, useSettingsPanel, useScopedDetailsPanel, EntityUpdatesProvider, GlobalProvider, PowerpackProvider, MenuProvider, URIProvider, DetailsPanelProvider, PiPProvider, DeleteEntitiesProvider, SettingsPanelProvider, ProjectContextProvider, ProjectFoldersContextProvider } from "@ynput/ayon-frontend-shared/context";
8
8
  import { buildProjectsTableData, ProjectsTable, PROJECTS_LIST_MENU_ID, parseProjectFolderRowId } from "@ynput/ayon-frontend-shared/ProjectsTable";
9
9
  import { getProjectDisplayName, clearAccessToken, storeAccessToken } from "@ynput/ayon-frontend-shared/util";
10
10
  import { Button, Icon, Dropdown, Dialog, InputText } from "@ynput/ayon-react-components";
11
- import { useContributions, prefetchPiece, runContribution, EntityPicker, ContributionView } from "@ynput/ayon-addon";
11
+ import { useContributions, prefetchPiece, runContribution, EntityPicker, ContributionView, useUser as useUser$1 } from "@ynput/ayon-addon";
12
12
  import { useCreateContextMenu, ContextMenuProvider, GlobalContextMenu } from "@ynput/ayon-frontend-shared/ContextMenu";
13
13
  import { useDispatch, Provider } from "react-redux";
14
14
  import { BrowserRouter, useNavigate, useSearchParams, useParams, useLocation } from "react-router-dom";
15
15
  import { ToastContainer } from "react-toastify";
16
+ import { QueryParamProvider } from "use-query-params";
17
+ import { ReactRouter6Adapter } from "use-query-params/adapters/react-router-6";
16
18
  import { Splitter, SplitterPanel } from "primereact/splitter";
17
19
  import { useAddonTableColumns, useAddonEntityMenuItems, AddonColumnDataScope, ProjectDataProvider } from "@ynput/ayon-frontend-shared/ProjectTreeTable";
18
20
  import { SLOT_DOCS } from "@ynput/ayon-addon/check";
@@ -403,6 +405,19 @@ const SLOT_AREAS = [
403
405
  ]
404
406
  }
405
407
  ]
408
+ },
409
+ {
410
+ label: "Settings",
411
+ icon: "settings",
412
+ sections: [
413
+ {
414
+ label: "User details",
415
+ slots: [
416
+ { slot: "userDetails.section", label: "Sections" },
417
+ { slot: "userDetails.menuItem", label: "More menu" }
418
+ ]
419
+ }
420
+ ]
406
421
  }
407
422
  ];
408
423
  const slotPath = (slot) => {
@@ -415,7 +430,14 @@ const slotPath = (slot) => {
415
430
  return ["Other", slot];
416
431
  };
417
432
  const slotIcon = (slot) => SLOT_AREAS.find((area) => area.sections.some((s) => s.slots.some((x) => x.slot === slot)))?.icon || "extension";
418
- const NO_PROJECT = ["studio.page", "header.item", "projectList.menuItem", "app.service"];
433
+ const NO_PROJECT = [
434
+ "studio.page",
435
+ "header.item",
436
+ "projectList.menuItem",
437
+ "app.service",
438
+ "userDetails.section",
439
+ "userDetails.menuItem"
440
+ ];
419
441
  const PROJECTS = ["studio.page", "projectList.menuItem"];
420
442
  const ENTITIES = [
421
443
  "detailsPanel.tab",
@@ -436,7 +458,8 @@ const RUN = [
436
458
  "projectList.menuItem",
437
459
  "slicer.menuItem",
438
460
  "entityMenuItem",
439
- "table.shortcut"
461
+ "table.shortcut",
462
+ "userDetails.menuItem"
440
463
  ];
441
464
  const needsProject = (slot) => !!slot && !NO_PROJECT.includes(slot);
442
465
  const needsProjects = (slot) => !!slot && PROJECTS.includes(slot);
@@ -1215,6 +1238,59 @@ const ServiceStage = ({ contribution, selection }) => {
1215
1238
  useReport(contribution, context, true);
1216
1239
  return /* @__PURE__ */ jsx(ServiceNote, {});
1217
1240
  };
1241
+ const UserDetailsStage = ({ contribution }) => {
1242
+ const signedIn = useUser$1();
1243
+ const { data: users = [], isLoading } = useGetUsersQuery({ selfName: signedIn?.name });
1244
+ const [picked, setPicked] = useState();
1245
+ const fallback = useMemo(
1246
+ () => users.find((u) => u.name === signedIn?.name && !u.isService) ?? users.find((u) => !u.isService && u.active !== false),
1247
+ [users, signedIn?.name]
1248
+ );
1249
+ const target = users.find((u) => u.name === picked) ?? fallback;
1250
+ const selected = useMemo(() => target ? [target] : [], [target]);
1251
+ const context = useUserDetailsSlotContext(selected, false);
1252
+ const isMenuItem = contribution.slot === "userDetails.menuItem";
1253
+ useReport(contribution, context, !!target, isMenuItem);
1254
+ const { topItems, items } = useAddonUserMenuItems(context);
1255
+ if (isLoading) return /* @__PURE__ */ jsx(Hint, { children: "Loading users…" });
1256
+ if (!target) return /* @__PURE__ */ jsx(Hint, { children: "No users to show." });
1257
+ return /* @__PURE__ */ jsx("div", { className: "ayon-shell-body", style: { justifyContent: "flex-end" }, children: /* @__PURE__ */ jsxs(
1258
+ "div",
1259
+ {
1260
+ style: { width: "min(420px, 100%)", display: "flex", flexDirection: "column", gap: 4 },
1261
+ "data-shell-surface": "user-details",
1262
+ children: [
1263
+ /* @__PURE__ */ jsxs("div", { className: "ayon-shell-bar", children: [
1264
+ /* @__PURE__ */ jsx(
1265
+ Dropdown,
1266
+ {
1267
+ value: [target.name],
1268
+ options: users.map((u) => ({
1269
+ value: u.name,
1270
+ label: u.isService ? `${u.name} (service)` : u.attrib?.fullName || u.name
1271
+ })),
1272
+ search: true,
1273
+ onChange: (names) => setPicked(names[0]),
1274
+ style: { minWidth: 200 }
1275
+ }
1276
+ ),
1277
+ /* @__PURE__ */ jsx("span", { className: "spacer" }),
1278
+ [...topItems, ...items].map((item) => /* @__PURE__ */ jsx(
1279
+ Button,
1280
+ {
1281
+ icon: item.icon,
1282
+ label: item.label,
1283
+ variant: "text",
1284
+ onClick: () => item.onClick?.()
1285
+ },
1286
+ item.id
1287
+ ))
1288
+ ] }),
1289
+ /* @__PURE__ */ jsx(AddonUserDetailsSections, { context })
1290
+ ]
1291
+ }
1292
+ ) });
1293
+ };
1218
1294
  const HeaderStage = ({ contribution, selection }) => {
1219
1295
  const { contributions } = useContributions("header.item");
1220
1296
  const [context, setContext] = useState();
@@ -1468,6 +1544,9 @@ const Stage = ({
1468
1544
  return /* @__PURE__ */ jsx(TableStage, { ...props });
1469
1545
  case "app.service":
1470
1546
  return /* @__PURE__ */ jsx(ServiceStage, { ...props });
1547
+ case "userDetails.section":
1548
+ case "userDetails.menuItem":
1549
+ return /* @__PURE__ */ jsx(UserDetailsStage, { ...props });
1471
1550
  default:
1472
1551
  return /* @__PURE__ */ jsxs(Hint, { children: [
1473
1552
  "The shell has no stage for ",
@@ -1624,7 +1703,7 @@ const Shell = ({ options, mode }) => {
1624
1703
  return /* @__PURE__ */ jsxs(Provider, { store, children: [
1625
1704
  /* @__PURE__ */ jsx(SplitterStyles, {}),
1626
1705
  /* @__PURE__ */ jsxs(BrowserRouter, { children: [
1627
- mode === "live" ? /* @__PURE__ */ jsx(SignedIn, { options, children: /* @__PURE__ */ jsx(AppProviders, { children: /* @__PURE__ */ jsx(Workbench, { options, mode }) }) }) : /* @__PURE__ */ jsx(AppProviders, { children: /* @__PURE__ */ jsx(Workbench, { options, mode }) }),
1706
+ /* @__PURE__ */ jsx(QueryParamProvider, { adapter: ReactRouter6Adapter, options: { updateType: "replaceIn" }, children: mode === "live" ? /* @__PURE__ */ jsx(SignedIn, { options, children: /* @__PURE__ */ jsx(AppProviders, { children: /* @__PURE__ */ jsx(Workbench, { options, mode }) }) }) : /* @__PURE__ */ jsx(AppProviders, { children: /* @__PURE__ */ jsx(Workbench, { options, mode }) }) }),
1628
1707
  /* @__PURE__ */ jsx(ToastContainer, { position: "bottom-right", theme: "dark" })
1629
1708
  ] })
1630
1709
  ] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ynput/ayon-addon-dev",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Dev tooling for AYON addon frontends: Vite plugin, dev server, CLI, lint preset",
5
5
  "repository": {
6
6
  "type": "git",
@@ -41,16 +41,17 @@
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@module-federation/vite": ">=1.14",
44
- "@ynput/ayon-addon": "0.2.0",
44
+ "@ynput/ayon-addon": "0.4.0",
45
45
  "vite": ">=6",
46
- "@ynput/ayon-frontend-shared": ">=0.7.6",
47
- "@ynput/ayon-react-components": "^1.25.0",
46
+ "@ynput/ayon-frontend-shared": ">=0.8.1",
47
+ "@ynput/ayon-react-components": "^1.25.1",
48
48
  "primereact": ">=9",
49
49
  "react": ">=18",
50
50
  "react-dom": ">=18",
51
51
  "react-redux": ">=9",
52
52
  "react-router-dom": ">=7",
53
53
  "react-toastify": ">=9",
54
+ "use-query-params": ">=2",
54
55
  "playwright": ">=1.40",
55
56
  "@rtk-query/codegen-openapi": ">=2"
56
57
  },