diff --git a/js_modules/dagster-ui/packages/ui-core/src/nav/useCodeLocationsStatus.tsx b/js_modules/dagster-ui/packages/ui-core/src/nav/useCodeLocationsStatus.tsx
index 2f276e0fc95e3..1a3f0db69db01 100644
--- a/js_modules/dagster-ui/packages/ui-core/src/nav/useCodeLocationsStatus.tsx
+++ b/js_modules/dagster-ui/packages/ui-core/src/nav/useCodeLocationsStatus.tsx
@@ -1,5 +1,5 @@
import {Box, ButtonLink, Colors} from '@dagster-io/ui-components';
-import {useCallback, useContext, useEffect, useLayoutEffect, useState} from 'react';
+import {useCallback, useContext, useLayoutEffect, useState} from 'react';
import {useHistory} from 'react-router-dom';
import {atom, useRecoilValue} from 'recoil';
import styled from 'styled-components';
@@ -38,8 +38,7 @@ export const useCodeLocationsStatus = (): StatusAndMessage | null => {
// Reload the workspace, but don't toast about it.
// Reload the workspace, and show a success or error toast upon completion.
- useEffect(() => {
- const isFreshPageload = previousEntriesById === null;
+ useLayoutEffect(() => {
const anyErrors = Object.values(data).some(
(entry) =>
entry.__typename === 'PythonError' ||
@@ -59,17 +58,6 @@ export const useCodeLocationsStatus = (): StatusAndMessage | null => {
),
icon: 'check_circle',
});
- } else if (!isFreshPageload) {
- showSharedToaster({
- intent: 'success',
- message: (
-
- Definitions reloaded
- {showViewButton ? : null}
-
- ),
- icon: 'check_circle',
- });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data, onClickViewButton]);
@@ -78,6 +66,7 @@ export const useCodeLocationsStatus = (): StatusAndMessage | null => {
useLayoutEffect(() => {
const isFreshPageload = previousEntriesById === null;
+ const showViewButton = !alreadyViewingCodeLocations();
// Given the previous and current code locations, determine whether to show a) a loading spinner
// and/or b) a toast indicating that a code location is being reloaded.
@@ -88,6 +77,19 @@ export const useCodeLocationsStatus = (): StatusAndMessage | null => {
: [];
let hasUpdatedEntries = entries.length !== Object.keys(previousEntriesById || {}).length;
+
+ if (!isFreshPageload && hasUpdatedEntries) {
+ showSharedToaster({
+ intent: 'success',
+ message: (
+
+ Definitions reloaded
+ {showViewButton ? : null}
+
+ ),
+ icon: 'check_circle',
+ });
+ }
const currEntriesById: {[key: string]: LocationStatusEntry} = {};
entries.forEach((entry) => {
const previousEntry = previousEntriesById && previousEntriesById[entry.id];
@@ -130,8 +132,6 @@ export const useCodeLocationsStatus = (): StatusAndMessage | null => {
return;
}
- const showViewButton = !alreadyViewingCodeLocations();
-
// We have a new entry, and it has already finished loading. Wow! It's surprisingly fast for it
// to have finished loading so quickly, but go ahead and indicate that the location has
// been added, then reload the workspace.
diff --git a/js_modules/dagster-ui/packages/ui-core/src/workspace/CodeLocationRowSet.tsx b/js_modules/dagster-ui/packages/ui-core/src/workspace/CodeLocationRowSet.tsx
index a03837c974bf4..0f684461839a6 100644
--- a/js_modules/dagster-ui/packages/ui-core/src/workspace/CodeLocationRowSet.tsx
+++ b/js_modules/dagster-ui/packages/ui-core/src/workspace/CodeLocationRowSet.tsx
@@ -4,23 +4,16 @@ import {
ButtonLink,
Colors,
Icon,
- JoinedButtons,
MiddleTruncate,
Tag,
Tooltip,
} from '@dagster-io/ui-components';
import {useCallback, useMemo, useState} from 'react';
-import {Link} from 'react-router-dom';
import styled from 'styled-components';
-import {CodeLocationMenu} from './CodeLocationMenu';
-import {RepositoryCountTags} from './RepositoryCountTags';
import {RepositoryLocationNonBlockingErrorDialog} from './RepositoryLocationErrorDialog';
import {WorkspaceRepositoryLocationNode} from './WorkspaceContext';
-import {buildRepoAddress} from './buildRepoAddress';
-import {repoAddressAsHumanString} from './repoAddressAsString';
import {WorkspaceDisplayMetadataFragment} from './types/WorkspaceQueries.types';
-import {workspacePathFromAddress} from './workspacePath';
import {showSharedToaster} from '../app/DomUtils';
import {useCopyToClipboard} from '../app/browser';
import {
@@ -31,81 +24,6 @@ import {
buildReloadFnForLocation,
useRepositoryLocationReload,
} from '../nav/useRepositoryLocationReload';
-import {TimeFromNow} from '../ui/TimeFromNow';
-
-interface Props {
- locationNode: WorkspaceRepositoryLocationNode;
-}
-
-export const CodeLocationRowSet = ({locationNode}: Props) => {
- const {name, locationOrLoadError} = locationNode;
-
- if (!locationOrLoadError || locationOrLoadError?.__typename === 'PythonError') {
- return (
-
-
-
- |
-
-
- |
-
-
- |
- {'\u2013'} |
-
-
-
-
-
- |
-
- );
- }
-
- const repositories = [...locationOrLoadError.repositories].sort((a, b) =>
- a.name.localeCompare(b.name),
- );
-
- return (
- <>
- {repositories.map((repository) => {
- const repoAddress = buildRepoAddress(repository.name, name);
- const allMetadata = [...locationNode.displayMetadata, ...repository.displayMetadata];
- return (
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
- |
-
-
- |
-
-
- |
-
-
-
-
-
- |
-
- );
- })}
- >
- );
-};
export const ImageName = ({metadata}: {metadata: WorkspaceDisplayMetadataFragment[]}) => {
const copy = useCopyToClipboard();
diff --git a/js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceContext.tsx b/js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceContext.tsx
index 2bc857cb55549..a2f2119f57109 100644
--- a/js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceContext.tsx
+++ b/js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceContext.tsx
@@ -192,19 +192,30 @@ export const WorkspaceProvider = ({children}: {children: React.ReactNode}) => {
[client, getData, localCacheIdPrefix],
);
+ const [isRefetching, setIsRefetching] = useState(false);
+
const locationsToFetch = useMemo(() => {
if (!didLoadCachedData) {
return [];
}
+ if (isRefetching) {
+ return [];
+ }
const toFetch = Object.values(locations).filter((loc) => {
const prev = prevLocations.current?.[loc.name];
- return prev?.updateTimestamp !== loc.updateTimestamp || prev?.loadStatus !== loc.loadStatus;
+ const d = locationsData[loc.name];
+ const entry = d?.__typename === 'WorkspaceLocationEntry' ? d : null;
+ return (
+ prev?.updateTimestamp !== loc.updateTimestamp ||
+ prev?.loadStatus !== loc.loadStatus ||
+ entry?.updatedTimestamp !== loc.updateTimestamp ||
+ entry?.loadStatus !== loc.loadStatus
+ );
});
prevLocations.current = locations;
return toFetch;
- }, [locations, didLoadCachedData]);
+ }, [didLoadCachedData, isRefetching, locations, locationsData]);
- const [isRefetching, setIsRefetching] = useState(false);
useLayoutEffect(() => {
if (!locationsToFetch.length) {
return;