Skip to content

Commit 89f3120

Browse files
✨ feat(merge): origin
1 parent dc09dca commit 89f3120

File tree

53 files changed

+302
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+302
-185
lines changed

.lintstagedrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"src/**/*.{json,ts,tsx}": [
3+
"node ./scripts/ci",
34
"npm run lint:fix"
45
]
56
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"typecheck": "tsc",
1919
"lint": "eslint --ext ts,tsx .",
2020
"lint:fix": "eslint --fix",
21-
"verify": "npm run typecheck && npm run lint && npm run test:cov",
21+
"verify": "node ./scripts/ci && npm run typecheck && npm run lint && npm run test:cov",
2222
"storybook": "start-storybook -p 6006",
2323
"build-storybook": "build-storybook",
2424
"prepare": "husky install"

scripts/ci/check-file-segments.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const fs = require("fs");
2+
const { listAllFilesInDir } = require("./lib");
3+
4+
let files = process.argv.slice(2);
5+
6+
if (files.length === 0) {
7+
files = [
8+
...listAllFilesInDir("./src/frontend"),
9+
...listAllFilesInDir("./src/backend"),
10+
...listAllFilesInDir("./src/shared"),
11+
];
12+
}
13+
14+
const errors = [];
15+
16+
const mustNotContain = (fileName, pathsToNotExist) => {
17+
const fileContent = fs.readFileSync(fileName, "utf8");
18+
19+
pathsToNotExist.forEach((pathToNotExist) => {
20+
if (fileContent.includes(pathToNotExist)) {
21+
errors.push(`${fileName} contains invalid path to ${pathToNotExist}`);
22+
}
23+
});
24+
};
25+
26+
const FILE_PATHS = { frontend: '"frontend/', backend: '"backend/' };
27+
28+
for (const fileName of files) {
29+
if (fileName.includes("src/backend")) {
30+
mustNotContain(fileName, [FILE_PATHS.frontend]);
31+
}
32+
if (fileName.includes("src/frontend")) {
33+
mustNotContain(fileName, [FILE_PATHS.backend]);
34+
}
35+
if (fileName.includes("src/shared")) {
36+
mustNotContain(fileName, [FILE_PATHS.backend, FILE_PATHS.frontend]);
37+
}
38+
}
39+
40+
if (errors.length > 0) {
41+
console.error(`${errors.length} files not placed in the correct folders`);
42+
43+
errors.forEach((error) => {
44+
console.error(error);
45+
});
46+
47+
process.exit(1);
48+
}

scripts/ci/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("./check-file-segments");

scripts/ci/lib.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const path = require("path");
2+
const fs = require("fs");
3+
4+
const listAllFilesInDir = (dir, files = []) => {
5+
const directoryPath = dir.startsWith("/")
6+
? dir
7+
: path.join(process.cwd(), dir);
8+
const filesInDir = fs.readdirSync(directoryPath);
9+
10+
filesInDir.forEach((file) => {
11+
const filePath = path.join(directoryPath, file);
12+
13+
const isDirectory = fs.statSync(filePath).isDirectory();
14+
15+
if (isDirectory) {
16+
listAllFilesInDir(filePath, files);
17+
} else {
18+
files.push(filePath);
19+
}
20+
});
21+
22+
return files;
23+
};
24+
25+
module.exports = {
26+
listAllFilesInDir,
27+
};

src/__tests__/_/api-handlers/integrations.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable no-param-reassign */
2-
import { IKeyValue } from "frontend/views/settings/Variables/types";
32
import {
43
DefaultBodyType,
54
PathParams,
@@ -8,6 +7,7 @@ import {
87
RestContext,
98
RestRequest,
109
} from "msw";
10+
import { IKeyValue } from "shared/types/options";
1111
import { BASE_TEST_URL } from "./_utils";
1212

1313
const CONSTANTS = [

src/__tests__/_/forCodeCoverage.spec.ts

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { FOR_CODE_COV as $16 } from "backend/actions/integrations/slack/types";
1717
import { FOR_CODE_COV as $17 } from "backend/actions/integrations/smtp/types";
1818
import { FOR_CODE_COV as $18 } from "backend/actions/integrations/twilio/types";
1919
import { FOR_CODE_COV as $19 } from "backend/storage/types";
20-
import { FOR_CODE_COV as $20 } from "frontend/views/settings/Variables/types";
2120
import { FOR_CODE_COV as $21 } from "shared/form-schemas/roles/permissions/base";
2221
import { FOR_CODE_COV as $22 } from "backend/lib/config-persistence/portal/index";
2322
import { FOR_CODE_COV as $23 } from "backend/lib/config-persistence/portal/main/types";
@@ -59,7 +58,6 @@ noop(
5958
$17,
6059
$18,
6160
$19,
62-
$20,
6361
$21,
6462
$22,
6563
$23,

src/backend/integrations-configurations/integrations-configurations.controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { BadRequestError } from "backend/lib/errors";
22
import { IntegrationsConfigurationGroup } from "shared/types/integrations";
3-
import { IKeyValue } from "frontend/views/settings/Variables/types";
3+
import { IKeyValue } from "shared/types/options";
44
import { credentialsApiService } from "./services/credentials.service";
55
import {
66
appConstantsApiService,

src/backend/menu/menu.service.ts

+24-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
SystemLinks,
77
} from "shared/types/menu";
88
import { userFriendlyCase } from "shared/lib/strings/friendly-case";
9-
import { META_USER_PERMISSIONS } from "shared/constants/user";
9+
import { META_USER_PERMISSIONS, USER_PERMISSIONS } from "shared/constants/user";
1010
import { GranularEntityPermissions } from "shared/types/user";
1111
import {
1212
EntitiesApiService,
@@ -20,10 +20,32 @@ import {
2020
import { RolesApiService, rolesApiService } from "backend/roles/roles.service";
2121
import { ILabelValue } from "shared/types/options";
2222
import { sortListByOrder } from "shared/lib/array/sort";
23-
import { SYSTEM_LINKS_CONFIG_MAP } from "shared/constants/menu";
2423
import { portalCheckIfIsMenuAllowed, getPortalMenuItems } from "./portal";
2524
import { IBaseNavigationMenuApiService } from "./types";
2625

26+
const SYSTEM_LINKS_CONFIG_MAP: Record<
27+
SystemLinks,
28+
{
29+
permission: string;
30+
}
31+
> = {
32+
[SystemLinks.Settings]: {
33+
permission: USER_PERMISSIONS.CAN_CONFIGURE_APP,
34+
},
35+
[SystemLinks.Home]: {
36+
permission: META_USER_PERMISSIONS.NO_PERMISSION_REQUIRED,
37+
},
38+
[SystemLinks.Roles]: {
39+
permission: USER_PERMISSIONS.CAN_MANAGE_PERMISSIONS,
40+
},
41+
[SystemLinks.Users]: {
42+
permission: USER_PERMISSIONS.CAN_MANAGE_USERS,
43+
},
44+
[SystemLinks.Integrations]: {
45+
permission: USER_PERMISSIONS.CAN_MANAGE_APP_CREDENTIALS,
46+
},
47+
};
48+
2749
export class NavigationMenuApiService
2850
implements IApplicationService, IBaseNavigationMenuApiService
2951
{

src/frontend/_layouts/app/LayoutImpl/RenderNavigation.tsx

+26-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,31 @@ import { PlainButton } from "frontend/design-system/components/Button/TextButton
1515
import { Stack } from "frontend/design-system/primitives/Stack";
1616
import { useThemeColorShade } from "frontend/design-system/theme/useTheme";
1717
import { useNavigationStack } from "frontend/lib/routing/useNavigationStack";
18-
import { SYSTEM_LINKS_CONFIG_MAP } from "shared/constants/menu";
19-
import { PORTAL_SYSTEM_LINK_CONFIG } from "shared/constants/portal/menu";
18+
import { ActionIntegrations } from "shared/types/actions";
19+
import { PORTAL_SYSTEM_LINK_CONFIG_LINKS } from "./portal";
20+
21+
const SYSTEM_LINKS_CONFIG_MAP: Record<
22+
SystemLinks,
23+
{
24+
link: string;
25+
}
26+
> = {
27+
[SystemLinks.Settings]: {
28+
link: NAVIGATION_LINKS.SETTINGS.DEFAULT,
29+
},
30+
[SystemLinks.Home]: {
31+
link: NAVIGATION_LINKS.DASHBOARD.HOME,
32+
},
33+
[SystemLinks.Roles]: {
34+
link: NAVIGATION_LINKS.ROLES.LIST,
35+
},
36+
[SystemLinks.Users]: {
37+
link: NAVIGATION_LINKS.USERS.LIST,
38+
},
39+
[SystemLinks.Integrations]: {
40+
link: NAVIGATION_LINKS.INTEGRATIONS.ACTIONS(ActionIntegrations.HTTP),
41+
},
42+
};
2043

2144
const LeftSideNavMenuList = styled.li<{}>`
2245
list-style: none;
@@ -127,7 +150,7 @@ const getNavigationTypeLink = (
127150
case NavigationMenuItemType.Entities:
128151
return NAVIGATION_LINKS.ENTITY.TABLE(link);
129152
case NavigationMenuItemType.System:
130-
return { ...SYSTEM_LINKS_CONFIG_MAP, ...PORTAL_SYSTEM_LINK_CONFIG }[
153+
return { ...SYSTEM_LINKS_CONFIG_MAP, ...PORTAL_SYSTEM_LINK_CONFIG_LINKS }[
131154
link as SystemLinks
132155
].link;
133156
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export { useConstantNavigationMenuItems } from "./main";
1+
export {
2+
useConstantNavigationMenuItems,
3+
PORTAL_SYSTEM_LINK_CONFIG_LINKS,
4+
} from "./main";

src/frontend/_layouts/app/LayoutImpl/portal/main.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NAVIGATION_LINKS } from "frontend/lib/routing/links";
2+
import { PortalSystemLinks } from "shared/constants/portal/menu/main";
23

34
export const useConstantNavigationMenuItems = () => {
45
return [
@@ -8,3 +9,11 @@ export const useConstantNavigationMenuItems = () => {
89
},
910
];
1011
};
12+
13+
export const PORTAL_SYSTEM_LINK_CONFIG_LINKS: Record<
14+
PortalSystemLinks,
15+
{
16+
link: string;
17+
permission?: string;
18+
}
19+
> = {};

src/frontend/components/FEPaginationTable/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { useState, ReactNode } from "react";
2-
import { IPaginatedDataState } from "shared/types/data";
2+
import { IPaginatedDataState, TableFilterType } from "shared/types/data";
33
import { DEFAULT_TABLE_STATE } from "frontend/design-system/components/Table/constants";
44
import { TableSkeleton } from "frontend/design-system/components/Skeleton/Table";
55
import { Table } from "frontend/design-system/components/Table";
66
import { ITableColumn } from "frontend/design-system/components/Table/types";
7-
import { TableFilterType } from "frontend/design-system/components/Table/filters/types";
87
import { IEmptyWrapperProps } from "frontend/design-system/components/EmptyWrapper/types";
98
import { useFEPagination } from "./useFEPagination";
109
import { ViewStateMachine } from "../ViewStateMachine";

src/frontend/components/SchemaForm/form-run.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { evalJavascriptStringSafely } from "frontend/lib/script-runner";
2-
import { ISchemaFormScriptProps } from "./types";
1+
import { ISchemaFormScriptProps } from "shared/form-schemas/types";
2+
import { evalJavascriptStringSafely } from "shared/lib/script-runner";
33

44
export const runFormFieldState = <T>(
55
fieldStateString: string,
+5-14
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
import { FormApi } from "final-form";
2-
import { ISharedFormInput } from "frontend/design-system/components/Form/_types";
32
import { FieldInputProps, FieldMetaState } from "react-final-form";
4-
import { ISchemaFormConfig } from "shared/form-schemas/types";
3+
import {
4+
IFormInputRightAction,
5+
ISchemaFormConfig,
6+
} from "shared/form-schemas/types";
57
import { IColorableSelection } from "shared/types/ui";
6-
import { IAuthenticatedUserBag } from "shared/types/user";
78
import { FIELD_TYPES_CONFIG_MAP } from "shared/validations";
89

910
export interface IFormExtension {
1011
fieldsState: string;
1112
beforeSubmit: string;
1213
}
1314

14-
export interface ISchemaFormScriptContext {
15-
routeParams: Record<string, string>;
16-
auth: IAuthenticatedUserBag;
17-
action: string;
18-
}
19-
20-
export interface ISchemaFormScriptProps<T> extends ISchemaFormScriptContext {
21-
formValues: T;
22-
}
23-
2415
export interface IRenderFormInputProps {
2516
type: keyof typeof FIELD_TYPES_CONFIG_MAP;
2617
renderProps: {
@@ -35,5 +26,5 @@ export interface IRenderFormInputProps {
3526
label: string;
3627
placeholder?: string;
3728
description?: string;
38-
rightActions?: ISharedFormInput["rightActions"];
29+
rightActions?: IFormInputRightAction[];
3930
}

src/frontend/components/SchemaForm/useSchemaFormScriptContext.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useRouter } from "next/router";
22
import { useAuthenticatedUserBag } from "frontend/hooks/auth/user.store";
3-
import { ISchemaFormScriptContext } from "./types";
3+
import { ISchemaFormScriptContext } from "shared/form-schemas/types";
44

55
export const useSchemaFormScriptContext = (
66
action: string
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import styled from "styled-components";
2+
import { forwardRef } from "react";
3+
import { USE_ROOT_COLOR } from "../theme/root";
4+
5+
const GrabRoot = styled.svg`
6+
cursor: grab;
7+
fill: ${USE_ROOT_COLOR("main-text")};
8+
touch-action: none;
9+
`;
10+
11+
export const GrabIcon = forwardRef<
12+
SVGSVGElement,
13+
{
14+
width?: number;
15+
className?: string;
16+
}
17+
>(({ className, width }, ref) => {
18+
return (
19+
<GrabRoot
20+
ref={ref}
21+
viewBox="0 0 20 20"
22+
width={width || 12}
23+
className={`${className} grab-icon`}
24+
>
25+
<path d="M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" />
26+
</GrabRoot>
27+
);
28+
});
29+
// // :eyes document.body.style.setProperty("cursor", "grabbing");
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FieldInputProps, FieldMetaState } from "react-final-form";
2+
import { IFormInputRightAction } from "shared/form-schemas/types";
23

34
export interface ISharedFormInput {
45
input: FieldInputProps<any, HTMLElement>;
@@ -9,10 +10,7 @@ export interface ISharedFormInput {
910
required?: boolean;
1011
disabled?: boolean;
1112
sm?: true;
12-
rightActions?: {
13-
label: string;
14-
action: () => void;
15-
}[];
13+
rightActions?: IFormInputRightAction[];
1614
}
1715

1816
export const FOR_CODE_COV = 1;

src/frontend/design-system/components/ListManager/ListManagerItem/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import Link from "next/link";
77
import styled, { css } from "styled-components";
88
import { USE_ROOT_COLOR } from "frontend/design-system/theme/root";
99
import { Stack } from "frontend/design-system/primitives/Stack";
10-
import { GrabIcon } from "shared/constants/Icons";
1110
import { SortableKnob } from "react-easy-sort";
11+
import { GrabIcon } from "frontend/design-system/Icons/Grab";
1212
import { FormButton } from "../../Button/FormButton";
1313
import { FormSwitch } from "../../Form/FormSwitch";
1414
import { ButtonIconTypes } from "../../Button/constants";

src/frontend/design-system/components/Table/Head.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import styled, { css } from "styled-components";
55
import { Stack } from "frontend/design-system/primitives/Stack";
66
import { Typo } from "frontend/design-system/primitives/Typo";
77
import { USE_ROOT_COLOR } from "frontend/design-system/theme/root";
8+
import { TableFilterType } from "shared/types/data";
89
import { TableFilter } from "./filters";
9-
import { TableFilterType } from "./filters/types";
1010
import { Th } from "./styles";
1111

1212
const THead = styled.thead`

src/frontend/design-system/components/Table/filters/_FilterWrapper.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { Icon, ToggleLeft, Filter, Search, Calendar } from "react-feather";
55
import styled from "styled-components";
66
import { Stack } from "frontend/design-system/primitives/Stack";
77
import { USE_ROOT_COLOR } from "frontend/design-system/theme/root";
8+
import { TableFilterType } from "shared/types/data";
89
import { Dropdown } from "../../Dropdown";
910
import { SoftButton } from "../../Button/SoftButton";
10-
import { TableFilterType } from "./types";
1111

1212
const FILTER_TYPE_CONFIG: Record<
1313
TableFilterType["_type"],

0 commit comments

Comments
 (0)