Skip to content

Commit

Permalink
update ui to get launched by info from graphene types
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiedemaria committed Oct 11, 2024
1 parent 581794d commit 5bf4cac
Show file tree
Hide file tree
Showing 21 changed files with 184 additions and 74 deletions.
18 changes: 9 additions & 9 deletions js_modules/dagster-ui/packages/ui-core/client.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const BackfillRowContent = ({
/>
</td>
<td style={{width: 160}}>
<CreatedByTagCell tags={backfill.tags} repoAddress={repoAddress} />
<CreatedByTagCell launchedBy={backfill.launchedBy} repoAddress={repoAddress} />
</td>
<td style={{width: 140}}>{renderBackfillStatus()}</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ export const BACKFILL_TABLE_FRAGMENT = gql`
key
value
}
launchedBy {
kind
tag {
key
value
}
}
error {
...PythonErrorFragment
}
Expand Down

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

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

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

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

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

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

105 changes: 52 additions & 53 deletions js_modules/dagster-ui/packages/ui-core/src/runs/CreatedByTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,85 +4,85 @@ import {Link} from 'react-router-dom';
import {UserDisplay} from 'shared/runs/UserDisplay.oss';
import styled from 'styled-components';

import {DagsterTag} from './RunTag';
// import {DagsterTag} from './RunTag';
import {RunFilterToken} from './RunsFilterInput';
import {RunTagsFragment} from './types/RunTagsFragment.types';
import {LaunchedByFragment} from './types/launchedByFragment.types';
import {TagActionsPopover} from '../ui/TagActions';
import {RepoAddress} from '../workspace/types';
import {workspacePathFromAddress} from '../workspace/workspacePath';

type Props = {
repoAddress?: RepoAddress | null;
tags: RunTagsFragment[];
// tags: RunTagsFragment[];
launchedBy: LaunchedByFragment;
onAddTag?: (token: RunFilterToken) => void;
};

export const CreatedByTagCell = memo(({repoAddress, tags, onAddTag}: Props) => {
export const CreatedByTagCell = memo(({repoAddress, launchedBy, onAddTag}: Props) => {
return (
<CreatedByTagCellWrapper flex={{direction: 'column', alignItems: 'flex-start'}}>
<CreatedByTag repoAddress={repoAddress} tags={tags} onAddTag={onAddTag} />
<CreatedByTag repoAddress={repoAddress} launchedBy={launchedBy} onAddTag={onAddTag} />
</CreatedByTagCellWrapper>
);
});

export const CreatedByTagCellWrapper = styled(Box)``;

type TagType =
| {
type: 'user' | 'schedule' | 'sensor' | 'auto-materialize' | 'auto-observe';
tag: RunTagsFragment;
}
| {type: 'manual'};
// type TagType =
// | {
// type: 'user' | 'schedule' | 'sensor' | 'auto-materialize' | 'auto-observe';
// tag: RunTagsFragment;
// }
// | {type: 'manual'};

const pluckTagFromList = (tags: RunTagsFragment[]): TagType => {
// Prefer user/schedule/sensor
for (const tag of tags) {
const {key} = tag;
switch (key) {
case DagsterTag.User:
return {type: 'user', tag};
case DagsterTag.ScheduleName:
return {type: 'schedule', tag};
case DagsterTag.SensorName:
return {type: 'sensor', tag};
}
}
// const pluckTagFromList = (tags: RunTagsFragment[]): TagType => {
// // Prefer user/schedule/sensor
// for (const tag of tags) {
// const {key} = tag;
// switch (key) {
// case DagsterTag.User:
// return {type: 'user', tag};
// case DagsterTag.ScheduleName:
// return {type: 'schedule', tag};
// case DagsterTag.SensorName:
// return {type: 'sensor', tag};
// }
// }

// If none of those, check for AMP
for (const tag of tags) {
const {key} = tag;
switch (key) {
case DagsterTag.Automaterialize:
return {type: 'auto-materialize', tag};
case DagsterTag.CreatedBy: {
// Backwards compatibility
if (tag.value === 'auto_materialize') {
return {type: 'auto-materialize', tag};
} else {
continue;
}
}
case DagsterTag.AutoObserve:
return {type: 'auto-observe', tag};
}
}
// // If none of those, check for AMP
// for (const tag of tags) {
// const {key} = tag;
// switch (key) {
// case DagsterTag.Automaterialize:
// return {type: 'auto-materialize', tag};
// case DagsterTag.CreatedBy: {
// // Backwards compatibility
// if (tag.value === 'auto_materialize') {
// return {type: 'auto-materialize', tag};
// } else {
// continue;
// }
// }
// case DagsterTag.AutoObserve:
// return {type: 'auto-observe', tag};
// }
// }

return {type: 'manual'};
};
// return {type: 'manual'};
// };

export const CreatedByTag = ({repoAddress, tags, onAddTag}: Props) => {
const plucked = pluckTagFromList(tags);
export const CreatedByTag = ({repoAddress, launchedBy, onAddTag}: Props) => {
const {kind, tag} = launchedBy;
const {key, value} = tag;

if (plucked.type === 'manual') {
if (kind === 'manual') {
return <Tag icon="account_circle">Manually launched</Tag>;
}

const buildTagElement = () => {
const {type, tag} = plucked;
const {value} = tag;
switch (type) {
switch (kind) {
case 'user':
return <UserDisplay email={tag.value} />;
return <UserDisplay email={value} />;
case 'schedule': {
return (
<Tag icon="schedule">
Expand Down Expand Up @@ -110,15 +110,14 @@ export const CreatedByTag = ({repoAddress, tags, onAddTag}: Props) => {
case 'auto-observe':
return <Tag icon="auto_observe">Auto-observation</Tag>;
}
return <Tag icon="auto_observe">Auto-observation</Tag>; // TODO fix - unreachable but not sure what to put here
};

const tagElement = buildTagElement();
if (!onAddTag) {
return tagElement;
}

const {tag} = plucked;
const {key, value} = tag;
return (
<TagActionsPopover
data={tag}
Expand Down
2 changes: 1 addition & 1 deletion js_modules/dagster-ui/packages/ui-core/src/runs/RunRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const RunRow = ({
<td>
<CreatedByTagCell
repoAddress={repoAddressGuess}
tags={run.tags || []}
launchedBy={run.launchedBy}
onAddTag={onAddTag}
/>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ export const RUN_TABLE_RUN_FRAGMENT = gql`
tags {
...RunTagsFragment
}
launchedBy {
kind
tag {
key
value
}
}
...RunTimeFragment
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export const RunsFeedRow = ({
</Tag>
</RowCell>
<RowCell>
<CreatedByTagCell tags={entry.tags || []} onAddTag={onAddTag} />
<CreatedByTagCell launchedBy={entry.launchedBy} onAddTag={onAddTag} />
</RowCell>
<RowCell>
<div>
Expand Down Expand Up @@ -225,6 +225,13 @@ export const RUNS_FEED_TABLE_ENTRY_FRAGMENT = gql`
key
value
}
launchedBy {
kind
tag {
key
value
}
}
jobName
assetSelection {
... on AssetKey {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {gql} from '../apollo-client';

export const LAUNCHED_BY_FRAGMENT = gql`
fragment LaunchedByFragment on LaunchedBy {
kind
tag {
key
value
}
}
`;
Loading

0 comments on commit 5bf4cac

Please sign in to comment.