Skip to content

Commit

Permalink
Move anon-apex to feature library
Browse files Browse the repository at this point in the history
  • Loading branch information
paustint committed Jun 20, 2024
1 parent 6121346 commit 2190bc3
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/jetstream/src/app/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const MassUpdateRecords = lazy(() => import('./components/update-records/MassUpd
const MassUpdateRecordsSelection = lazy(() => import('./components/update-records/selection/MassUpdateRecordsSelection'));
const MassUpdateRecordsDeployment = lazy(() => import('./components/update-records/deployment/MassUpdateRecordsDeployment'));

const AnonymousApex = lazy(() => import('./components/anonymous-apex/AnonymousApex'));
const AnonymousApex = lazy(() => import('@jetstream/feature/anon-apex').then((module) => ({ default: module.AnonymousApex })));

const SalesforceApi = lazy(() => import('./components/salesforce-api/SalesforceApi'));

Expand Down
12 changes: 12 additions & 0 deletions libs/features/anon-apex/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
18 changes: 18 additions & 0 deletions libs/features/anon-apex/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["plugin:@nx/react", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
7 changes: 7 additions & 0 deletions libs/features/anon-apex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# features-anon-apex

This library was generated with [Nx](https://nx.dev).

## Running unit tests

Run `nx test features-anon-apex` to execute the unit tests via [Jest](https://jestjs.io).
11 changes: 11 additions & 0 deletions libs/features/anon-apex/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'features-anon-apex',
preset: '../../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../../coverage/libs/features/anon-apex',
};
16 changes: 16 additions & 0 deletions libs/features/anon-apex/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "features-anon-apex",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/features/anon-apex/src",
"projectType": "library",
"tags": [],
"targets": {
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/features/anon-apex/jest.config.ts"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { logger } from '@jetstream/shared/client-logger';
import { ANALYTICS_KEYS, INDEXED_DB, LOG_LEVELS, TITLES } from '@jetstream/shared/constants';
import { anonymousApex } from '@jetstream/shared/data';
import { useBrowserNotifications, useDebounce, useNonInitialEffect, useRollbar, useTitle } from '@jetstream/shared/ui-utils';
import { getErrorMessage, getErrorMessageAndStackObj } from '@jetstream/shared/utils';
import { SplitWrapper as Split } from '@jetstream/splitjs';
import { ApexHistoryItem, ListItem, SalesforceOrgUi } from '@jetstream/types';
import {
Expand All @@ -21,8 +22,7 @@ import {
ViewDocsLink,
getModifierKey,
} from '@jetstream/ui';
import { STORAGE_KEYS, applicationCookieState, selectSkipFrontdoorAuth, selectedOrgState } from '@jetstream/ui-core';
import { useAmplitude } from '@jetstream/ui-core';
import { STORAGE_KEYS, applicationCookieState, selectSkipFrontdoorAuth, selectedOrgState, useAmplitude } from '@jetstream/ui-core';
import Editor, { OnMount, useMonaco } from '@monaco-editor/react';
import localforage from 'localforage';
import escapeRegExp from 'lodash/escapeRegExp';
Expand Down Expand Up @@ -174,12 +174,12 @@ export const AnonymousApex: FunctionComponent<AnonymousApexProps> = () => {
})
.catch((ex) => {
logger.warn('[ERROR] Could not save history', ex);
rollbar.error('Error saving apex history', { message: ex.message, stack: ex.stack });
rollbar.error('Error saving apex history', getErrorMessageAndStackObj(ex));
});
}
trackEvent(ANALYTICS_KEYS.apex_Submitted, { success: result.success });
} catch (ex) {
setResults(`There was a problem submitting the request\n${ex.message}`);
setResults(`There was a problem submitting the request\n${getErrorMessage(ex)}`);
trackEvent(ANALYTICS_KEYS.apex_Submitted, { success: false });
} finally {
setLoading(false);
Expand All @@ -188,8 +188,8 @@ export const AnonymousApex: FunctionComponent<AnonymousApexProps> = () => {
[historyItems, selectedOrg, logLevel, setHistoryItems, trackEvent]
);

function handleEditorChange(value, event) {
setApex(value);
function handleEditorChange(value?: string, event?: unknown) {
setApex(value || '');
}

const handleApexEditorMount: OnMount = (currEditor, monaco) => {
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions libs/features/anon-apex/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './AnonymousApex';
22 changes: 22 additions & 0 deletions libs/features/anon-apex/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react",
"allowJs": false,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"strict": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
24 changes: 24 additions & 0 deletions libs/features/anon-apex/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"types": ["node"]
},
"exclude": [
"jest.config.ts",
"src/**/*.spec.ts",
"src/**/*.test.ts",
"src/**/*.spec.tsx",
"src/**/*.test.tsx",
"src/**/*.spec.js",
"src/**/*.test.js",
"src/**/*.spec.jsx",
"src/**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"],
"files": [
"../../../node_modules/@nx/react/typings/cssmodule.d.ts",
"../../../node_modules/@nx/react/typings/image.d.ts",
"../../../custom-typings/index.d.ts"
]
}
20 changes: 20 additions & 0 deletions libs/features/anon-apex/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@jetstream/api-config": ["libs/api-config/src/index.ts"],
"@jetstream/api-types": ["libs/api-types/src/index.ts"],
"@jetstream/connected-ui": ["libs/connected/connected-ui/src/index.ts"],
"@jetstream/feature/anon-apex": ["libs/features/anon-apex/src/index.ts"],
"@jetstream/feature/query": ["libs/features/query/src/index.ts"],
"@jetstream/icon-factory": ["libs/icon-factory/src/index.ts"],
"@jetstream/monaco": ["libs/monaco-configuration/src/index.ts"],
Expand Down

0 comments on commit 2190bc3

Please sign in to comment.