Skip to content

mdl published by org#405

Merged
joaquimds merged 3 commits intomainfrom
mdl-published-by-org
Apr 7, 2026
Merged

mdl published by org#405
joaquimds merged 3 commits intomainfrom
mdl-published-by-org

Conversation

@Arbyhisenaj
Copy link
Copy Markdown
Member

Description

Motivation and Context

How Can It Be Tested?

How Will This Be Deployed?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I've checked the spec (e.g. Figma file) and documented any divergences.
  • My code follows the code style of this project.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I've updated the documentation accordingly.
  • Replace unused checkboxes with bullet points.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds publisher (organisation) information to data sources so the UI can display “Published by ”, particularly for the Movement Data Library and superadmin data source management.

Changes:

  • Extend dataSource tRPC outputs to include organisationName across relevant list/detail endpoints.
  • Display organisation/publisher metadata in DataSourceItem cards and the inspector’s DataRecordsPanel.
  • Show organisation name in superadmin data source tables and detail/preview views.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/server/trpc/routers/dataSource.ts Enriches data source queries/responses with organisationName; generalises addImportInfo typing.
src/components/DataSourceItem.tsx Adds OrganisationMeta and renders publisher info in multiple density variants.
src/app/(private)/map/[id]/components/InspectorPanel/DataRecordsPanel.tsx Shows publisher info at the bottom of the inspector panel.
src/app/(private)/hooks/useDataSourceListCache.ts Updates cache updater wrapper to include organisationName (but currently risks wiping it).
src/app/(private)/(dashboards)/superadmin/page.tsx Adds an “Organisation” column to the public data sources table.
src/app/(private)/(dashboards)/superadmin/data-sources/[id]/page.tsx Displays organisation name on the superadmin data source detail page.
src/app/(private)/(dashboards)/superadmin/data-sources/[id]/components/DefaultInspectorPreview.tsx Displays organisation name in the preview footer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +65 to 72
.selectFrom("dataSource")
.leftJoin("organisation", "dataSource.organisationId", "organisation.id")
.where("dataSource.public", "=", true)
.selectAll("dataSource")
.select(["organisation.name as organisationName"])
.execute();

const withImportInfo = await addImportInfo(dataSources);
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listPublic no longer calls findPublicDataSources(), so the findPublicDataSources import at the top of this file appears to be unused and may fail lint/TS builds with unused-import checks. Remove the unused import or switch back to using the repository helper.

Copilot uses AI. Check for mistakes.
Comment on lines 58 to 69
(old: DataSourceByOrganisation[] | undefined) =>
old?.map((ds) =>
ds.id === dataSourceId
? { ...ds, ...updater({ ...ds, organisationOverride: null }) }
? {
...ds,
...updater({
...ds,
organisationName: "",
organisationOverride: null,
}),
}
: ds,
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In updateDataSource, the wrapper passed to updater() overwrites organisationName with an empty string before calling the updater. If the updater returns { ...ds, ... } (common pattern), this will clear an existing organisation name in the cache until the next refetch. Preserve the existing organisationName when present (only default it when missing).

Copilot uses AI. Check for mistakes.
Comment on lines 73 to +83
{ queryKey: trpc.dataSource.byId.queryKey() },
(old: DataSourceById | undefined) => {
if (!old || old.id !== dataSourceId) return old;
return { ...old, ...updater({ ...old, organisationOverride: null }) };
return {
...old,
...updater({
...old,
organisationName: "",
organisationOverride: null,
}),
};
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue for the byId cache: organisationName is set to "" before calling updater(), which can wipe the cached organisation name if the updater spreads its input. Pass through the existing value (or default only when absent) instead of always forcing an empty string.

Copilot uses AI. Check for mistakes.
"use client";

import { Settings } from "lucide-react";
import { BookOpen, Settings } from "lucide-react";
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BookOpenIcon is imported but never used in this component. Remove the unused import to avoid lint/TS unused-import errors.

Suggested change
import { BookOpen, Settings } from "lucide-react";
import { Settings } from "lucide-react";

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +90
function OrganisationMeta({
organisationName,
compact,
}: {
organisationName: string | null | undefined;
compact?: boolean;
}) {
const name = organisationName?.trim();
if (!name) return null;
return (
<span
className={cn(
"inline-flex items-center gap-1 whitespace-nowrap text-muted-foreground",
compact ? "text-[11px]" : "text-xs",
)}
>
Published by
<span className="text-neutral-400">•</span>
<span className="truncate">{name}</span>
</span>
);
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OrganisationMeta always renders the text "Published by" whenever organisationName is set, but it isn’t gated on dataSource.public. This will label private/internal data sources as "Published" in contexts like the organisation’s own data source list where the "Published" badge is not shown. Consider rendering this meta only when dataSource.public is true, or change the wording to something that doesn’t imply the public flag.

Copilot uses AI. Check for mistakes.
<div className="flex items-center gap-1 pt-2 border-t border-neutral-200/70 text-muted-foreground">
<BookOpen className="w-3 h-3 shrink-0" />
<p className="text-[11px] truncate">
Published by <span className="text-neutral-400">•</span>{" "}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This UI shows "Published by" based solely on dataSource.organisationName. If dataSource.public is false (private/internal data sources in the inspector), this copy becomes misleading compared to the existing "Published" badge semantics elsewhere. Consider gating this on dataSource.public or adjusting the copy to not imply publication.

Suggested change
Published by <span className="text-neutral-400"></span>{" "}
{dataSource.public ? "Published by" : "Provided by"}{" "}
<span className="text-neutral-400"></span>{" "}

Copilot uses AI. Check for mistakes.
@joaquimds joaquimds merged commit ffba95c into main Apr 7, 2026
1 check passed
@joaquimds joaquimds deleted the mdl-published-by-org branch April 7, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants