Skip to content

Commit

Permalink
[dagit] Allow colon in run tag value (#7409)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellendag committed Apr 13, 2022
1 parent 94f7984 commit 8120421
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js_modules/dagit/packages/ui/src/components/TokenizingField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ export const tokenizedValuesFromString = (str: string, providers: SuggestionProv
export const tokenizedValuesFromStringArray = (tokens: string[], providers: SuggestionProvider[]) =>
tokens.map((token) => tokenizedValueFromString(token, providers));

export const tokenizeString = (str: string): [string, string] => {
const colonAt = str.indexOf(':');
if (colonAt === -1) {
return [str, ''];
}
return [str.slice(0, colonAt), str.slice(colonAt + 1)];
};

export function tokenizedValueFromString(
str: string,
providers: SuggestionProvider[],
): TokenizingFieldValue {
const [token = '', value = ''] = str.split(':');

const [token, value] = tokenizeString(str);
if (findProviderByToken(token, providers)) {
if (token && value) {
return {token, value};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {tokenizeString} from './TokenizingField';

describe('tokenizeString', () => {
it('tokenizes when there is only a token', () => {
expect(tokenizeString('foo')).toEqual(['foo', '']);
});

it('tokenizes when there is a token and value', () => {
expect(tokenizeString('foo:bar')).toEqual(['foo', 'bar']);
});

it('tokenizes when there is only a value with colons in it', () => {
expect(tokenizeString('foo:bar:baz')).toEqual(['foo', 'bar:baz']);
});
});

1 comment on commit 8120421

@vercel
Copy link

@vercel vercel bot commented on 8120421 Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

dagit-storybook – ./js_modules/dagit/packages/ui

dagit-storybook-git-master-elementl.vercel.app
dagit-storybook-elementl.vercel.app
dagit-storybook.vercel.app

Please sign in to comment.