Create name/title Widget utils

This commit is contained in:
Michael Telatynski 2020-08-28 10:50:27 +01:00
parent 11e349d6c8
commit 2527344294
4 changed files with 14 additions and 2 deletions

View file

@ -76,7 +76,7 @@ export default class PersistentApp extends React.Component {
userId={MatrixClientPeg.get().credentials.userId} userId={MatrixClientPeg.get().credentials.userId}
show={true} show={true}
creatorUserId={app.creatorUserId} creatorUserId={app.creatorUserId}
widgetPageTitle={(app.data && app.data.title) ? app.data.title : ''} widgetPageTitle={WidgetUtils.getWidgetDataTitle(app)}
waitForIframeLoad={app.waitForIframeLoad} waitForIframeLoad={app.waitForIframeLoad}
whitelistCapabilities={capWhitelist} whitelistCapabilities={capWhitelist}
showDelete={false} showDelete={false}

View file

@ -171,7 +171,7 @@ export default class AppsDrawer extends React.Component {
userId={this.props.userId} userId={this.props.userId}
show={this.props.showApps} show={this.props.showApps}
creatorUserId={app.creatorUserId} creatorUserId={app.creatorUserId}
widgetPageTitle={(app.data && app.data.title) ? app.data.title : ''} widgetPageTitle={WidgetUtils.getWidgetDataTitle(app)}
waitForIframeLoad={app.waitForIframeLoad} waitForIframeLoad={app.waitForIframeLoad}
whitelistCapabilities={capWhitelist} whitelistCapabilities={capWhitelist}
/>); />);

View file

@ -387,6 +387,7 @@
"Common names and surnames are easy to guess": "Common names and surnames are easy to guess", "Common names and surnames are easy to guess": "Common names and surnames are easy to guess",
"Straight rows of keys are easy to guess": "Straight rows of keys are easy to guess", "Straight rows of keys are easy to guess": "Straight rows of keys are easy to guess",
"Short keyboard patterns are easy to guess": "Short keyboard patterns are easy to guess", "Short keyboard patterns are easy to guess": "Short keyboard patterns are easy to guess",
"Unknown App": "Unknown App",
"Help us improve %(brand)s": "Help us improve %(brand)s", "Help us improve %(brand)s": "Help us improve %(brand)s",
"Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. This will use a <PolicyLink>cookie</PolicyLink>.": "Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. This will use a <PolicyLink>cookie</PolicyLink>.", "Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. This will use a <PolicyLink>cookie</PolicyLink>.": "Send <UsageDataLink>anonymous usage data</UsageDataLink> which helps us improve %(brand)s. This will use a <PolicyLink>cookie</PolicyLink>.",
"I want to help": "I want to help", "I want to help": "I want to help",

View file

@ -32,6 +32,7 @@ import {Capability} from "../widgets/WidgetApi";
import {Room} from "matrix-js-sdk/src/models/room"; import {Room} from "matrix-js-sdk/src/models/room";
import {WidgetType} from "../widgets/WidgetType"; import {WidgetType} from "../widgets/WidgetType";
import {objectClone} from "./objects"; import {objectClone} from "./objects";
import {_t} from "../languageHandler";
export default class WidgetUtils { export default class WidgetUtils {
/* Returns true if user is able to send state events to modify widgets in this room /* Returns true if user is able to send state events to modify widgets in this room
@ -486,4 +487,14 @@ export default class WidgetUtils {
IntegrationManagers.sharedInstance().getPrimaryManager().open(room, 'type_' + app.type, app.id); IntegrationManagers.sharedInstance().getPrimaryManager().open(room, 'type_' + app.type, app.id);
} }
} }
static getWidgetName(app) {
if (!app || !app.name) return "";
return app.name.trim() || _t("Unknown App");
}
static getWidgetDataTitle(app) {
if (!app || !app.data || !app.data.title) return "";
return app.data.title.trim();
}
} }