Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions explorer/app/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export { Stack } from "@clevercanary/data-explorer-ui/lib/components/common/Stac
export { StaticImage } from "@clevercanary/data-explorer-ui/lib/components/common/StaticImage/staticImage";
export { StatusBadge } from "@clevercanary/data-explorer-ui/lib/components/common/StatusBadge/statusBadge";
export { TagWarning } from "@clevercanary/data-explorer-ui/lib/components/common/Tag/tag.styles";
export { ConditionalComponent } from "@clevercanary/data-explorer-ui/lib/components/ComponentCreator/components/ConditionalComponent/conditionalComponent";
export { DetailViewTable } from "@clevercanary/data-explorer-ui/lib/components/Detail/components/DetailViewTable/detailViewTable";
export { DownloadCurlCommandForm } from "@clevercanary/data-explorer-ui/lib/components/Export/components/DownloadCurlCommand/components/DownloadCurlCommandForm/downloadCurlCommandForm";
export { DownloadCurlCommand } from "@clevercanary/data-explorer-ui/lib/components/Export/components/DownloadCurlCommand/downloadCurlCommand";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,29 @@ export const buildExportEntityToTerra = (
};
};

/**
* Build props for entity related export warning FluidAlert component.
* @param datasetsResponse - Response model return from datasets API (unused).
* @param viewContext - View context.
* @returns model to be used as props for the FluidAlert component.
*/
export const buildExportEntityWarning = (
datasetsResponse: DatasetsResponse,
viewContext: ViewContext
): React.ComponentProps<typeof C.FluidAlert> => {
const {
authState: { isAuthorized },
} = viewContext;
const title = isAuthorized
? "To export this dataset, please request access."
: "To export this dataset, please sign in and, if necessary, request access.";
return {
severity: "warning",
title,
variant: "banner",
};
};

/**
* Build props for export Hero component.
* @param _ - Unused.
Expand Down Expand Up @@ -804,6 +827,32 @@ function mapCurrentQuery(
];
}

/**
* Renders entity related export when the given datasests response is accessible.
* @param datasetsResponse - Response model return from datasets API.
* @returns model to be used as props for the ConditionalComponent component.
*/
export const renderExportEntity = (
datasetsResponse: DatasetsResponse
): React.ComponentProps<typeof C.ConditionalComponent> => {
return {
isIn: isDatasetAccessible(datasetsResponse),
};
};

/**
* Renders entity related export warning when the given datasests response is not accessible.
* @param datasetsResponse - Response model return from datasets API.
* @returns model to be used as props for the ConditionalComponent component.
*/
export const renderExportEntityWarning = (
datasetsResponse: DatasetsResponse
): React.ComponentProps<typeof C.ConditionalComponent> => {
return {
isIn: !isDatasetAccessible(datasetsResponse),
};
};

/**
* Returns value from a string array matching the given index.
* @param arr - String array.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,73 @@
import { ComponentConfig } from "@clevercanary/data-explorer-ui/lib/config/entities";
import { DatasetsResponse } from "../../../../../app/apis/azul/anvil-cmg/common/responses";
import * as C from "../../../../../app/components";
import * as MDX from "../../../../../app/content/anvil-cmg";
import * as V from "../../../../../app/viewModelBuilders/azul/anvil-cmg/common/viewModelBuilders";

export const mainColumn: ComponentConfig[] = [
{
component: C.ExportToTerra,
viewBuilder: V.buildExportEntityToTerra,
} as ComponentConfig<typeof C.ExportToTerra, DatasetsResponse>,
/* Dataset is not accessible; render warning */
children: [
{
children: [
{
component: C.FluidAlert,
viewBuilder: V.buildExportEntityWarning,
} as ComponentConfig<typeof C.FluidAlert, DatasetsResponse>,
],
component: C.BackPageContentSingleColumn,
} as ComponentConfig<typeof C.BackPageContentSingleColumn>,
],
component: C.ConditionalComponent,
viewBuilder: V.renderExportEntityWarning,
} as ComponentConfig<typeof C.ConditionalComponent, DatasetsResponse>,
{
/* Dataset is accessible; render export entity */
children: [
/* mainColumn */
{
children: [
{
component: C.ExportToTerra,
viewBuilder: V.buildExportEntityToTerra,
} as ComponentConfig<typeof C.ExportToTerra, DatasetsResponse>,
],
component: C.BackPageContentMainColumn,
} as ComponentConfig<typeof C.BackPageContentMainColumn>,
/* sideColumn */
{
children: [
{
children: [
{
component: C.ExportCurrentQuery,
viewBuilder: V.buildExportCurrentQuery,
} as ComponentConfig<typeof C.ExportCurrentQuery>,
{
component: C.ExportSelectedDataSummary,
viewBuilder: V.buildExportSelectedDataSummary,
} as ComponentConfig<typeof C.ExportSelectedDataSummary>,
],
component: C.ExportSummary,
} as ComponentConfig<typeof C.ExportSummary>,
{
children: [
{
children: [
{
component: MDX.DataReleasePolicy,
} as ComponentConfig<typeof MDX.DataReleasePolicy>,
],
component: MDX.Section,
} as ComponentConfig<typeof MDX.Section>,
],
component: C.FluidPaper,
} as ComponentConfig<typeof C.FluidPaper>,
],
component: C.BackPageContentSideColumn,
} as ComponentConfig<typeof C.BackPageContentSideColumn>,
],
component: C.ConditionalComponent,
viewBuilder: V.renderExportEntity,
} as ComponentConfig<typeof C.ConditionalComponent, DatasetsResponse>,
];

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
ANVIL_CMG_CATEGORY_LABEL,
} from "../../category";
import { mainColumn as exportMainColumn } from "../detail/dataset/exportMainColumn";
import { sideColumn as exportSideColumn } from "../detail/dataset/exportSideColumn";
import { mainColumn } from "../detail/dataset/overviewMainColumn";
import { sideColumn } from "../detail/dataset/overviewSideColumn";
import { top } from "../detail/dataset/top";
Expand All @@ -37,7 +36,6 @@ export const datasetsEntityConfig: EntityConfig<DatasetsResponse> = {
label: "Export",
mainColumn: exportMainColumn,
route: "export-to-terra",
sideColumn: exportSideColumn,
},
],
top: top,
Expand Down
2 changes: 1 addition & 1 deletion explorer/site-config/anvil-cmg/dev/listView/listHero.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ComponentConfig,
ComponentsConfig,
} from "../../../../../../data-explorer/packages/data-explorer-ui/src/config/entities";
} from "@clevercanary/data-explorer-ui/lib/config/entities";
import * as C from "../../../../app/components";
import * as T from "../../../../app/viewModelBuilders/azul/anvil-cmg/common/viewModelBuilders";

Expand Down