Skip to content

Commit

Permalink
Merge pull request #52 from Finsemble/lintandprettier
Browse files Browse the repository at this point in the history
prettier and lint
  • Loading branch information
karisjlin authored Dec 23, 2022
2 parents c61862a + dc6d93f commit ecf0c55
Show file tree
Hide file tree
Showing 19 changed files with 483 additions and 420 deletions.
5 changes: 1 addition & 4 deletions toolbox/fdc3-workbench/src/components/AppChannels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ export const AppChannels = observer(({ handleTabChange }: { handleTabChange: any
</Grid>
</form>
<div className={classes.border}></div>
<ChannelField
handleTabChange={handleTabChange}
channelsList={appChannelStore.appChannelsList}
/>
<ChannelField handleTabChange={handleTabChange} channelsList={appChannelStore.appChannelsList} />
</div>
);
});
40 changes: 17 additions & 23 deletions toolbox/fdc3-workbench/src/components/ChannelField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import FileCopyIcon from "@material-ui/icons/FileCopy";
import Autocomplete, { createFilterOptions } from "@material-ui/lab/Autocomplete";
import contextStore from "../store/ContextStore";
import { TemplateTextField } from "./common/TemplateTextField";
import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined';
import InfoOutlinedIcon from "@material-ui/icons/InfoOutlined";

interface ListenerOptionType {
title: string;
Expand Down Expand Up @@ -105,7 +105,7 @@ const useStyles = makeStyles((theme: Theme) =>
},
rightPadding: {
paddingRight: theme.spacing(0.5),
}
},
})
);

Expand All @@ -114,17 +114,17 @@ export const ChannelField = observer(
handleTabChange,
channelsList,
isPrivateChannel = false,
channelName
channelName,
}: {
handleTabChange: any;
channelsList: any;
isPrivateChannel?: boolean;
channelName? : string;
channelName?: string;
}) => {
const classes = useStyles();
const [contextItem, setContextItem] = useState<ContextType | null>(null);
const [currentChannelList, setCurrentChannelList] = useState<any>(channelsList);

const channelStore = isPrivateChannel ? privateChannelStore : appChannelStore;

const contextListenersOptionsAll: ListenerOptionType[] = contextStore.contextsList.map(({ id, template }) => {
Expand Down Expand Up @@ -225,18 +225,18 @@ export const ChannelField = observer(
};

const handleRemoveOrDisconnect = (channel: any) => {
if(isPrivateChannel) {
if (isPrivateChannel) {
privateChannelStore.disconnect(channel);
} else {
appChannelStore.remove(channel);
}
setCurrentChannelList(currentChannelList.filter((currentChannel: any) => currentChannel.id !== channel.id));
}
};

useEffect(() => {
setCurrentChannelList(channelsList);
}, [channelsList])
setCurrentChannelList(channelsList);
}, [channelsList]);

return (
<div>
{currentChannelList.length > 0 &&
Expand Down Expand Up @@ -283,7 +283,6 @@ export const ChannelField = observer(
<Link target="_blank" href="https://fdc3.finos.org/docs/api/ref/Channel#broadcast">
<InfoOutlinedIcon />
</Link>

</Grid>
</Grid>
<Grid container>
Expand Down Expand Up @@ -344,24 +343,19 @@ export const ChannelField = observer(
</Link>
</Grid>
</Grid>
<Button
variant="contained"
color="secondary"
onClick={() => handleRemoveOrDisconnect(channel)}
>
{isPrivateChannel ? 'Disconnect' : 'Remove'}
<Button variant="contained" color="secondary" onClick={() => handleRemoveOrDisconnect(channel)}>
{isPrivateChannel ? "Disconnect" : "Remove"}
</Button>
<div className={classes.border}></div>
</Grid>
);

if(channelName) {
return channel.id === channelName && element
if (channelName) {
return channel.id === channelName && element;
} else {
return element
return element;
}
})
}
})}
</div>
);
}
Expand Down
67 changes: 31 additions & 36 deletions toolbox/fdc3-workbench/src/components/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { ContextLinking } from "./ContextLinking";
import contextStore from "../store/ContextStore";
import { ContextTemplates } from "./ContextTemplates";
import { ContextType } from "../utility/Fdc3Api";
import InfoOutlinedIcon from '@material-ui/icons/InfoOutlined';
import InfoOutlinedIcon from "@material-ui/icons/InfoOutlined";

const useStyles = makeStyles((theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -69,11 +69,11 @@ const useStyles = makeStyles((theme: Theme) =>
})
);

export const Channels = observer(({handleTabChange} : {handleTabChange:any}) => {
export const Channels = observer(({ handleTabChange }: { handleTabChange: any }) => {
const classes = useStyles();
const [channelId, setChannelId] = useState<string>("");
const [isError, setIsError] = useState<boolean>(false);
const [broadcastContext, setBroadcastContext] = useState<ContextType | null>(null)
const [broadcastContext, setBroadcastContext] = useState<ContextType | null>(null);

const handleSelectChange = (event: React.ChangeEvent<{ value: unknown }>) => {
setChannelId(event.target.value as string);
Expand All @@ -98,7 +98,7 @@ export const Channels = observer(({handleTabChange} : {handleTabChange:any}) =>
};

const handleBroadcast = () => {
if(broadcastContext) contextStore.broadcast(broadcastContext);
if (broadcastContext) contextStore.broadcast(broadcastContext);
};

return (
Expand Down Expand Up @@ -223,42 +223,37 @@ export const Channels = observer(({handleTabChange} : {handleTabChange:any}) =>
</Grid>

<Grid container direction="row" spacing={1}>
<Grid item sm={9}>
<ContextTemplates handleTabChange={handleTabChange} contextStateSetter={setBroadcastContext} />
</Grid>
<Grid item sm={3} className={classes.centerChildren}>
<Grid container direction="row" justifyContent="flex-end" spacing={1}>
<Grid item className={classes.controls} >
<Button
disabled={!broadcastContext}
variant="contained"
<Grid item sm={9}>
<ContextTemplates handleTabChange={handleTabChange} contextStateSetter={setBroadcastContext} />
</Grid>
<Grid item sm={3} className={classes.centerChildren}>
<Grid container direction="row" justifyContent="flex-end" spacing={1}>
<Grid item className={classes.controls}>
<Button disabled={!broadcastContext} variant="contained" color="primary" onClick={handleBroadcast}>
Broadcast Context
</Button>
</Grid>
<Grid item className={classes.controls}>
<Tooltip title="Copy code example" aria-label="Copy code example">
<IconButton
size="small"
aria-label="Copy code example"
color="primary"
onClick={handleBroadcast}
onClick={copyToClipboard(codeExamples.broadcast, "broadcast")}
>
Broadcast Context
</Button>
</Grid>
<Grid item className={classes.controls} >
<Tooltip title="Copy code example" aria-label="Copy code example">
<IconButton
size="small"
aria-label="Copy code example"
color="primary"
onClick={copyToClipboard(codeExamples.broadcast, "broadcast")}
>
<FileCopyIcon />
</IconButton>
</Tooltip>
<Link target="_blank" href="https://fdc3.finos.org/docs/api/ref/DesktopAgent#broadcast">
<InfoOutlinedIcon />
</Link>
</Grid>
<FileCopyIcon />
</IconButton>
</Tooltip>
<Link target="_blank" href="https://fdc3.finos.org/docs/api/ref/DesktopAgent#broadcast">
<InfoOutlinedIcon />
</Link>
</Grid>
</Grid>
<div className={classes.border}></div>

<ContextLinking />
</Grid>
</Grid>
<div className={classes.border}></div>

<ContextLinking />
</Grid>
</div>
);
});
Loading

0 comments on commit ecf0c55

Please sign in to comment.