Skip to content

Commit

Permalink
Revert "[bugfix] Check that oldData is defined before trying to migra…
Browse files Browse the repository at this point in the history
…te (#7537)" and  "Update key for saving data in useExecutionSessionStorage (#7333)" (#7551)
  • Loading branch information
gibsondan committed Apr 22, 2022
1 parent 942c995 commit 5bf224a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 111 deletions.
22 changes: 3 additions & 19 deletions js_modules/dagit/packages/core/src/app/ExecutionSessionStorage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import * as React from 'react';

import {getJSONForKey} from '../hooks/useStateWithStorage';
import {RepoAddress} from '../workspace/types';

import {AppContext} from './AppContext';

// Internal LocalStorage data format and mutation helpers

Expand Down Expand Up @@ -157,31 +154,18 @@ version flag it can use to trigger a re-render after changes are saved, so chang
namespaces changes the returned data immediately.
*/
export function useExecutionSessionStorage(
repoAddress: RepoAddress,
pipelineOrJobName: string,
repositoryName: string,
pipelineName: string,
initial: Partial<IExecutionSession> = {},
): StorageHook {
const {basePath} = React.useContext(AppContext);

const oldNamespace = `${repoAddress.name}.${pipelineOrJobName}`;
const oldData = getStorageDataForNamespace(oldNamespace);

const namespace = `${basePath}-${repoAddress.location}-${repoAddress.name}-${pipelineOrJobName}`;
const namespace = `${repositoryName}.${pipelineName}`;
const [version, setVersion] = React.useState<number>(0);

const onSave = (newData: IStorageData) => {
writeStorageDataForNamespace(namespace, newData);
setVersion(version + 1); // trigger a React render
};

// TODO: Remove this migration logic in a few patches when we know the old namespace is likely no longer being used
const oldDataMigrated = React.useRef(false);
if (oldData && !oldDataMigrated.current) {
onSave(oldData);
window.localStorage.removeItem(getKey(oldNamespace));
oldDataMigrated.current = true;
}

return [getStorageDataForNamespace(namespace, initial), onSave];
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ const LaunchpadSessionContainer: React.FC<LaunchpadSessionContainerProps> = (pro
return {};
}, [isJob, partitionSets.results, presets]);

const [data, onSave] = useExecutionSessionStorage(repoAddress, pipeline.name, initialDataForMode);
const [data, onSave] = useExecutionSessionStorage(
repoAddress.name || '',
pipeline.name,
initialDataForMode,
);

const currentSession = data.sessions[data.current];
const tagsFromSession = React.useMemo(() => currentSession.tags || [], [currentSession]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const LaunchpadSetupFromRunAllowedRoot: React.FC<Props> = (props) => {

useJobTitle(explorerPath, isJob);

const [storageData, onSave] = useExecutionSessionStorage(repoAddress, pipelineName);
const [storageData, onSave] = useExecutionSessionStorage(repoAddress.name, pipelineName);

const {data, loading} = useQuery<ConfigForRunQuery, ConfigForRunQueryVariables>(
CONFIG_FOR_RUN_QUERY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const LaunchpadSetupAllowedRoot: React.FC<Props> = (props) => {

useJobTitle(explorerPath, isJob);

const [data, onSave] = useExecutionSessionStorage(repoAddress, pipelineName);
const [data, onSave] = useExecutionSessionStorage(repoAddress.name, pipelineName);
const queryString = qs.parse(window.location.search, {ignoreQueryPrefix: true});

React.useEffect(() => {
Expand Down

0 comments on commit 5bf224a

Please sign in to comment.