mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-18 21:19:44 +00:00
feat: add title field to shortcut
This commit is contained in:
parent
714889433f
commit
e6ece43231
@ -49,6 +49,7 @@ type Shortcut struct {
|
|||||||
// Domain specific fields
|
// Domain specific fields
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Visibility Visibility `json:"visibility"`
|
Visibility Visibility `json:"visibility"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
@ -59,6 +60,7 @@ type Shortcut struct {
|
|||||||
type CreateShortcutRequest struct {
|
type CreateShortcutRequest struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Link string `json:"link"`
|
Link string `json:"link"`
|
||||||
|
Title string `json:"title"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Visibility Visibility `json:"visibility"`
|
Visibility Visibility `json:"visibility"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
@ -69,6 +71,7 @@ type PatchShortcutRequest struct {
|
|||||||
RowStatus *RowStatus `json:"rowStatus"`
|
RowStatus *RowStatus `json:"rowStatus"`
|
||||||
Name *string `json:"name"`
|
Name *string `json:"name"`
|
||||||
Link *string `json:"link"`
|
Link *string `json:"link"`
|
||||||
|
Title *string `json:"title"`
|
||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
Visibility *Visibility `json:"visibility"`
|
Visibility *Visibility `json:"visibility"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
@ -91,6 +94,7 @@ func (s *APIV1Service) registerShortcutRoutes(g *echo.Group) {
|
|||||||
CreatorID: userID,
|
CreatorID: userID,
|
||||||
Name: strings.ToLower(create.Name),
|
Name: strings.ToLower(create.Name),
|
||||||
Link: create.Link,
|
Link: create.Link,
|
||||||
|
Title: create.Title,
|
||||||
Description: create.Description,
|
Description: create.Description,
|
||||||
Visibility: store.Visibility(create.Visibility.String()),
|
Visibility: store.Visibility(create.Visibility.String()),
|
||||||
Tag: strings.Join(create.Tags, " "),
|
Tag: strings.Join(create.Tags, " "),
|
||||||
@ -158,6 +162,7 @@ func (s *APIV1Service) registerShortcutRoutes(g *echo.Group) {
|
|||||||
ID: shortcutID,
|
ID: shortcutID,
|
||||||
Name: patch.Name,
|
Name: patch.Name,
|
||||||
Link: patch.Link,
|
Link: patch.Link,
|
||||||
|
Title: patch.Title,
|
||||||
Description: patch.Description,
|
Description: patch.Description,
|
||||||
}
|
}
|
||||||
if patch.RowStatus != nil {
|
if patch.RowStatus != nil {
|
||||||
@ -332,6 +337,7 @@ func convertShortcutFromStore(shortcut *store.Shortcut) *Shortcut {
|
|||||||
CreatorID: shortcut.CreatorID,
|
CreatorID: shortcut.CreatorID,
|
||||||
Name: shortcut.Name,
|
Name: shortcut.Name,
|
||||||
Link: shortcut.Link,
|
Link: shortcut.Link,
|
||||||
|
Title: shortcut.Title,
|
||||||
Description: shortcut.Description,
|
Description: shortcut.Description,
|
||||||
Visibility: Visibility(shortcut.Visibility),
|
Visibility: Visibility(shortcut.Visibility),
|
||||||
RowStatus: RowStatus(shortcut.RowStatus),
|
RowStatus: RowStatus(shortcut.RowStatus),
|
||||||
|
@ -41,6 +41,7 @@ CREATE TABLE shortcut (
|
|||||||
row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL',
|
row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL',
|
||||||
name TEXT NOT NULL UNIQUE,
|
name TEXT NOT NULL UNIQUE,
|
||||||
link TEXT NOT NULL,
|
link TEXT NOT NULL,
|
||||||
|
title TEXT NOT NULL DEFAULT '',
|
||||||
description TEXT NOT NULL DEFAULT '',
|
description TEXT NOT NULL DEFAULT '',
|
||||||
visibility TEXT NOT NULL CHECK (visibility IN ('PRIVATE', 'WORKSPACE', 'PUBLIC')) DEFAULT 'PRIVATE',
|
visibility TEXT NOT NULL CHECK (visibility IN ('PRIVATE', 'WORKSPACE', 'PUBLIC')) DEFAULT 'PRIVATE',
|
||||||
tag TEXT NOT NULL DEFAULT '',
|
tag TEXT NOT NULL DEFAULT '',
|
||||||
|
1
store/db/migration/prod/0.4/00__add_shortcut_title.sql
Normal file
1
store/db/migration/prod/0.4/00__add_shortcut_title.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE shortcut ADD COLUMN title TEXT NOT NULL DEFAULT '';
|
@ -41,6 +41,7 @@ CREATE TABLE shortcut (
|
|||||||
row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL',
|
row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL',
|
||||||
name TEXT NOT NULL UNIQUE,
|
name TEXT NOT NULL UNIQUE,
|
||||||
link TEXT NOT NULL,
|
link TEXT NOT NULL,
|
||||||
|
title TEXT NOT NULL DEFAULT '',
|
||||||
description TEXT NOT NULL DEFAULT '',
|
description TEXT NOT NULL DEFAULT '',
|
||||||
visibility TEXT NOT NULL CHECK (visibility IN ('PRIVATE', 'WORKSPACE', 'PUBLIC')) DEFAULT 'PRIVATE',
|
visibility TEXT NOT NULL CHECK (visibility IN ('PRIVATE', 'WORKSPACE', 'PUBLIC')) DEFAULT 'PRIVATE',
|
||||||
tag TEXT NOT NULL DEFAULT '',
|
tag TEXT NOT NULL DEFAULT '',
|
||||||
|
@ -50,6 +50,7 @@ type Shortcut struct {
|
|||||||
// Domain specific fields
|
// Domain specific fields
|
||||||
Name string
|
Name string
|
||||||
Link string
|
Link string
|
||||||
|
Title string
|
||||||
Description string
|
Description string
|
||||||
Visibility Visibility
|
Visibility Visibility
|
||||||
Tag string
|
Tag string
|
||||||
@ -62,6 +63,7 @@ type UpdateShortcut struct {
|
|||||||
RowStatus *RowStatus
|
RowStatus *RowStatus
|
||||||
Name *string
|
Name *string
|
||||||
Link *string
|
Link *string
|
||||||
|
Title *string
|
||||||
Description *string
|
Description *string
|
||||||
Visibility *Visibility
|
Visibility *Visibility
|
||||||
Tag *string
|
Tag *string
|
||||||
@ -82,9 +84,9 @@ type DeleteShortcut struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) CreateShortcut(ctx context.Context, create *Shortcut) (*Shortcut, error) {
|
func (s *Store) CreateShortcut(ctx context.Context, create *Shortcut) (*Shortcut, error) {
|
||||||
set := []string{"creator_id", "name", "link", "description", "visibility", "tag"}
|
set := []string{"creator_id", "name", "link", "title", "description", "visibility", "tag"}
|
||||||
args := []any{create.CreatorID, create.Name, create.Link, create.Description, create.Visibility, create.Tag}
|
args := []any{create.CreatorID, create.Name, create.Link, create.Title, create.Description, create.Visibility, create.Tag}
|
||||||
placeholder := []string{"?", "?", "?", "?", "?", "?"}
|
placeholder := []string{"?", "?", "?", "?", "?", "?", "?"}
|
||||||
if create.OpenGraphMetadata != nil {
|
if create.OpenGraphMetadata != nil {
|
||||||
set = append(set, "og_metadata")
|
set = append(set, "og_metadata")
|
||||||
openGraphMetadataBytes, err := json.Marshal(create.OpenGraphMetadata)
|
openGraphMetadataBytes, err := json.Marshal(create.OpenGraphMetadata)
|
||||||
@ -125,6 +127,9 @@ func (s *Store) UpdateShortcut(ctx context.Context, update *UpdateShortcut) (*Sh
|
|||||||
if update.Link != nil {
|
if update.Link != nil {
|
||||||
set, args = append(set, "link = ?"), append(args, *update.Link)
|
set, args = append(set, "link = ?"), append(args, *update.Link)
|
||||||
}
|
}
|
||||||
|
if update.Title != nil {
|
||||||
|
set, args = append(set, "title = ?"), append(args, *update.Title)
|
||||||
|
}
|
||||||
if update.Description != nil {
|
if update.Description != nil {
|
||||||
set, args = append(set, "description = ?"), append(args, *update.Description)
|
set, args = append(set, "description = ?"), append(args, *update.Description)
|
||||||
}
|
}
|
||||||
@ -152,7 +157,7 @@ func (s *Store) UpdateShortcut(ctx context.Context, update *UpdateShortcut) (*Sh
|
|||||||
` + strings.Join(set, ", ") + `
|
` + strings.Join(set, ", ") + `
|
||||||
WHERE
|
WHERE
|
||||||
id = ?
|
id = ?
|
||||||
RETURNING id, creator_id, created_ts, updated_ts, row_status, name, link, description, visibility, tag, og_metadata
|
RETURNING id, creator_id, created_ts, updated_ts, row_status, name, link, title, description, visibility, tag, og_metadata
|
||||||
`
|
`
|
||||||
shortcut := &Shortcut{}
|
shortcut := &Shortcut{}
|
||||||
openGraphMetadataString := ""
|
openGraphMetadataString := ""
|
||||||
@ -164,6 +169,7 @@ func (s *Store) UpdateShortcut(ctx context.Context, update *UpdateShortcut) (*Sh
|
|||||||
&shortcut.RowStatus,
|
&shortcut.RowStatus,
|
||||||
&shortcut.Name,
|
&shortcut.Name,
|
||||||
&shortcut.Link,
|
&shortcut.Link,
|
||||||
|
&shortcut.Title,
|
||||||
&shortcut.Description,
|
&shortcut.Description,
|
||||||
&shortcut.Visibility,
|
&shortcut.Visibility,
|
||||||
&shortcut.Tag,
|
&shortcut.Tag,
|
||||||
@ -217,6 +223,7 @@ func (s *Store) ListShortcuts(ctx context.Context, find *FindShortcut) ([]*Short
|
|||||||
row_status,
|
row_status,
|
||||||
name,
|
name,
|
||||||
link,
|
link,
|
||||||
|
title,
|
||||||
description,
|
description,
|
||||||
visibility,
|
visibility,
|
||||||
tag,
|
tag,
|
||||||
@ -243,6 +250,7 @@ func (s *Store) ListShortcuts(ctx context.Context, find *FindShortcut) ([]*Short
|
|||||||
&shortcut.RowStatus,
|
&shortcut.RowStatus,
|
||||||
&shortcut.Name,
|
&shortcut.Name,
|
||||||
&shortcut.Link,
|
&shortcut.Link,
|
||||||
|
&shortcut.Title,
|
||||||
&shortcut.Description,
|
&shortcut.Description,
|
||||||
&shortcut.Visibility,
|
&shortcut.Visibility,
|
||||||
&shortcut.Tag,
|
&shortcut.Tag,
|
||||||
|
@ -27,6 +27,7 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
shortcutCreate: {
|
shortcutCreate: {
|
||||||
name: "",
|
name: "",
|
||||||
link: "",
|
link: "",
|
||||||
|
title: "",
|
||||||
description: "",
|
description: "",
|
||||||
visibility: "PRIVATE",
|
visibility: "PRIVATE",
|
||||||
tags: [],
|
tags: [],
|
||||||
@ -85,6 +86,14 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleTitleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setPartialState({
|
||||||
|
shortcutCreate: Object.assign(state.shortcutCreate, {
|
||||||
|
title: e.target.value,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleVisibilityInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleVisibilityInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setPartialState({
|
setPartialState({
|
||||||
shortcutCreate: Object.assign(state.shortcutCreate, {
|
shortcutCreate: Object.assign(state.shortcutCreate, {
|
||||||
@ -184,6 +193,18 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<div className="overflow-y-auto overflow-x-hidden">
|
<div className="overflow-y-auto overflow-x-hidden">
|
||||||
|
<div className="w-full flex flex-col justify-start items-start mb-3">
|
||||||
|
<span className="mb-2">Title</span>
|
||||||
|
<div className="relative w-full">
|
||||||
|
<Input
|
||||||
|
className="w-full"
|
||||||
|
type="text"
|
||||||
|
placeholder="Title"
|
||||||
|
value={state.shortcutCreate.title}
|
||||||
|
onChange={handleTitleInputChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</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">Name</span>
|
<span className="mb-2">Name</span>
|
||||||
<div className="relative w-full">
|
<div className="relative w-full">
|
||||||
|
3
web/src/types/modules/shortcut.d.ts
vendored
3
web/src/types/modules/shortcut.d.ts
vendored
@ -19,6 +19,7 @@ interface Shortcut {
|
|||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
link: string;
|
link: string;
|
||||||
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
visibility: Visibility;
|
visibility: Visibility;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
@ -29,6 +30,7 @@ interface Shortcut {
|
|||||||
interface ShortcutCreate {
|
interface ShortcutCreate {
|
||||||
name: string;
|
name: string;
|
||||||
link: string;
|
link: string;
|
||||||
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
visibility: Visibility;
|
visibility: Visibility;
|
||||||
tags: string[];
|
tags: string[];
|
||||||
@ -40,6 +42,7 @@ interface ShortcutPatch {
|
|||||||
|
|
||||||
name?: string;
|
name?: string;
|
||||||
link?: string;
|
link?: string;
|
||||||
|
title?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
visibility?: Visibility;
|
visibility?: Visibility;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user