BrowseView: Git Provisioned Read Only Folder Disable Empty State Create Dashboard Button (#111971)

BrowseView: Disable empty state create dashboard button when repo is read only
This commit is contained in:
Yunwen Zheng
2025-10-02 20:51:45 -06:00
committed by GitHub
parent 2f321982b2
commit 454cd0f385
2 changed files with 11 additions and 3 deletions
@@ -206,7 +206,13 @@ const BrowseDashboardsPage = memo(({ queryParams }: { queryParams: Record<string
searchStateManager={stateManager}
/>
) : (
<BrowseView permissions={permissions} width={width} height={height} folderUID={folderUID} />
<BrowseView
permissions={permissions}
width={width}
height={height}
folderUID={folderUID}
isReadOnlyRepo={isReadOnlyRepo}
/>
)
}
</AutoSizer>
@@ -33,9 +33,10 @@ interface BrowseViewProps {
width: number;
folderUID: string | undefined;
permissions: BrowseDashboardsPermissions;
isReadOnlyRepo?: boolean;
}
export function BrowseView({ folderUID, width, height, permissions }: BrowseViewProps) {
export function BrowseView({ folderUID, width, height, permissions, isReadOnlyRepo }: BrowseViewProps) {
const status = useBrowseLoadingStatus(folderUID);
const dispatch = useDispatch();
const flatTree = useFlatTreeState(folderUID);
@@ -163,6 +164,7 @@ export function BrowseView({ folderUID, width, height, permissions }: BrowseView
href={folderUID ? `dashboard/new?folderUid=${folderUID}` : 'dashboard/new'}
icon="plus"
size="lg"
disabled={isReadOnlyRepo}
>
<Trans i18nKey="browse-dashboards.empty-state.button-title">Create dashboard</Trans>
</LinkButton>
@@ -173,7 +175,7 @@ export function BrowseView({ folderUID, width, height, permissions }: BrowseView
: t('browse-dashboards.empty-state.title', "You haven't created any dashboards yet")
}
>
{folderUID && (
{folderUID && !isReadOnlyRepo && (
<Trans i18nKey="browse-dashboards.empty-state.pro-tip">
Add/move dashboards to your folder at{' '}
<TextLink external={false} href="/dashboards">