Skip to content

Commit

Permalink
chore(reflux-state-mixin): import into Compass source tree (#5872)
Browse files Browse the repository at this point in the history
From the archived and abandoned https://github.com/mongodb-js/reflux-state-mixin
repository.
  • Loading branch information
addaleax authored Jun 6, 2024
1 parent ff79bd8 commit bdd9182
Show file tree
Hide file tree
Showing 20 changed files with 741 additions and 33 deletions.
65 changes: 48 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/compass-crud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"prop-types": "^15.7.2",
"react": "^17.0.2",
"reflux": "^0.4.1",
"reflux-state-mixin": "github:mongodb-js/reflux-state-mixin",
"@mongodb-js/reflux-state-mixin": "^1.0.0",
"semver": "^7.6.2"
},
"is_compass_plugin": true
Expand Down
5 changes: 2 additions & 3 deletions packages/compass-crud/src/stores/crud-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import Reflux from 'reflux';
import toNS from 'mongodb-ns';
import { findIndex, isEmpty, isEqual } from 'lodash';
import semver from 'semver';
// @ts-expect-error no types available
import StateMixin from 'reflux-state-mixin';
import StateMixin from '@mongodb-js/reflux-state-mixin';
import type { Element } from 'hadron-document';
import { Document } from 'hadron-document';
import HadronDocument from 'hadron-document';
Expand Down Expand Up @@ -320,7 +319,7 @@ class CrudStoreImpl
extends BaseRefluxStore<CrudStoreOptions & CrudStoreActionsOptions>
implements CrudActions
{
mixins = [StateMixin.store];
mixins = [StateMixin.store<CrudState>()];
listenables: unknown[];

// Should this be readonly? The existence of setState would imply that...
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"react-leaflet": "^2.4.0",
"react-leaflet-draw": "^0.19.0",
"reflux": "^0.4.1",
"reflux-state-mixin": "github:mongodb-js/reflux-state-mixin"
"@mongodb-js/reflux-state-mixin": "^1.0.0"
},
"is_compass_plugin": true
}
15 changes: 4 additions & 11 deletions packages/compass-schema/src/stores/store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Reflux from 'reflux';
// @ts-expect-error no types available
import StateMixin from 'reflux-state-mixin';
import type { StoreWithStateMixin } from '@mongodb-js/reflux-state-mixin';
import StateMixin from '@mongodb-js/reflux-state-mixin';
import type { LoggerAndTelemetry } from '@mongodb-js/compass-logging';
import type { InternalLayer } from '../modules/geo';
import { addLayer, generateGeoQuery } from '../modules/geo';
Expand Down Expand Up @@ -65,19 +65,14 @@ export type SchemaPluginServices = {
};

type SchemaState = {
localAppRegistry: SchemaPluginServices['localAppRegistry'];
globalAppRegistry: SchemaPluginServices['globalAppRegistry'];
analysisState: AnalysisState;
errorMessage: string;
schema: Schema | null;
resultId: number;
abortController: undefined | AbortController;
};

export type SchemaStore = Reflux.Store & {
state: Readonly<SchemaState>;
setState(state: Partial<SchemaState>): void;

export type SchemaStore = StoreWithStateMixin<SchemaState> & {
localAppRegistry: SchemaPluginServices['localAppRegistry'];
globalAppRegistry: SchemaPluginServices['globalAppRegistry'];
fieldStoreService: SchemaPluginServices['fieldStoreService'];
Expand Down Expand Up @@ -139,7 +134,7 @@ export function activateSchemaPlugin(
* The reflux store for the schema.
*/
const store: SchemaStore = Reflux.createStore({
mixins: [StateMixin.store],
mixins: [StateMixin.store<SchemaState>()],
listenables: actions,

/**
Expand Down Expand Up @@ -185,8 +180,6 @@ export function activateSchemaPlugin(
*/
getInitialState(this: SchemaStore): SchemaState {
return {
localAppRegistry,
globalAppRegistry,
analysisState: ANALYSIS_STATE_INITIAL,
errorMessage: '',
schema: null,
Expand Down
9 changes: 9 additions & 0 deletions packages/reflux-state-mixin/.depcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ignores:
- '@mongodb-js/prettier-config-compass'
- '@mongodb-js/tsconfig-compass'
- '@types/chai'
- '@types/sinon-chai'
- 'sinon'
- 'reflux'
ignore-patterns:
- 'dist'
2 changes: 2 additions & 0 deletions packages/reflux-state-mixin/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.nyc-output
dist
8 changes: 8 additions & 0 deletions packages/reflux-state-mixin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
root: true,
extends: ['@mongodb-js/eslint-config-compass'],
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig-lint.json'],
},
};
1 change: 1 addition & 0 deletions packages/reflux-state-mixin/.mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@mongodb-js/mocha-config-compass');
3 changes: 3 additions & 0 deletions packages/reflux-state-mixin/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.nyc_output
dist
coverage
1 change: 1 addition & 0 deletions packages/reflux-state-mixin/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@mongodb-js/prettier-config-compass"
Loading

0 comments on commit bdd9182

Please sign in to comment.