Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deploy staging <- main #433

Merged
merged 14 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions client/__tests__/e2e/puppeteerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,11 @@ export async function getElementCoordinates(testId: any) {
});
}

async function nameNewAnnotation() {
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
if (await isElementPresent(getTestId("annotation-dialog"))) {
await typeInto("new-annotation-name", "ignoreE2E");
await clickOn("submit-annotation");

// wait for the page to load
await waitByClass("autosave-complete");
}
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
export async function goToPage(url: any) {
await page.goto(url, {
waitUntil: "networkidle0",
});

await nameNewAnnotation();
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
Expand Down
6 changes: 3 additions & 3 deletions client/__tests__/reducers/genesetsUI.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import genesetsUIReducer from "../../src/reducers/genesetsUI";
import genesetsUIReducer, { GeneSetsUIState } from "../../src/reducers/genesetsUI";

// Format: GeneSetsUI(state,action)

const initialState = {
const initialState: GeneSetsUIState = {
createGenesetModeActive: false,
isEditingGenesetName: false,
isAddingGenesToGeneset: false,
Expand Down Expand Up @@ -30,7 +30,7 @@ describe("geneset UI states", () => {
});
test("geneset: disable create geneset mode", () => {
expect(
genesetsUIReducer(undefined, { isEditingGenesetName: false })
genesetsUIReducer(undefined, { type: "geneset: disable rename geneset mode", isEditingGenesetName: false })
).toMatchObject(initialState);
});

Expand Down
Binary file modified client/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 1 addition & 177 deletions client/src/actions/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
* Action creators for user annotation
*/
import difference from "lodash.difference";
import pako from "pako";
import * as globals from "../globals";
import { AppDispatch, GetState } from "../reducers";
import { MatrixFBS, AnnotationsHelpers } from "../util/stateManager";
import { AnnotationsHelpers } from "../util/stateManager";

const { isUserAnnotation } = AnnotationsHelpers;

Expand Down Expand Up @@ -313,178 +312,3 @@ export const needToSaveObsAnnotations = (
(col: any) => annoMatrix.col(col) !== lastSavedAnnoMatrix.col(col)
);
};

/**
* Save the user-created obs annotations IF any have changed.
*/
export const saveObsAnnotationsAction =
() =>
async (dispatch: AppDispatch, getState: GetState): Promise<void> => {
if (!globals.API) throw new Error("API not set");
const state = getState();
const { annotations, autosave } = state;
const { dataCollectionNameIsReadOnly, dataCollectionName } = annotations;
const { lastSavedAnnoMatrix, saveInProgress } = autosave;

const annoMatrix = state.annoMatrix.base();

if (saveInProgress || annoMatrix === lastSavedAnnoMatrix) return;
if (!needToSaveObsAnnotations(annoMatrix, lastSavedAnnoMatrix)) {
dispatch({
type: "writable obs annotations - save complete",
lastSavedAnnoMatrix: annoMatrix,
});
return;
}

/**
* Else, we really do need to save
*/
dispatch({
type: "writable obs annotations - save started",
});

const df = await annoMatrix.fetch("obs", writableAnnotations(annoMatrix));
const matrix = MatrixFBS.encodeMatrixFBS(df);
const compressedMatrix = pako.deflate(matrix);
try {
const queryString =
!dataCollectionNameIsReadOnly && !!dataCollectionName
? `?annotation-collection-name=${encodeURIComponent(
dataCollectionName
)}`
: "";
const res = await fetch(
`${globals.API.prefix}${globals.API.version}annotations/obs${queryString}`,
{
method: "PUT",
body: compressedMatrix,
headers: new Headers({
"Content-Type": "application/octet-stream",
}),
credentials: "include",
}
);
if (res.ok) {
dispatch({
type: "writable obs annotations - save complete",
lastSavedAnnoMatrix: annoMatrix,
});
} else {
dispatch({
type: "writable obs annotations - save error",
message: `HTTP error ${res.status} - ${res.statusText}`,
res,
});
}
} catch (error) {
if (error instanceof Error)
dispatch({
type: "writable obs annotations - save error",
message: error.toString(),
error,
});
}
};

export const saveGenesetsAction =
() =>
async (dispatch: AppDispatch, getState: GetState): Promise<unknown> => {
if (!globals.API) throw new Error("API not set");
const state = getState();

// bail if gene sets not available, or in readonly mode.
const { config } = state;
const { lastTid, genesets } = state.genesets;

const genesetsAreAvailable =
config?.parameters?.annotations_genesets ?? false;
const genesetsReadonly =
config?.parameters?.annotations_genesets_readonly ?? true;
if (!genesetsAreAvailable || genesetsReadonly) {
// our non-save was completed!
return dispatch({
type: "autosave: genesets complete",
lastSavedGenesets: genesets,
});
}

dispatch({
type: "autosave: genesets started",
});

/* Create the JSON OTA data structure */
const tid = (lastTid ?? 0) + 1;
const genesetsOTA = [];
for (const [name, gs] of genesets) {
const genes = [];
for (const g of gs.genes.values()) {
genes.push({
gene_symbol: g.geneSymbol,
gene_description: g.geneDescription,
});
}
genesetsOTA.push({
geneset_name: name,
geneset_description: gs.genesetDescription,
genes,
});
}
const ota = {
tid,
genesets: genesetsOTA,
};

/* Save to server */
try {
const { dataCollectionNameIsReadOnly, dataCollectionName } =
state.annotations;
const queryString =
!dataCollectionNameIsReadOnly && !!dataCollectionName
? `?annotation-collection-name=${encodeURIComponent(
dataCollectionName
)}`
: "";

const res = await fetch(
`${globals.API.prefix}${globals.API.version}genesets${queryString}`,
{
method: "PUT",
headers: new Headers({
Accept: "application/json",
"Content-Type": "application/json",
}),
body: JSON.stringify(ota),
credentials: "include",
}
);
if (!res.ok) {
return dispatch({
type: "autosave: genesets error",
message: `HTTP error ${res.status} - ${res.statusText}`,
res,
});
}
return await Promise.all([
dispatch({
type: "autosave: genesets complete",
lastSavedGenesets: genesets,
}),
dispatch({
type: "geneset: set tid",
tid,
}),
]);
} catch (error) {
if (error instanceof Error)
return dispatch({
type: "autosave: genesets error",
message: error.toString(),
error,
});
return dispatch({
type: "autosave: genesets error",
error,
});
}
};
2 changes: 0 additions & 2 deletions client/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,6 @@ export default {
annoActions.annotationDeleteLabelFromCategory,
annotationRenameLabelInCategory: annoActions.annotationRenameLabelInCategory,
annotationLabelCurrentSelection: annoActions.annotationLabelCurrentSelection,
saveObsAnnotationsAction: annoActions.saveObsAnnotationsAction,
saveGenesetsAction: annoActions.saveGenesetsAction,
needToSaveObsAnnotations: annoActions.needToSaveObsAnnotations,
layoutChoiceAction: embActions.layoutChoiceAction,
setCellSetFromSelection: selnActions.setCellSetFromSelection,
Expand Down
4 changes: 0 additions & 4 deletions client/src/common/types/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ export const STANDARD_CATEGORY_NAMES = [
"disease_ontology_term_id",
"ethnicity",
"ethnicity_ontology_term_id",
"self_reported_ethnicity",
"self_reported_ethnicity_ontology_term_id",
"is_primary_data",
"organism",
"organism_ontology_term_id",
"sex_ontology_term_id",
"sex",
"tissue_ontology_term_id",
"tissue",
"suspension_type",
"donor_id",
];

/**
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import RightSideBar from "./rightSidebar";
import Legend from "./continuousLegend";
import Graph from "./graph/graph";
import MenuBar from "./menubar";
import Autosave from "./autosave";
import Embedding from "./embedding";

import actions from "../actions";
Expand Down Expand Up @@ -79,7 +78,6 @@ class App extends React.Component<Props> {
</Controls>
<Embedding />
<FloatingButton baseUrl={baseUrl} />
<Autosave />
<Legend />
<Graph
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- FIXME: added to solve linting error with ts-ignore
Expand Down
Loading