Group Permission editors into the same folder

This will make it easier to make changes and reuse code on the future.

They were grouped together by only the storybook title.

Now they are on the same folder, which is `frontend/libs/console/legacy-ce/src/lib/Permissions`.

Since now they are together, removed the title to all storybook stories.

Important: I did not make any behavior changes. Only moved code around. I need this for a separate PR but I thought it was good to create this isolated PR with non behavioral changes so it's easy to review (it has a lot of files changed).

Jira ticket: https://hasurahq.atlassian.net/browse/DSF-496

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9974
GitOrigin-RevId: 940020d06e0144eac95c614f84aea122852396b9
This commit is contained in:
Julian 2023-07-28 16:11:50 -03:00 committed by hasura-bot
parent d303ebc266
commit a3deb5eff0
51 changed files with 59 additions and 71 deletions

View File

@ -1,6 +1,6 @@
import { Tabs } from '../../../../new-components/Tabs';
import { LogicalModelPermissionsPage } from '../../../Permissions/LogicalModelPermissions/LogicalModelPermissionsPage';
import { ViewLogicalModelPage } from '../LogicalModel/ViewLogicalModelPage';
import { LogicalModelPermissionsPage } from '../LogicalModelPermissions/LogicalModelPermissionsPage';
export const LogicalModelTabs = ({
defaultValue,

View File

@ -1,2 +1,2 @@
export { LogicalModelPermissionsRoute } from './LogicalModelPermissions/LogicalModelPermissionsPage';
export { LogicalModelPermissionsRoute } from '../../Permissions/LogicalModelPermissions/LogicalModelPermissionsPage';
export { ViewLogicalModelRoute } from './LogicalModel/ViewLogicalModelPage';

View File

@ -5,7 +5,7 @@ import {
SupportedDrivers,
} from '../../../hasura-metadata-types';
import { ModifyFunctionConfiguration } from './ModifyFunctionConfiguration';
import { ModifyFunctionPermissionsDialog } from '../FunctionPermissions/ModifyFunctionPermissionsDialog';
import { ModifyFunctionPermissionsDialog } from '../../../Permissions/FunctionPermissions/ModifyFunctionPermissionsDialog';
import { IconTooltip } from '../../../../new-components/Tooltip';
import { FaEdit, FaKey } from 'react-icons/fa';
import { DisplayConfigurationDetails } from './DisplayConfigurationDetails';

View File

@ -1,13 +1,12 @@
import { Meta, StoryObj } from '@storybook/react';
import { expect } from '@storybook/jest';
import { ReactQueryDecorator } from '../../../../storybook/decorators/react-query';
import { ReactQueryDecorator } from '../../../storybook/decorators/react-query';
import { ModifyFunctionPermissionsDialog } from './ModifyFunctionPermissionsDialog';
import { handlers } from './mocks';
import { action } from '@storybook/addon-actions';
import { userEvent, waitFor, within } from '@storybook/testing-library';
export default {
title: 'Features/Permissions/Form/UDF Permissions',
component: ModifyFunctionPermissionsDialog,
decorators: [ReactQueryDecorator()],
parameters: {

View File

@ -1,21 +1,21 @@
import { Dialog } from '../../../../new-components/Dialog';
import { Dialog } from '../../../new-components/Dialog';
import {
MetadataFunction,
QualifiedFunction,
} from '../../../hasura-metadata-types';
import { areTablesEqual, useMetadata } from '../../../hasura-metadata-api';
} from '../../hasura-metadata-types';
import { areTablesEqual, useMetadata } from '../../hasura-metadata-api';
import { FaCheck, FaTimes } from 'react-icons/fa';
import React from 'react';
import { Switch } from '../../../../new-components/Switch';
import { Switch } from '../../../new-components/Switch';
import clsx from 'clsx';
import { hasuraToast } from '../../../../new-components/Toasts';
import { hasuraToast } from '../../../new-components/Toasts';
import { QueryClient, useQueryClient } from 'react-query';
import { IndicatorCard } from '../../../../new-components/IndicatorCard';
import { IndicatorCard } from '../../../new-components/IndicatorCard';
import { Link } from 'react-router';
import { LearnMoreLink } from '../../../../new-components/LearnMoreLink';
import { LearnMoreLink } from '../../../new-components/LearnMoreLink';
import { getMetadataDataSource } from './utils';
import { useManageFunctionPermission } from '../../../MetadataAPI/hooks/useManageFunctionPermission';
import { MetadataHelpers } from '../../../hasura-metadata-api/metadataHelpers';
import { useManageFunctionPermission } from '../../MetadataAPI/hooks/useManageFunctionPermission';
import { MetadataHelpers } from '../../hasura-metadata-api/metadataHelpers';
export type ModifyFunctionPermissionsProps = {
qualifiedFunction: QualifiedFunction[];

View File

@ -1,5 +1,5 @@
import { Metadata } from '../../../hasura-metadata-types';
import { MetadataSelectors } from '../../../hasura-metadata-api';
import { Metadata } from '../../hasura-metadata-types';
import { MetadataSelectors } from '../../hasura-metadata-api';
export const getMetadataDataSource =
(dataSourceName: string) => (m: Metadata) => {

View File

@ -1,13 +1,12 @@
import { Meta, StoryObj } from '@storybook/react';
import { LogicalModelPermissions } from './LogicalModelPermissions';
import { comparators } from '../../../Permissions/PermissionsForm/components/RowPermissionsBuilder/components/__tests__/fixtures/comparators';
import { comparators } from '../PermissionsForm/components/RowPermissionsBuilder/components/__tests__/fixtures/comparators';
import { userEvent, within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
import { ComponentProps } from 'react';
export default {
title: 'Features/Permissions/Form/Logical Model Permissions',
component: LogicalModelPermissions,
} as Meta;

View File

@ -2,7 +2,7 @@ import { useCallback } from 'react';
import {
Comparators,
RowPermissionsInput,
} from '../../../Permissions/PermissionsForm/components/RowPermissionsBuilder/components';
} from '../PermissionsForm/components/RowPermissionsBuilder/components';
import {
LogicalModelWithPermissions,
OnDelete,

View File

@ -1,14 +1,13 @@
import { Meta, StoryObj } from '@storybook/react';
import { LogicalModelPermissionsPage } from './LogicalModelPermissionsPage';
import { ReactQueryDecorator } from '../../../../storybook/decorators/react-query';
import { RouteWrapper } from '../components/RouteWrapper';
import { handlers, deleteHandlers } from './mocks';
import { RouteWrapper } from '../../Data/LogicalModels/components/RouteWrapper';
import { ReactQueryDecorator } from '../../../storybook/decorators/react-query';
const name = 'LogicalModel';
const source = 'Postgres';
export default {
title: 'Features/Permissions/Form/Logical Model Permissions Page',
component: params => {
return (
<RouteWrapper

View File

@ -1,13 +1,13 @@
import { InjectedRouter, withRouter } from 'react-router';
import { RouteWrapper } from '../components/RouteWrapper';
import { LogicalModelPermissions } from './LogicalModelPermissions';
import { useCreateLogicalModelsPermissions } from './hooks/useCreateLogicalModelsPermissions';
import { useRemoveLogicalModelsPermissions } from './hooks/useRemoveLogicalModelsPermissions';
import { useMetadata } from '../../../hasura-metadata-api';
import { usePermissionComparators } from '../../../Permissions/PermissionsForm/components/RowPermissionsBuilder/hooks/usePermissionComparators';
import { useMetadata } from '../../hasura-metadata-api';
import { usePermissionComparators } from '../PermissionsForm/components/RowPermissionsBuilder/hooks/usePermissionComparators';
import Skeleton from 'react-loading-skeleton';
import { extractModelsAndQueriesFromMetadata } from '../../../hasura-metadata-api/selectors';
import { LogicalModelTabs } from '../components/LogicalModelTabs';
import { extractModelsAndQueriesFromMetadata } from '../../hasura-metadata-api/selectors';
import { LogicalModelTabs } from '../../Data/LogicalModels/components/LogicalModelTabs';
import { RouteWrapper } from '../../Data/LogicalModels/components/RouteWrapper';
export const LogicalModelPermissionsPage = ({
source,

View File

@ -1,4 +1,4 @@
import { PermissionsIcon } from '../../../../Permissions/PermissionsTable/components/PermissionsIcons';
import { PermissionsIcon } from '../../PermissionsTable/components/PermissionsIcons';
interface PermissionAccessCellProps extends React.ComponentProps<'button'> {
access: 'fullAccess' | 'partialAccess' | 'noAccess';

View File

@ -1,11 +1,11 @@
import { ReactNode } from 'react';
import { Button } from '../../../../../new-components/Button';
import { IconTooltip } from '../../../../../new-components/Tooltip';
import { Button } from '../../../../new-components/Button';
import { IconTooltip } from '../../../../new-components/Tooltip';
import { usePermissionsFormContext } from '../hooks/usePermissionForm';
import { Permission } from './types';
import { Collapse } from '../../../../../new-components/deprecated';
import { getEdForm } from '../../../../../components/Services/Data/utils';
import { Badge } from '../../../../../new-components/Badge';
import { Collapse } from '../../../../new-components/deprecated';
import { getEdForm } from '../../../../components/Services/Data/utils';
import { Badge } from '../../../../new-components/Badge';
type PermissionsFormProps = {
permission: Permission;

View File

@ -1,7 +1,7 @@
import { createRef } from 'react';
import { PermissionsIcon } from '../../../../Permissions/PermissionsTable/components/PermissionsIcons';
import { Action, Permission } from './types';
import { PermissionsRow } from './PermissionsRow';
import { PermissionsIcon } from '../../PermissionsTable/components/PermissionsIcons';
export type PermissionsTableProps = {
allowedActions: Action[];

View File

@ -1,4 +1,4 @@
import { LogicalModel, Source } from '../../../../hasura-metadata-types';
import { LogicalModel, Source } from '../../../hasura-metadata-types';
export type LogicalModelWithSourceName = LogicalModel & {
source: Source;

View File

@ -1,9 +1,9 @@
import { useCallback } from 'react';
import { useFireNotification } from '../../../../../new-components/Notifications/index';
import { exportMetadata } from '../../../../DataSource';
import { useMetadataMigration } from '../../../../MetadataAPI';
import { useHttpClient } from '../../../../Network';
import { LogicalModel, Source } from '../../../../hasura-metadata-types';
import { useFireNotification } from '../../../../new-components/Notifications/index';
import { exportMetadata } from '../../../DataSource';
import { useMetadataMigration } from '../../../MetadataAPI';
import { useHttpClient } from '../../../Network';
import { LogicalModel, Source } from '../../../hasura-metadata-types';
import { errorTransform } from './utils/errorTransform';
import { getCreateLogicalModelBody } from './utils/getCreateLogicalModelBody';

View File

@ -1,9 +1,9 @@
import { useCallback } from 'react';
import { useFireNotification } from '../../../../../new-components/Notifications/index';
import { exportMetadata } from '../../../../DataSource';
import { useMetadataMigration } from '../../../../MetadataAPI';
import { useHttpClient } from '../../../../Network';
import { LogicalModel, Source } from '../../../../hasura-metadata-types';
import { useFireNotification } from '../../../../new-components/Notifications/index';
import { exportMetadata } from '../../../DataSource';
import { useMetadataMigration } from '../../../MetadataAPI';
import { useHttpClient } from '../../../Network';
import { LogicalModel, Source } from '../../../hasura-metadata-types';
import { Permission } from '../components/types';
import { errorTransform } from './utils/errorTransform';
import { getDeleteLogicalModelBody } from './utils/getDeleteLogicalModelBody';

View File

@ -1,5 +1,5 @@
import { getPermissionValues } from './getPermissionValues';
import { LogicalModel, Source } from '../../../../../hasura-metadata-types';
import { LogicalModel, Source } from '../../../../hasura-metadata-types';
import { Permission } from '../../components/types';
import { mapPostgresToPg } from '.';

View File

@ -1,5 +1,5 @@
import { mapPostgresToPg } from '.';
import { Source } from '../../../../../hasura-metadata-types';
import { Source } from '../../../../hasura-metadata-types';
import { Permission } from '../../components/types';
export interface DeleteLogicalModalBodyArgs {
logicalModelName: string;

View File

@ -8,7 +8,6 @@ import { BulkDelete, BulkDeleteProps } from './BulkDelete';
import { handlers } from './mocks/handlers.mock';
export default {
title: 'Features/Permissions/Bulk Update',
component: BulkDelete,
decorators: [ReactQueryDecorator()],
} as Meta;

View File

@ -5,7 +5,6 @@ import { PermissionsForm, PermissionsFormProps } from './PermissionsForm';
import { handlers } from './mocks/handlers.mock';
export default {
title: 'Features/Permissions/Form',
component: PermissionsForm,
decorators: [ReactQueryDecorator()],
parameters: {

View File

@ -7,7 +7,6 @@ import { action } from '@storybook/addon-actions';
import { AggregationProps, AggregationSection } from './Aggregation';
export default {
title: 'Features/Permissions/Form/Aggregation Section',
component: AggregationSection,
parameters: {
// Disable storybook for playground stories

View File

@ -6,7 +6,6 @@ import { SimpleForm } from '../../../../new-components/Form';
import { BackendOnlySection, BackEndOnlySectionProps } from './BackendOnly';
export default {
title: 'Features/Permissions/Form/Backend Only Section',
component: BackendOnlySection,
parameters: {
// Disable storybook for playground stories

View File

@ -10,7 +10,6 @@ import {
} from './ClonePermissions';
export default {
title: 'Features/Permissions/Form/Clone Permissions',
component: ClonePermissionsSection,
decorators: [
(StoryComponent: React.FC) => (
@ -23,7 +22,12 @@ export default {
export const Default: StoryObj<ClonePermissionsSectionProps> = {
args: {
tables: ['users', 'public'],
tables: [
{
name: 'users',
schema: 'public',
},
],
supportedQueryTypes: ['insert', 'select', 'update', 'delete'],
roles: ['one', 'two'],
},

View File

@ -12,7 +12,6 @@ import {
const schema = z.object({ columns: z.record(z.optional(z.boolean())) });
export default {
title: 'Features/Permissions/Form/Column Section',
component: ColumnPermissionsSection,
decorators: [
ReactQueryDecorator(),

View File

@ -9,7 +9,6 @@ import {
} from './ColumnPresets';
export default {
title: 'Features/Permissions/Form/Presets Section',
component: ColumnPresetsSection,
decorators: [
(StoryComponent: React.FC) => (

View File

@ -6,7 +6,6 @@ import {
} from './PermissionsConfirmationModal';
export default {
title: 'Features/Permissions/Confirmation Modal',
component: PermissionsConfirmationModal,
argTypes: {
onSubmit: { action: true },

View File

@ -12,7 +12,6 @@ import {
} from './RowPermissions';
export default {
title: 'Features/Permissions/Form/Row Section',
component: RowPermissionsSection,
decorators: [
(StoryComponent: React.FC) => (

View File

@ -7,7 +7,6 @@ import { handlers } from './__tests__/fixtures/jsonb/handlers';
import { ReactQueryDecorator } from '../../../../../../storybook/decorators/react-query';
export default {
title: 'Features/Permissions/Form/Logical Model Permissions Input',
component: RowPermissionsInput,
parameters: {
msw: handlers(),
@ -25,8 +24,8 @@ export const Basic: Story = {
logicalModels: [
{
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',
source: {
@ -38,8 +37,8 @@ export const Basic: Story = {
},
{
fields: [
{ name: 'a', nullable: false, type: 'text' },
{ name: 'b', nullable: false, type: 'text' },
{ name: 'a', type: { scalar: 'text', nullable: false } },
{ name: 'b', type: { scalar: 'text', nullable: false } },
],
name: 'logical_model',
source: {

View File

@ -23,7 +23,6 @@ import { useState } from 'react';
import { Permissions } from './types';
export default {
title: 'Features/Permissions/Form/Row Permissions Input',
component: RowPermissionsInput,
parameters: {
msw: handlers(),

View File

@ -7,11 +7,11 @@ import { RootInput } from './RootInput';
import { JsonEditor } from './JsonEditor';
import { RootTableProvider } from './RootTableProvider';
import { RootLogicalModelProvider } from './RootLogicalModelProvider';
import { LogicalModelWithSourceName } from '../../../../../Data/LogicalModels/LogicalModelPermissions/components/types';
import {
ForbiddenFeaturesProvider,
Feature,
} from './ForbiddenFeaturesProvider';
import { LogicalModelWithSourceName } from '../../../../LogicalModelPermissions/components/types';
export const RowPermissionsInput = ({
permissions,

View File

@ -23,7 +23,7 @@ export const queries = [
payload: {
type: 'run_sql',
args: {
sql: "\n SELECT \n column_name, data_type, is_nullable\n FROM \n information_schema.columns \n WHERE \n table_schema = 'public' AND \n table_name = 'Stuff';",
sql: "\n SELECT a.attname as column_name,\n pg_catalog.format_type(a.atttypid, NULL) as data_type,\n case\n when a.attnotnull = 'f' then 'true'\n else 'false'\n end as is_nullable\nFROM pg_attribute a\n JOIN pg_class t on a.attrelid = t.oid\n JOIN pg_namespace s on t.relnamespace = s.oid\nWHERE a.attnum > 0 \n AND NOT a.attisdropped\n AND t.relname = 'Stuff'\n AND s.nspname = 'public' \n",
source: 'default',
},
},
@ -54,7 +54,7 @@ export const queries = [
payload: {
type: 'run_sql',
args: {
sql: "\n SELECT \n column_name, data_type, is_nullable\n FROM \n information_schema.columns \n WHERE \n table_schema = 'public' AND \n table_name = 'Stuff';",
sql: "\n SELECT a.attname as column_name,\n pg_catalog.format_type(a.atttypid, NULL) as data_type,\n case\n when a.attnotnull = 'f' then 'true'\n else 'false'\n end as is_nullable\nFROM pg_attribute a\n JOIN pg_class t on a.attrelid = t.oid\n JOIN pg_namespace s on t.relnamespace = s.oid\nWHERE a.attnum > 0 \n AND NOT a.attisdropped\n AND t.relname = 'Stuff'\n AND s.nspname = 'public' \n",
source: 'default',
},
},
@ -85,7 +85,7 @@ export const queries = [
payload: {
type: 'run_sql',
args: {
sql: "\n SELECT \n column_name, data_type, is_nullable\n FROM \n information_schema.columns \n WHERE \n table_schema = 'public' AND \n table_name = 'Stuff';",
sql: "\n SELECT a.attname as column_name,\n pg_catalog.format_type(a.atttypid, NULL) as data_type,\n case\n when a.attnotnull = 'f' then 'true'\n else 'false'\n end as is_nullable\nFROM pg_attribute a\n JOIN pg_class t on a.attrelid = t.oid\n JOIN pg_namespace s on t.relnamespace = s.oid\nWHERE a.attnum > 0 \n AND NOT a.attisdropped\n AND t.relname = 'Stuff'\n AND s.nspname = 'public' \n",
source: 'default',
},
},

View File

@ -9,7 +9,6 @@ import { expect } from '@storybook/jest';
import { userEvent } from '@storybook/testing-library';
export default {
title: 'Features/Permissions',
component: PermissionsTab,
decorators: [ReactQueryDecorator()],
} as Meta;

View File

@ -7,7 +7,6 @@ import { handlers } from '../PermissionsForm/mocks/handlers.mock';
import { useTableMachine } from './hooks';
export default {
title: 'Features/Permissions/Table',
component: PermissionsTable,
decorators: [ReactQueryDecorator()],
parameters: {
@ -15,6 +14,7 @@ export default {
},
} as Meta;
// Fails
export const GDCTable: StoryObj<PermissionsTableProps> = {
render: args => {
const machine = useTableMachine();

View File

@ -12,7 +12,6 @@ import {
} from './Cells';
export default {
title: 'Features/Permissions/Table/Cells',
component: InputCell,
decorators: [
(StoryComponent: React.FC) => (

View File

@ -4,7 +4,6 @@ import { StoryFn, Meta } from '@storybook/react';
import { PermissionsLegend } from './PermissionsLegend';
export default {
title: 'Features/Permissions/Table/Permissions Legend',
component: PermissionsLegend,
parameters: { chromatic: { disableSnapshot: true } },
} as Meta;