-
}
onClick={() => onRemoveClick(row.original)}
>
Remove
diff --git a/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModel/ViewLogicalModelPage.tsx b/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModel/ViewLogicalModelPage.tsx
new file mode 100644
index 00000000000..572044f8960
--- /dev/null
+++ b/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModel/ViewLogicalModelPage.tsx
@@ -0,0 +1,86 @@
+import { InjectedRouter, withRouter } from 'react-router';
+import { RouteWrapper } from '../components/RouteWrapper';
+import { LogicalModelTabs } from '../components/LogicalModelTabs';
+import { IndicatorCard } from '../../../../new-components/IndicatorCard';
+import { MetadataUtils, useMetadata } from '../../../hasura-metadata-api';
+import Skeleton from 'react-loading-skeleton';
+import { LogicalModelWidget } from '../LogicalModelWidget/LogicalModelWidget';
+import { logicalModelFieldToFormField } from './utils/logicalModelFieldToFormField';
+
+export const ViewLogicalModelRoute = withRouter<{
+ location: Location;
+ router: InjectedRouter;
+ params: {
+ source: string;
+ name: string;
+ };
+}>(({ params }) => {
+ if (!params.source || !params.name) {
+ return (
+
+ Unable to parse data from url.
+
+ );
+ }
+ return (
+
+
+
+ );
+});
+
+export const ViewLogicalModelPage = ({
+ source,
+ name,
+}: {
+ source: string;
+ name: string;
+}) => {
+ const { data: logicalModels, isLoading } = useMetadata(
+ m => MetadataUtils.findMetadataSource(source, m)?.logical_models
+ );
+
+ if (isLoading) {
+ return (
+
+
+
+ );
+ }
+
+ const logicalModel = logicalModels?.find(l => l.name === name);
+
+ if (!logicalModel) {
+ return (
+
+ Logical Model {name} not found in {source}
+
+ );
+ }
+
+ return (
+
+
+
+ );
+};
diff --git a/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModel/utils/logicalModelFieldToFormField.ts b/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModel/utils/logicalModelFieldToFormField.ts
new file mode 100644
index 00000000000..63c5429a4d6
--- /dev/null
+++ b/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModel/utils/logicalModelFieldToFormField.ts
@@ -0,0 +1,40 @@
+import { LogicalModel } from '../../../../hasura-metadata-types';
+import {
+ isArrayLogicalModelType,
+ isLogicalModelType,
+ isScalarFieldType,
+} from '../../../../hasura-metadata-types/source/typeGuards';
+import { AddLogicalModelFormData } from '../../LogicalModelWidget/validationSchema';
+
+export function logicalModelFieldToFormField(
+ f: LogicalModel['fields'][number]
+): AddLogicalModelFormData['fields'][number] {
+ if (isScalarFieldType(f.type)) {
+ return {
+ name: f.name,
+ type: f.type.scalar,
+ typeClass: 'scalar',
+ nullable: f.type.nullable,
+ array: false,
+ };
+ }
+ if (isLogicalModelType(f.type)) {
+ return {
+ name: f.name,
+ type: f.type.logical_model,
+ typeClass: 'logical_model',
+ nullable: f.type.nullable,
+ array: false,
+ };
+ }
+ if (isArrayLogicalModelType(f.type)) {
+ return {
+ name: f.name,
+ type: f.type.array.logical_model,
+ typeClass: 'logical_model',
+ nullable: f.type.array.nullable,
+ array: true,
+ };
+ }
+ throw new Error('Unknown field type');
+}
diff --git a/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModelPermissions/LogicalModelPermissions.stories.tsx b/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModelPermissions/LogicalModelPermissions.stories.tsx
index 7abc20b6369..243d7a72f69 100644
--- a/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModelPermissions/LogicalModelPermissions.stories.tsx
+++ b/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModelPermissions/LogicalModelPermissions.stories.tsx
@@ -25,8 +25,20 @@ const noPermissionArgs: Partial<
tables: [],
},
fields: [
- { name: 'one', nullable: false, type: 'text' },
- { name: 'two', nullable: false, type: 'text' },
+ {
+ name: 'one',
+ type: {
+ scalar: 'text',
+ nullable: false,
+ },
+ },
+ {
+ name: 'two',
+ type: {
+ scalar: 'text',
+ nullable: false,
+ },
+ },
],
name: 'hello_world',
},
@@ -47,8 +59,20 @@ const existingPermissionArgs: Partial<
tables: [],
},
fields: [
- { name: 'one', nullable: false, type: 'text' },
- { name: 'two', nullable: false, type: 'text' },
+ {
+ name: 'one',
+ type: {
+ scalar: 'text',
+ nullable: false,
+ },
+ },
+ {
+ name: 'two',
+ type: {
+ scalar: 'text',
+ nullable: false,
+ },
+ },
],
name: 'hello_world',
select_permissions: [
diff --git a/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModelPermissions/LogicalModelPermissionsPage.tsx b/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModelPermissions/LogicalModelPermissionsPage.tsx
index dde35a75f57..03b828814e0 100644
--- a/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModelPermissions/LogicalModelPermissionsPage.tsx
+++ b/frontend/libs/console/legacy-ce/src/lib/features/Data/LogicalModels/LogicalModelPermissions/LogicalModelPermissionsPage.tsx
@@ -1,6 +1,5 @@
import { InjectedRouter, withRouter } from 'react-router';
import { RouteWrapper } from '../components/RouteWrapper';
-import { Tabs } from '../../../../new-components/Tabs';
import { LogicalModelPermissions } from './LogicalModelPermissions';
import { useCreateLogicalModelsPermissions } from './hooks/useCreateLogicalModelsPermissions';
import { useRemoveLogicalModelsPermissions } from './hooks/useRemoveLogicalModelsPermissions';
@@ -8,6 +7,7 @@ import { useMetadata } from '../../../hasura-metadata-api';
import { usePermissionComparators } from '../../../Permissions/PermissionsForm/components/RowPermissionsBuilder/hooks/usePermissionComparators';
import Skeleton from 'react-loading-skeleton';
import { extractModelsAndQueriesFromMetadata } from '../../../hasura-metadata-api/selectors';
+import { LogicalModelTabs } from '../components/LogicalModelTabs';
export const LogicalModelPermissionsPage = ({
source,
@@ -32,58 +32,47 @@ export const LogicalModelPermissionsPage = ({
logicalModels,
source: logicalModel?.source,
});
-
return (
-
- {isLoading ? (
-
-
-
- ) : !logicalModel ? (
-
-
- Logical model with name {name} and driver {source} not found
-
-
- ) : (
- {
- create({
- logicalModelName: logicalModel?.name,
- permission,
- });
- }}
- onDelete={async permission => {
- remove({
- logicalModelName: logicalModel?.name,
- permission,
- });
- }}
- isCreating={isCreating}
- isRemoving={isRemoving}
- comparators={comparators}
- logicalModelName={logicalModel?.name}
- logicalModels={logicalModels}
- />
- )}
-
- ),
- },
- ]}
- />
+ >
+ {isLoading ? (
+