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

Update UI to get "launched by" info from backend #25237

Draft
wants to merge 3 commits into
base: jamie/launched-by-tag-to-graphene-layer
Choose a base branch
from
Draft
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
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
Loading