Skip to content

Commit

Permalink
Merge branch 'master' into require-fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
Cictrone committed Apr 16, 2020
2 parents d12fdaf + 4488c74 commit 94954b2
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 146 deletions.
12 changes: 3 additions & 9 deletions pkg/worker/worker.go
Expand Up @@ -45,14 +45,8 @@ func (w *Worker) HandleTaskQueued(ctx context.Context, info event.TaskQueued) {
return
}

tags := info.Tags
if tags == nil {
log.Printf("[DBG] task queued event with invalid tags")
return
}

found := false
for _, tag := range tags {
for _, tag := range info.Tags {
if tag == nil {
continue
}
Expand All @@ -63,8 +57,8 @@ func (w *Worker) HandleTaskQueued(ctx context.Context, info event.TaskQueued) {
found = true
break
}
if !found {
log.Printf("[DBG] task queued event without worker tags")
if !found && info.Tags != nil {
log.Printf("[DBG] task queued event with service tags that were not for the worker")
return
}

Expand Down
10 changes: 3 additions & 7 deletions www/src/components/form/XServiceTypeahead.tsx
Expand Up @@ -22,7 +22,7 @@ type ServicesResult = {
};

// XServiceTypeahead adds a service tag field to a form, which has a value of a single tag id.
const XServiceTypeahead: React.FC<{ value: string, onChange: (event: React.SyntheticEvent<HTMLElement>, data: DropdownProps) => void, labeled?: boolean, defaultSVC?: string }> = ({ value, onChange, labeled, defaultSVC }) => {
const XServiceTypeahead: React.FC<{ value: string, onChange: (event: React.SyntheticEvent<HTMLElement>, data: DropdownProps) => void, labeled?: boolean }> = ({ value, onChange, labeled }) => {
const { loading, error, data: { services = [] } = {} } = useQuery<
ServicesResult
>(SUGGEST_SERVICES_QUERY);
Expand All @@ -31,10 +31,6 @@ const XServiceTypeahead: React.FC<{ value: string, onChange: (event: React.Synth
? Array.from(
new Map(
services.map(svc => {
if (svc && svc.name === defaultSVC && svc.tag && svc.tag.id && !value) {
onChange(null, { value: svc.tag.id })
}

return [
svc.tag ? svc.tag.id : null,
{
Expand All @@ -49,10 +45,10 @@ const XServiceTypeahead: React.FC<{ value: string, onChange: (event: React.Synth

const getDropdown = () => (
<Dropdown
placeholder="Default Service"
placeholder="Any Service"
icon=""
fluid
// search
clearable
selection
error={error !== null && error !== undefined}
loading={loading}
Expand Down
5 changes: 2 additions & 3 deletions www/src/components/job/XJobSettingsModal.tsx
Expand Up @@ -21,10 +21,9 @@ const XJobSettingsModal: React.FC<{
<XServiceTypeahead
labeled
value={serviceTag}
defaultSVC={"pg-worker"}
onChange={(e, { value }) => setServiceTag(value)}
/>
{/* <XTagTypeahead
/>;
{/* <XTagTypeahead
labeled
onChange={(e, { value }) => setTags(value)}
/> */}
Expand Down
120 changes: 0 additions & 120 deletions www/src/components/target/XTargetCreateForm.tsx

This file was deleted.

43 changes: 37 additions & 6 deletions www/src/components/target/XTargetCreateModal.tsx
Expand Up @@ -3,14 +3,14 @@ import { ApolloError } from "apollo-client/errors/ApolloError";
import gql from "graphql-tag";
import * as React from "react";
import { useState } from "react";
import { Button, Form, Grid, Input, Message, Modal } from "semantic-ui-react";
import { Button, Dropdown, Form, Grid, Input, Message, Modal } from "semantic-ui-react";
import { Tag } from "../../graphql/models";
import { MULTI_TARGET_QUERY } from "../../views";
import { useModal, XTagTypeahead } from "../form";

export const CREATE_TARGET_MUTATION = gql`
mutation CreateTarget($name: String!, $primaryIP: String!, $tags: [ID!]) {
createTarget(input: { name: $name, primaryIP: $primaryIP, tags: $tags }) {
mutation CreateTarget($name: String!, $primaryIP: String!, $os: String!, $tags: [ID!]) {
createTarget(input: { name: $name, primaryIP: $primaryIP, os: $os, tags: $tags }) {
id
name
primaryIP
Expand All @@ -35,6 +35,7 @@ const XTargetCreateModal = ({ openOnStart }: TargetCreateModalParams) => {
const [name, setName] = useState<string>("");
const [primaryIP, setPrimaryIP] = useState<string>("");
const [tags, setTags] = useState<Tag[]>([]);
const [os, setOS] = useState<string>("LINUX");

const [createTarget, { called, loading }] = useMutation(
CREATE_TARGET_MUTATION,
Expand All @@ -47,7 +48,8 @@ const XTargetCreateModal = ({ openOnStart }: TargetCreateModalParams) => {
let vars = {
name: name,
primaryIP: primaryIP,
tags: tags
tags: tags,
os: os,
};

createTarget({
Expand All @@ -72,6 +74,20 @@ const XTargetCreateModal = ({ openOnStart }: TargetCreateModalParams) => {
openModal();
}

let osIcon = "windows";
switch (os) {
case "WINDOWS":
osIcon = "windows";
break;
case "LINUX":
osIcon = "linux";
break;
case "BSD":
osIcon = "freebsd";
case "MACOS":
osIcon = "apple";
}

return (
<Modal
open={isOpen}
Expand All @@ -98,11 +114,26 @@ const XTargetCreateModal = ({ openOnStart }: TargetCreateModalParams) => {
onChange={(e, { value }) => setName(value)}
/>
</Grid.Column>

<Grid.Column>
<Input fluid label="OS" icon={osIcon} input={<Dropdown
icon=""
fluid
selection
options={[
{ text: "Linux", value: "LINUX" },
{ text: "Windows", value: "WINDOWS" },
{ text: "BSD", value: "BSD" },
{ text: "MacOS", value: "MACOS" },
]}
name="os"
value={os}
onChange={(e, { value }) => setOS(value.toString())}
/>} />
</Grid.Column>
<Grid.Column>
<Input
label="Primary IP"
icon="desktop"
icon="plug"
fluid
placeholder="Enter primary ip address"
name="primaryIP"
Expand Down
2 changes: 1 addition & 1 deletion www/src/components/target/index.ts
@@ -1,5 +1,5 @@
export { default as XNoTargetsFound } from './XNoTargetsFound';
export { default as XTargetCard } from './XTargetCard';
export { default as XTargetCreateForm } from './XTargetCreateForm';
export { default as XTargetCreateModal } from './XTargetCreateModal';
export { default as XTargetHeader } from './XTargetHeader';

0 comments on commit 94954b2

Please sign in to comment.