Skip to content

Commit 531ede0

Browse files
committed
Added option to set custom description for apps
1 parent b08181e commit 531ede0

File tree

7 files changed

+53
-9
lines changed

7 files changed

+53
-9
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v2.2.0 (TBA)
2+
- Added option to set custom description for apps ([#201](https://github.com/pawelmalak/flame/issues/201))
3+
14
### v2.1.1 (2021-12-02)
25
- Added support for Docker secrets ([#189](https://github.com/pawelmalak/flame/issues/189))
36
- Changed some messages and buttons to make it easier to open bookmarks editor ([#239](https://github.com/pawelmalak/flame/issues/239))

client/src/components/Apps/AppCard/AppCard.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,23 @@ import { State } from '../../../store/reducers';
88

99
interface Props {
1010
app: App;
11-
pinHandler?: Function;
1211
}
1312

14-
export const AppCard = (props: Props): JSX.Element => {
13+
export const AppCard = ({ app }: Props): JSX.Element => {
1514
const { config } = useSelector((state: State) => state.config);
1615

17-
const [displayUrl, redirectUrl] = urlParser(props.app.url);
16+
const [displayUrl, redirectUrl] = urlParser(app.url);
1817

1918
let iconEl: JSX.Element;
20-
const { icon } = props.app;
19+
const { icon } = app;
2120

2221
if (isImage(icon)) {
2322
const source = isUrl(icon) ? icon : `/uploads/${icon}`;
2423

2524
iconEl = (
2625
<img
2726
src={source}
28-
alt={`${props.app.name} icon`}
27+
alt={`${app.name} icon`}
2928
className={classes.CustomIcon}
3029
/>
3130
);
@@ -54,8 +53,8 @@ export const AppCard = (props: Props): JSX.Element => {
5453
>
5554
<div className={classes.AppCardIcon}>{iconEl}</div>
5655
<div className={classes.AppCardDetails}>
57-
<h5>{props.app.name}</h5>
58-
<span>{displayUrl}</span>
56+
<h5>{app.name}</h5>
57+
<span>{!app.description.length ? displayUrl : app.description}</span>
5958
</div>
6059
</a>
6160
);

client/src/components/Apps/AppForm/AppForm.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export const AppForm = ({ modalHandler }: Props): JSX.Element => {
9696
<ModalForm modalHandler={modalHandler} formHandler={formSubmitHandler}>
9797
{/* NAME */}
9898
<InputGroup>
99-
<label htmlFor="name">App Name</label>
99+
<label htmlFor="name">App name</label>
100100
<input
101101
type="text"
102102
name="name"
@@ -122,11 +122,27 @@ export const AppForm = ({ modalHandler }: Props): JSX.Element => {
122122
/>
123123
</InputGroup>
124124

125+
{/* DESCRIPTION */}
126+
<InputGroup>
127+
<label htmlFor="description">App description</label>
128+
<input
129+
type="text"
130+
name="description"
131+
id="description"
132+
placeholder="My self-hosted app"
133+
value={formData.description}
134+
onChange={(e) => inputChangeHandler(e)}
135+
/>
136+
<span>
137+
Optional - If description is not set, app URL will be displayed
138+
</span>
139+
</InputGroup>
140+
125141
{/* ICON */}
126142
{!useCustomIcon ? (
127143
// use mdi icon
128144
<InputGroup>
129-
<label htmlFor="icon">App Icon</label>
145+
<label htmlFor="icon">App icon</label>
130146
<input
131147
type="text"
132148
name="icon"

client/src/interfaces/App.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface NewApp {
55
url: string;
66
icon: string;
77
isPublic: boolean;
8+
description: string;
89
}
910

1011
export interface App extends Model, NewApp {

client/src/utility/templateObjects/appTemplate.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const newAppTemplate: NewApp = {
55
url: '',
66
icon: '',
77
isPublic: true,
8+
description: '',
89
};
910

1011
export const appTemplate: App = {

db/migrations/05_app-description.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { DataTypes } = require('sequelize');
2+
const { STRING } = DataTypes;
3+
4+
const up = async (query) => {
5+
await query.addColumn('apps', 'description', {
6+
type: STRING,
7+
allowNull: false,
8+
defaultValue: '',
9+
});
10+
};
11+
12+
const down = async (query) => {
13+
await query.removeColumn('apps', 'description');
14+
};
15+
16+
module.exports = {
17+
up,
18+
down,
19+
};

models/App.js

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const App = sequelize.define(
3131
allowNull: true,
3232
defaultValue: 1,
3333
},
34+
description: {
35+
type: DataTypes.STRING,
36+
allowNull: false,
37+
defaultValue: '',
38+
},
3439
},
3540
{
3641
tableName: 'apps',

0 commit comments

Comments
 (0)