Skip to content

Commit

Permalink
refactor(console): Rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
pjdotson committed Sep 8, 2024
1 parent c43bcae commit eade4db
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
2 changes: 1 addition & 1 deletion console/src/range/CreateLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import "@/range/CreateLayout.css";

import { ontology, ranger, TimeRange, TimeStamp } from "@synnaxlabs/client";
import { ontology, type ranger, TimeRange, TimeStamp } from "@synnaxlabs/client";
import { Icon } from "@synnaxlabs/media";
import {
Align,
Expand Down
21 changes: 9 additions & 12 deletions console/src/range/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ import { Layout } from "@/layout";
import { createLayout } from "@/range/CreateLayout";
import { type Range } from "@/range/slice";

export interface SelectMultipleRangesProps
extends Select.MultipleProps<string, Range> {}
interface SelectMultipleRangesProps extends Select.MultipleProps<string, Range> {}

const dynamicIcon = (
<Icon.Dynamic style={{ color: "var(--pluto-error-p1)", filter: "opacity(0.8)" }} />
);

export const listColumns: Array<List.ColumnSpec<string, Range>> = [
const listColumns: Array<List.ColumnSpec<string, Range>> = [
{
key: "name",
name: "Name",
Expand Down Expand Up @@ -72,9 +71,7 @@ const RenderTag = ({

const renderTag = componentRenderProp(RenderTag);

export const SelectMultipleRanges = (
props: SelectMultipleRangesProps,
): ReactElement => (
const SelectMultipleRanges = (props: SelectMultipleRangesProps): ReactElement => (
<Select.Multiple
columns={listColumns}
entryRenderKey="name"
Expand All @@ -83,27 +80,27 @@ export const SelectMultipleRanges = (
/>
);

export interface SelectSingleRangeProps extends Select.SingleProps<string, Range> {}
interface SelectSingleRangeProps extends Select.SingleProps<string, Range> {}

export const SelectRange = (props: SelectSingleRangeProps): ReactElement => (
const SelectRange = (props: SelectSingleRangeProps): ReactElement => (
<Select.Single columns={listColumns} {...props} entryRenderKey="name" />
);

export interface SelectMultipleInputItemProps
interface SelectMultipleInputItemProps
extends Omit<Input.ItemProps, "label" | "onChange">,
Pick<SelectMultipleRangesProps, "data"> {
value: string[];
onChange: (value: string[]) => void;
}

const SelectEmptyContent = (): ReactElement => {
const newLayout = Layout.usePlacer();
const placer = Layout.usePlacer();
return (
<Align.Center style={{ height: 150 }} direction="x">
<Status.Text variant="disabled" hideIcon>
No Ranges:
</Status.Text>
<Button.Button variant="outlined" onClick={() => newLayout(createLayout({}))}>
<Button.Button variant="outlined" onClick={() => placer(createLayout({}))}>
Define a Range
</Button.Button>
</Align.Center>
Expand All @@ -126,7 +123,7 @@ export const SelectMultipleInputItem = ({
</Input.Item>
);

export interface SelectInputItemProps
interface SelectInputItemProps
extends Omit<Input.ItemProps, "label" | "onChange">,
Input.Control<string>,
Pick<SelectSingleRangeProps, "data"> {}
Expand Down
16 changes: 8 additions & 8 deletions console/src/range/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ const useViewDetails = (): ((key: string) => void) => {
const store = useStore<RootState>();
const client = Synnax.use();
const addStatus = Status.useAggregator();
const placeLayout = Layout.usePlacer();
const placer = Layout.usePlacer();
return useMutation<void, Error, string>({
mutationFn: async (key: string) => {
if (client == null) return;
const rng = await fetchIfNotInState(store, client, key);
placeLayout({ ...overviewLayout, name: rng.name, key: rng.key });
placer({ ...overviewLayout, name: rng.name, key: rng.key });
},
onError: (e) => {
addStatus({
Expand All @@ -186,13 +186,13 @@ const useViewDetails = (): ((key: string) => void) => {
const useAddToNewPlot = (): ((key: string) => void) => {
const store = useStore<RootState>();
const client = Synnax.use();
const placeLayout = Layout.usePlacer();
const placer = Layout.usePlacer();
const addStatus = Status.useAggregator();
return useMutation<void, Error, string>({
mutationFn: async (key: string) => {
if (client == null) return;
const res = await fetchIfNotInState(store, client, key);
placeLayout(
placer(
createLinePlot({
name: `Plot for ${res.name}`,
ranges: { x1: [key], x2: [] },
Expand Down Expand Up @@ -233,14 +233,14 @@ const NoRanges = ({ onLinkClick }: NoRangesProps): ReactElement => {
const List = (): ReactElement => {
const menuProps = PMenu.useContextMenu();
const client = Synnax.use();
const placeLayout = Layout.usePlacer();
const placer = Layout.usePlacer();
const removeLayout = Layout.useRemover();
const dispatch = useDispatch();
const ranges = useSelectMultiple();
const activeRange = useSelect();

const handleCreate = (key?: string): void =>
void placeLayout(createLayout({ initial: { key } }));
void placer(createLayout({ initial: { key } }));

const handleRemove = (keys: string[]): void => void dispatch(remove({ keys }));

Expand Down Expand Up @@ -306,11 +306,11 @@ const List = (): ReactElement => {
const activeLayout = Layout.useSelectActiveMosaicLayout();
const addToActivePlot = useAddToActivePlot();
const addToNewPlot = useAddToNewPlot();
const placeLayout = Layout.usePlacer();
const placer = Layout.usePlacer();
const handleSetActive = () => void dispatch(setActive(key));
const handleViewDetails = useViewDetails();
const handleAddChildRange = () =>
void placeLayout(createLayout({ initial: { parent: key } }));
void placer(createLayout({ initial: { parent: key } }));

const rangeExists = rng != null;

Expand Down
11 changes: 5 additions & 6 deletions console/src/range/services/ontology.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,13 @@ const useAddToNewPlot = (): ((props: Ontology.TreeContextMenuProps) => void) =>
}).mutate;

const useViewDetails = (): ((props: Ontology.TreeContextMenuProps) => void) => {
const placeLayout = Layout.usePlacer();
return ({ selection: { resources } }) => {
placeLayout({
const placer = Layout.usePlacer();
return ({ selection: { resources } }) =>
placer({
...overviewLayout,
name: resources[0].name,
key: resources[0].id.key,
});
};
};

const useDelete = (): ((props: Ontology.TreeContextMenuProps) => void) => {
Expand Down Expand Up @@ -215,9 +214,9 @@ const TreeContextMenu: Ontology.TreeContextMenu = (props) => {
const activate = useActivate();
const groupFromSelection = Group.useCreateFromSelection();
const handleLink = Link.useCopyToClipboard();
const placeLayout = Layout.usePlacer();
const placer = Layout.usePlacer();
const handleAddChildRange = () =>
void placeLayout(createLayout({ initial: { parent: resources[0].id.key } }));
void placer(createLayout({ initial: { parent: resources[0].id.key } }));
const viewDetails = useViewDetails();
const handleSelect = {
delete: () => handleDelete(props),
Expand Down

0 comments on commit eade4db

Please sign in to comment.