mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-18 21:19:44 +00:00
feat: add shortcut tags in UI
This commit is contained in:
parent
f3c758ff22
commit
b3640699e0
@ -23,8 +23,10 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
link: "",
|
link: "",
|
||||||
description: "",
|
description: "",
|
||||||
visibility: "PRIVATE",
|
visibility: "PRIVATE",
|
||||||
|
tags: [],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const [tag, setTag] = useState<string>("");
|
||||||
const requestState = useLoading(false);
|
const requestState = useLoading(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -40,6 +42,7 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
visibility: shortcutTemp.visibility,
|
visibility: shortcutTemp.visibility,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
setTag(shortcutTemp.tags.join(" "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [shortcutId]);
|
}, [shortcutId]);
|
||||||
@ -67,6 +70,11 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
handleInputChange(e, "description");
|
handleInputChange(e, "description");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleTagsInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const text = e.target.value as string;
|
||||||
|
setTag(text);
|
||||||
|
};
|
||||||
|
|
||||||
const handleVisibilityInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleVisibilityInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
handleInputChange(e, "visibility");
|
handleInputChange(e, "visibility");
|
||||||
};
|
};
|
||||||
@ -85,9 +93,13 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
link: state.shortcutCreate.link,
|
link: state.shortcutCreate.link,
|
||||||
description: state.shortcutCreate.description,
|
description: state.shortcutCreate.description,
|
||||||
visibility: state.shortcutCreate.visibility,
|
visibility: state.shortcutCreate.visibility,
|
||||||
|
tags: tag.split(" "),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await shortcutService.createShortcut(state.shortcutCreate);
|
await shortcutService.createShortcut({
|
||||||
|
...state.shortcutCreate,
|
||||||
|
tags: tag.split(" "),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onConfirm) {
|
if (onConfirm) {
|
||||||
@ -145,6 +157,10 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
onChange={handleDescriptionInputChange}
|
onChange={handleDescriptionInputChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="w-full flex flex-col justify-start items-start mb-3">
|
||||||
|
<span className="mb-2">Tags</span>
|
||||||
|
<Input className="w-full" type="text" placeholder="Tags" value={tag} onChange={handleTagsInputChange} />
|
||||||
|
</div>
|
||||||
<div className="w-full flex flex-col justify-start items-start mb-3">
|
<div className="w-full flex flex-col justify-start items-start mb-3">
|
||||||
<span className="mb-2">
|
<span className="mb-2">
|
||||||
Visibility <span className="text-red-600">*</span>
|
Visibility <span className="text-red-600">*</span>
|
||||||
|
@ -58,10 +58,21 @@ const ShortcutListView: React.FC<Props> = (props: Props) => {
|
|||||||
<div className="w-full flex flex-col justify-start items-start">
|
<div className="w-full flex flex-col justify-start items-start">
|
||||||
{shortcutList.map((shortcut) => {
|
{shortcutList.map((shortcut) => {
|
||||||
return (
|
return (
|
||||||
<div key={shortcut.id} className="w-full flex flex-row justify-between items-start border px-6 py-4 mb-3 rounded-lg">
|
<div key={shortcut.id} className="w-full flex flex-row justify-between items-start border px-4 py-3 mb-2 rounded-lg">
|
||||||
<div className="flex flex-row justify-start items-center mr-4">
|
<div className="flex flex-col justify-start items-start mr-4">
|
||||||
<span>{shortcut.name}</span>
|
<p>
|
||||||
<span className="text-gray-400 text-sm ml-2">({shortcut.description})</span>
|
<span>{shortcut.name}</span>
|
||||||
|
{shortcut.description && <span className="text-gray-500 ml-1">({shortcut.description})</span>}
|
||||||
|
</p>
|
||||||
|
<div className="space-x-2">
|
||||||
|
{shortcut.tags.map((tag) => {
|
||||||
|
return (
|
||||||
|
<span key={tag} className="text-gray-400 text-sm font-mono">
|
||||||
|
#{tag}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-row justify-end items-center">
|
<div className="flex flex-row justify-end items-center">
|
||||||
<span className="w-16 truncate mr-2 text-gray-600">{shortcut.creator.nickname}</span>
|
<span className="w-16 truncate mr-2 text-gray-600">{shortcut.creator.nickname}</span>
|
||||||
|
@ -47,13 +47,12 @@ export function getShortcutList(shortcutFind?: ShortcutFind) {
|
|||||||
if (shortcutFind?.creatorId) {
|
if (shortcutFind?.creatorId) {
|
||||||
queryList.push(`creatorId=${shortcutFind.creatorId}`);
|
queryList.push(`creatorId=${shortcutFind.creatorId}`);
|
||||||
}
|
}
|
||||||
|
if (shortcutFind?.tag) {
|
||||||
|
queryList.push(`tag=${shortcutFind.tag}`);
|
||||||
|
}
|
||||||
return axios.get<Shortcut[]>(`/api/v1/shortcut?${queryList.join("&")}`);
|
return axios.get<Shortcut[]>(`/api/v1/shortcut?${queryList.join("&")}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getShortcutWithNameAndWorkspaceName(workspaceName: string, shortcutName: string) {
|
|
||||||
return axios.get<Shortcut>(`/api/v1/workspace/${workspaceName}/shortcut/${shortcutName}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createShortcut(shortcutCreate: ShortcutCreate) {
|
export function createShortcut(shortcutCreate: ShortcutCreate) {
|
||||||
return axios.post<Shortcut>("/api/v1/shortcut", shortcutCreate);
|
return axios.post<Shortcut>("/api/v1/shortcut", shortcutCreate);
|
||||||
}
|
}
|
||||||
|
4
web/src/types/modules/shortcut.d.ts
vendored
4
web/src/types/modules/shortcut.d.ts
vendored
@ -15,6 +15,7 @@ interface Shortcut {
|
|||||||
link: string;
|
link: string;
|
||||||
description: string;
|
description: string;
|
||||||
visibility: Visibility;
|
visibility: Visibility;
|
||||||
|
tags: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShortcutCreate {
|
interface ShortcutCreate {
|
||||||
@ -22,6 +23,7 @@ interface ShortcutCreate {
|
|||||||
link: string;
|
link: string;
|
||||||
description: string;
|
description: string;
|
||||||
visibility: Visibility;
|
visibility: Visibility;
|
||||||
|
tags: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShortcutPatch {
|
interface ShortcutPatch {
|
||||||
@ -31,8 +33,10 @@ interface ShortcutPatch {
|
|||||||
link?: string;
|
link?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
visibility?: Visibility;
|
visibility?: Visibility;
|
||||||
|
tags?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShortcutFind {
|
interface ShortcutFind {
|
||||||
creatorId?: UserId;
|
creatorId?: UserId;
|
||||||
|
tag?: string;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user