@industry-theme/alexandria-panels 0.1.16 → 0.1.18

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.
@@ -1,11 +1,18 @@
1
1
  import React from 'react';
2
2
  import type { PanelComponentProps } from '../../types';
3
+ export interface WorkspaceCollectionPanelProps extends PanelComponentProps {
4
+ selectedRepository?: string;
5
+ }
3
6
  /**
4
7
  * WorkspaceCollectionPanel - Browser-based workspace repository management panel
5
8
  *
9
+ * Props:
10
+ * - selectedRepository: Full name of the selected repo (e.g., "owner/repo")
11
+ *
6
12
  * Features:
7
13
  * - List all repositories in a workspace
8
- * - Filter repositories by name/description
14
+ * - Toggle between name (A-Z) and recently updated sorting
15
+ * - Syncs selection with selectedRepository prop and repository:selected events
9
16
  * - Navigate to repository pages
10
17
  * - Remove repositories from workspace
11
18
  *
@@ -18,7 +25,7 @@ import type { PanelComponentProps } from '../../types';
18
25
  * - repository:navigate
19
26
  * - repository:removed
20
27
  */
21
- export declare const WorkspaceCollectionPanel: React.FC<PanelComponentProps>;
28
+ export declare const WorkspaceCollectionPanel: React.FC<WorkspaceCollectionPanelProps>;
22
29
  /**
23
30
  * Preview component for panel tabs/thumbnails
24
31
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/panels/WorkspaceCollectionPanel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AAUzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAqwBvD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAElE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,KAAK,CAAC,EAsCnD,CAAC;AAGF,YAAY,EACV,SAAS,EACT,wBAAwB,EACxB,0BAA0B,EAC1B,+BAA+B,EAC/B,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/panels/WorkspaceCollectionPanel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAC;AASzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAYvD,MAAM,WAAW,6BAA8B,SAAQ,mBAAmB;IACxE,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AA8uBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAAC,6BAA6B,CAE5E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B,EAAE,KAAK,CAAC,EAsCnD,CAAC;AAGF,YAAY,EACV,SAAS,EACT,wBAAwB,EACxB,0BAA0B,EAC1B,+BAA+B,EAC/B,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,SAAS,CAAC"}
@@ -3020,12 +3020,13 @@ function getLanguageColor$1(language) {
3020
3020
  const WorkspaceCollectionPanelContent = ({
3021
3021
  context,
3022
3022
  actions,
3023
- events
3023
+ events,
3024
+ selectedRepository
3024
3025
  }) => {
3025
3026
  var _a, _b, _c, _d;
3026
3027
  const { theme } = useTheme();
3027
- const [filter, setFilter] = useState("");
3028
3028
  const [selectedRepo, setSelectedRepo] = useState(null);
3029
+ const [sortField, setSortField] = useState("name");
3029
3030
  const panelActions = actions;
3030
3031
  const workspaceSlice = context.getSlice("workspace");
3031
3032
  const repositoriesSlice = context.getSlice("workspaceRepositories");
@@ -3033,24 +3034,44 @@ const WorkspaceCollectionPanelContent = ({
3033
3034
  const repositories = ((_b = repositoriesSlice == null ? void 0 : repositoriesSlice.data) == null ? void 0 : _b.repositories) ?? [];
3034
3035
  const isLoading = (workspaceSlice == null ? void 0 : workspaceSlice.loading) || (repositoriesSlice == null ? void 0 : repositoriesSlice.loading) || false;
3035
3036
  const error = ((_c = workspaceSlice == null ? void 0 : workspaceSlice.data) == null ? void 0 : _c.error) || ((_d = repositoriesSlice == null ? void 0 : repositoriesSlice.data) == null ? void 0 : _d.error);
3036
- const filteredRepositories = useMemo(() => {
3037
- let filtered = [...repositories];
3038
- if (filter.trim()) {
3039
- const normalizedFilter = filter.trim().toLowerCase();
3040
- filtered = filtered.filter((repo) => {
3041
- var _a2;
3042
- const haystack = [
3043
- repo.name,
3044
- repo.full_name,
3045
- ((_a2 = repo.owner) == null ? void 0 : _a2.login) ?? "",
3046
- repo.description ?? "",
3047
- repo.language ?? ""
3048
- ].join(" ").toLowerCase();
3049
- return haystack.includes(normalizedFilter);
3050
- });
3037
+ useEffect(() => {
3038
+ if (selectedRepository && repositories.length > 0) {
3039
+ const repo = repositories.find((r) => r.full_name === selectedRepository);
3040
+ if (repo) {
3041
+ setSelectedRepo(repo);
3042
+ }
3051
3043
  }
3052
- return filtered.sort((a, b) => a.name.localeCompare(b.name));
3053
- }, [repositories, filter]);
3044
+ }, [selectedRepository, repositories]);
3045
+ useEffect(() => {
3046
+ const unsubscribe = events.on("repository:selected", (event) => {
3047
+ var _a2;
3048
+ const payload = event.payload;
3049
+ if (((_a2 = payload == null ? void 0 : payload.repository) == null ? void 0 : _a2.full_name) && repositories.length > 0) {
3050
+ const repo = repositories.find((r) => {
3051
+ var _a3;
3052
+ return r.full_name === ((_a3 = payload.repository) == null ? void 0 : _a3.full_name);
3053
+ });
3054
+ if (repo) {
3055
+ setSelectedRepo(repo);
3056
+ }
3057
+ }
3058
+ });
3059
+ return () => unsubscribe();
3060
+ }, [events, repositories]);
3061
+ const toggleSort = () => {
3062
+ setSortField(sortField === "name" ? "updated" : "name");
3063
+ };
3064
+ const sortedRepositories = useMemo(() => {
3065
+ return [...repositories].sort((a, b) => {
3066
+ if (sortField === "name") {
3067
+ return a.name.localeCompare(b.name);
3068
+ } else {
3069
+ const aTime = new Date(a.pushed_at || a.updated_at || 0).getTime();
3070
+ const bTime = new Date(b.pushed_at || b.updated_at || 0).getTime();
3071
+ return bTime - aTime;
3072
+ }
3073
+ });
3074
+ }, [repositories, sortField]);
3054
3075
  const handleSelectRepository = useCallback(
3055
3076
  (repository) => {
3056
3077
  setSelectedRepo(repository);
@@ -3138,10 +3159,6 @@ const WorkspaceCollectionPanelContent = ({
3138
3159
  void handleRemoveRepository(repository);
3139
3160
  }
3140
3161
  }
3141
- }),
3142
- events.on(`${PANEL_ID$a}:filter`, (event) => {
3143
- var _a2;
3144
- setFilter(((_a2 = event.payload) == null ? void 0 : _a2.filter) || "");
3145
3162
  })
3146
3163
  ];
3147
3164
  return () => unsubscribers.forEach((unsub) => unsub());
@@ -3153,9 +3170,7 @@ const WorkspaceCollectionPanelContent = ({
3153
3170
  backgroundColor: theme.colors.backgroundSecondary
3154
3171
  };
3155
3172
  const contentContainerStyle = {
3156
- ...baseContainerStyle,
3157
- padding: "16px",
3158
- gap: "12px"
3173
+ ...baseContainerStyle
3159
3174
  };
3160
3175
  if (!workspace) {
3161
3176
  return /* @__PURE__ */ jsx("div", { style: baseContainerStyle, children: /* @__PURE__ */ jsx(
@@ -3273,69 +3288,71 @@ const WorkspaceCollectionPanelContent = ({
3273
3288
  ) });
3274
3289
  }
3275
3290
  return /* @__PURE__ */ jsxs("div", { style: contentContainerStyle, children: [
3276
- /* @__PURE__ */ jsxs("div", { children: [
3277
- /* @__PURE__ */ jsx(
3278
- "h3",
3279
- {
3280
- style: {
3281
- margin: "0 0 4px 0",
3282
- fontSize: `${theme.fontSizes[2]}px`,
3283
- fontWeight: theme.fontWeights.semibold,
3284
- color: theme.colors.text,
3285
- fontFamily: theme.fonts.body
3286
- },
3287
- children: workspace.name
3288
- }
3289
- ),
3290
- workspace.description && /* @__PURE__ */ jsx(
3291
- "p",
3292
- {
3293
- style: {
3294
- margin: 0,
3295
- fontSize: `${theme.fontSizes[1]}px`,
3296
- color: theme.colors.textSecondary,
3297
- fontFamily: theme.fonts.body
3298
- },
3299
- children: workspace.description
3300
- }
3301
- )
3302
- ] }),
3303
- repositories.length > 0 && /* @__PURE__ */ jsxs("div", { style: { position: "relative" }, children: [
3304
- /* @__PURE__ */ jsx(
3305
- Search,
3306
- {
3307
- size: 16,
3308
- style: {
3309
- position: "absolute",
3310
- top: "50%",
3311
- left: "12px",
3312
- transform: "translateY(-50%)",
3313
- color: theme.colors.textSecondary,
3314
- pointerEvents: "none"
3315
- }
3316
- }
3317
- ),
3318
- /* @__PURE__ */ jsx(
3319
- "input",
3320
- {
3321
- type: "text",
3322
- value: filter,
3323
- placeholder: "Filter repositories...",
3324
- onChange: (e) => setFilter(e.target.value),
3325
- style: {
3326
- width: "100%",
3327
- padding: "8px 12px 8px 36px",
3328
- borderRadius: "6px",
3329
- border: `1px solid ${theme.colors.border}`,
3330
- backgroundColor: theme.colors.background,
3331
- color: theme.colors.text,
3332
- fontSize: `${theme.fontSizes[1]}px`,
3333
- fontFamily: theme.fonts.body,
3334
- outline: "none"
3335
- }
3336
- }
3337
- )
3338
- ] }),
3291
+ /* @__PURE__ */ jsxs(
3292
+ "div",
3293
+ {
3294
+ style: {
3295
+ height: "40px",
3296
+ minHeight: "40px",
3297
+ padding: "0 16px",
3298
+ borderBottom: `1px solid ${theme.colors.border}`,
3299
+ display: "flex",
3300
+ alignItems: "center",
3301
+ gap: "8px"
3302
+ },
3303
+ children: [
3304
+ /* @__PURE__ */ jsx(Folder, { size: 18, color: theme.colors.primary }),
3305
+ /* @__PURE__ */ jsx(
3306
+ "span",
3307
+ {
3308
+ style: {
3309
+ fontSize: `${theme.fontSizes[2]}px`,
3310
+ fontWeight: theme.fontWeights.medium,
3311
+ color: theme.colors.text,
3312
+ fontFamily: theme.fonts.body
3313
+ },
3314
+ children: "Repositories"
3315
+ }
3316
+ ),
3317
+ repositories.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
3318
+ /* @__PURE__ */ jsx(
3319
+ "span",
3320
+ {
3321
+ style: {
3322
+ fontSize: `${theme.fontSizes[1]}px`,
3323
+ color: theme.colors.textSecondary,
3324
+ padding: "2px 8px",
3325
+ borderRadius: "12px",
3326
+ backgroundColor: theme.colors.background
3327
+ },
3328
+ children: repositories.length
3329
+ }
3330
+ ),
3331
+ /* @__PURE__ */ jsx(
3332
+ "button",
3333
+ {
3334
+ onClick: toggleSort,
3335
+ style: {
3336
+ marginLeft: "auto",
3337
+ padding: "4px 10px",
3338
+ borderRadius: "4px",
3339
+ border: `1px solid ${theme.colors.border}`,
3340
+ background: theme.colors.background,
3341
+ color: theme.colors.text,
3342
+ fontSize: `${theme.fontSizes[1]}px`,
3343
+ fontFamily: theme.fonts.body,
3344
+ cursor: "pointer",
3345
+ display: "flex",
3346
+ alignItems: "center",
3347
+ gap: "4px"
3348
+ },
3349
+ children: sortField === "name" ? "A-Z" : "Recent"
3350
+ }
3351
+ )
3352
+ ] })
3353
+ ]
3354
+ }
3355
+ ),
3339
3356
  error && /* @__PURE__ */ jsx(
3340
3357
  "div",
3341
3358
  {
@@ -3344,6 +3361,7 @@ const WorkspaceCollectionPanelContent = ({
3344
3361
  alignItems: "center",
3345
3362
  gap: "8px",
3346
3363
  padding: "10px 14px",
3364
+ margin: "8px 16px",
3347
3365
  borderRadius: "6px",
3348
3366
  backgroundColor: `${theme.colors.error || "#ef4444"}20`,
3349
3367
  color: theme.colors.error || "#ef4444",
@@ -3353,28 +3371,6 @@ const WorkspaceCollectionPanelContent = ({
3353
3371
  children: /* @__PURE__ */ jsx("span", { children: error })
3354
3372
  }
3355
3373
  ),
3356
- /* @__PURE__ */ jsxs(
3357
- "div",
3358
- {
3359
- style: {
3360
- fontSize: `${theme.fontSizes[0]}px`,
3361
- fontFamily: theme.fonts.body,
3362
- color: theme.colors.textSecondary,
3363
- textTransform: "uppercase",
3364
- letterSpacing: "0.5px"
3365
- },
3366
- children: [
3367
- filteredRepositories.length,
3368
- " ",
3369
- filteredRepositories.length === 1 ? "repository" : "repositories",
3370
- filter && repositories.length !== filteredRepositories.length && /* @__PURE__ */ jsxs("span", { children: [
3371
- " (filtered from ",
3372
- repositories.length,
3373
- ")"
3374
- ] })
3375
- ]
3376
- }
3377
- ),
3378
3374
  /* @__PURE__ */ jsxs(
3379
3375
  "div",
3380
3376
  {
@@ -3383,7 +3379,8 @@ const WorkspaceCollectionPanelContent = ({
3383
3379
  overflowY: "auto",
3384
3380
  display: "flex",
3385
3381
  flexDirection: "column",
3386
- gap: "4px"
3382
+ gap: "4px",
3383
+ padding: "8px"
3387
3384
  },
3388
3385
  children: [
3389
3386
  repositories.length === 0 && !isLoading && /* @__PURE__ */ jsxs(
@@ -3416,18 +3413,7 @@ const WorkspaceCollectionPanelContent = ({
3416
3413
  ]
3417
3414
  }
3418
3415
  ),
3419
- repositories.length > 0 && filteredRepositories.length === 0 && /* @__PURE__ */ jsx(
3420
- "div",
3421
- {
3422
- style: {
3423
- padding: "32px",
3424
- textAlign: "center",
3425
- color: theme.colors.textSecondary
3426
- },
3427
- children: /* @__PURE__ */ jsx("p", { style: { margin: 0 }, children: "No repositories match your filter." })
3428
- }
3429
- ),
3430
- filteredRepositories.map((repository) => /* @__PURE__ */ jsx(
3416
+ sortedRepositories.map((repository) => /* @__PURE__ */ jsx(
3431
3417
  WorkspaceCollectionRepositoryCard,
3432
3418
  {
3433
3419
  repository,