Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eik/hide labs and sharedinvites #86

Merged
merged 20 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ test/end-to-end-tests/synapse/
test/end-to-end-tests/lib/
# Legacy skinning file that some people might still have
src/component-index.js
src/components/structures/scripts/freshworks.js
4 changes: 4 additions & 0 deletions res/css/structures/_RightPanel.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ limitations under the License.
mask-image: url("$(res)/img/element-icons/room/room-summary.svg");
mask-position: center;
}
.mx_RightPanel_supportButton::before {
mask-image: url("$(res)/img/element-icons/settings/help.svg");
mask-position: center;
}

.mx_RightPanel_pinnedMessagesButton {
&::before {
Expand Down
26 changes: 26 additions & 0 deletions src/components/structures/scripts/freshworks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function toggleWidget() {
var iframe = document.getElementById("widget-frame");
if (iframe) {
FreshworksWidget("close");
} else {
FreshworksWidget("open");
}
}
function init() {
window.fwSettings = {
widget_id: 80000004505,
locale: "nb-NO",
};

!(function () {
if ("function" != typeof window.FreshworksWidget) {
var n = function () {
n.q.push(arguments);
};
(n.q = []), (window.FreshworksWidget = n);
}
})();
FreshworksWidget("hide", "launcher");
}
init();
export default toggleWidget;
61 changes: 36 additions & 25 deletions src/components/views/dialogs/BugReportDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import DialogButtons from "../elements/DialogButtons";
import { sendSentryReport } from "../../../sentry";
import defaultDispatcher from "../../../dispatcher/dispatcher";
import { Action } from "../../../dispatcher/actions";
import SettingsStore from "../../../settings/SettingsStore";
import { UIFeature } from "../../../settings/UIFeature";

interface IProps {
onFinished: (success: boolean) => void;
Expand Down Expand Up @@ -226,21 +228,22 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
<p>{_t("bug_reporting|description")}</p>
<p>
<b>
{_t(
"bug_reporting|before_submitting",
{},
{
a: (sub) => (
<a
target="_blank"
href={SdkConfig.get().feedback.new_issue_url}
rel="noreferrer noopener"
>
{sub}
</a>
),
},
)}
{SettingsStore.getValue(UIFeature.HelpShowMatrixDisclosurePolicyAndLinks) &&
_t(
"bug_reporting|before_submitting",
{},
{
a: (sub) => (
<a
target="_blank"
href={SdkConfig.get().feedback.new_issue_url}
rel="noreferrer noopener"
>
{sub}
</a>
),
},
)}
</b>
</p>

Expand All @@ -250,16 +253,24 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
</AccessibleButton>
{this.state.downloadProgress && <span>{this.state.downloadProgress} ...</span>}
</div>

<Field
type="text"
className="mx_BugReportDialog_field_input"
label={_t("bug_reporting|github_issue")}
onChange={this.onIssueUrlChange}
value={this.state.issueUrl}
placeholder="https://github.com/vector-im/element-web/issues/..."
ref={this.issueRef}
/>
{console.log(
"Eik bugrep: HelpShowMatrixDisclosurePolicyAndLinks " +
SettingsStore.getValue(UIFeature.HelpShowMatrixDisclosurePolicyAndLinks),
)}

{SettingsStore.getValue(UIFeature.HelpShowMatrixDisclosurePolicyAndLinks) && (
<>
<Field
type="text"
className="mx_BugReportDialog_field_input"
label={_t("bug_reporting|github_issue")}
onChange={this.onIssueUrlChange}
value={this.state.issueUrl}
placeholder="https://github.com/vector-im/element-web/issues/..."
ref={this.issueRef}
/>
</>
)}
<Field
className="mx_BugReportDialog_field_input"
element="textarea"
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/InviteDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
<div className="error">{this.state.errorText}</div>
{onlyOneThreepidNote}
{results}
{footer}
{SettingsStore.getValue(UIFeature.SendInviteLinkPrompt) && footer}
</React.Fragment>
);

Expand Down
54 changes: 54 additions & 0 deletions src/components/views/misc_header/MiscButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright ROSBERG / VerjiTech
*/

import React from "react";
import classNames from "classnames";

// import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
import AccessibleButton from "../elements/AccessibleButton";

interface IProps {
// Whether this button is highlighted
isHighlighted: boolean;
// click handler
onClick: () => void;
// The badge to display above the icon
badge?: React.ReactNode;

// Button name
name: string;
// Button title
title: string;
}

// TODO: replace this, the composer buttons and the right panel buttons with a unified
// representation
export default class MiscButton extends React.Component<IProps> {
public constructor(props: IProps) {
super(props);
this.onClick = this.onClick.bind(this);
}

private onClick(): void {
this.props.onClick();
}

public render(): React.ReactElement {
const classes = classNames({
mx_LegacyRoomHeader_button: true,
mx_RightPanel_supportButton_highlight: this.props.isHighlighted,
[`${this.props.name}`]: true,
});

return (
<AccessibleButton
aria-current={this.props.isHighlighted}
role="button"
title={this.props.title}
className={classes}
onClick={this.onClick}
/>
);
}
}
73 changes: 73 additions & 0 deletions src/components/views/misc_header/MiscHeaderButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
Copyright VerjiTech
*/

import React from "react";

import { _t } from "../../../languageHandler";
import MiscButton from "./MiscButton";
import { ActionPayload } from "../../../dispatcher/payloads";
// @ts-ignore
import toggleWidget from "../../structures/scripts/freshworks.js";

// Currently only misc, but should be defined if misc buttons will later be used together with other header kinds.
export enum HeaderKind {
Misc = "misc",
}

interface IProps {}
interface IState {
headerKind: HeaderKind;
}

abstract class Buttons extends React.Component<IProps, IState> {
public constructor(props: IProps, kind: HeaderKind) {
super(props);

this.state = {
headerKind: kind,
};
}

protected abstract onAction(payload: ActionPayload): void;
public abstract renderButtons(): JSX.Element[];

public render(): React.ReactElement {
return <div className="mx_MiscHeaderButtons">{this.renderButtons()}</div>;
// return <div>
// {this.renderButtons()}
// </div>;
}
}

export default class MiscHeaderButtons extends Buttons {
public constructor(props: IProps) {
super(props, HeaderKind.Misc);
}

protected onAction(payload: ActionPayload): void {}
public renderButtons(): React.ReactElement[] {
return [
<MiscButton
key="roomSupportButton"
// name="roomSupportButton"
// name="mx_UserSettingsDialog_helpIcon"
name="mx_RightPanel_supportButton"
isHighlighted={false}
title={_t("common|support")}
onClick={() => supportRedirect()}
// analytics={['Misc Header Button', 'Support Button', 'click']}
/>,
];
}
}

const supportRedirect = (): void => {
/* REDIRECT TO SUPPORT PAGE
const newWindow = window.open("https://rosberg.no/hjelp", '_blank', 'noopener,noreferrer')
if (newWindow)
newWindow.opener = null
*/

toggleWidget();
};
16 changes: 16 additions & 0 deletions src/components/views/right_panel/LegacyRoomHeaderButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import { SummarizedNotificationState } from "../../../stores/notifications/Summa
import PosthogTrackers from "../../../PosthogTrackers";
import { ButtonEvent } from "../elements/AccessibleButton";
import { doesRoomOrThreadHaveUnreadMessages } from "../../../Unread";
// @ts-ignore
import toggleWidget from "../../structures/scripts/freshworks.js";

const ROOM_INFO_PHASES = [
RightPanelPhases.RoomSummary,
Expand Down Expand Up @@ -223,6 +225,9 @@ export default class LegacyRoomHeaderButtons extends HeaderButtons<IProps> {
RightPanelStore.instance.showOrHidePanel(RightPanelPhases.RoomSummary);
}
};
private onSupportClicked = (): void => {
toggleWidget();
};

private onNotificationsClicked = (): void => {
// This toggles for us, if needed
Expand Down Expand Up @@ -314,6 +319,17 @@ export default class LegacyRoomHeaderButtons extends HeaderButtons<IProps> {
onClick={this.onRoomSummaryClicked}
/>,
);
rightPanelPhaseButtons.set(
RightPanelPhases.Support,
<HeaderButton
key="supportButton"
name="supportButton"
title={_t("common|support")}
isHighlighted={this.isPhase(ROOM_INFO_PHASES)}
onClick={this.onSupportClicked}
// onClick={() => toggleWidget()}
/>,
);

return (
<>
Expand Down
8 changes: 8 additions & 0 deletions src/components/views/rooms/EntityTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,19 @@ import { ModuleRunner } from "../../../modules/ModuleRunner";
export enum PowerStatus {
Admin = "admin",
Moderator = "moderator",
CustomerAdmin = "customer",
RosbergAdmin = "rosberg",
SystemAdmin = "system",
Standard = "standard",
}

const PowerLabel: Record<PowerStatus, TranslationKey> = {
[PowerStatus.Admin]: _td("power_level|admin"),
[PowerStatus.Moderator]: _td("power_level|mod"),
[PowerStatus.CustomerAdmin]: _td("verji|power_levels|customer_admin"),
[PowerStatus.RosbergAdmin]: _td("verji|power_levels|rosberg_admin"),
[PowerStatus.SystemAdmin]: _td("verji|power_levels|system_admin"),
[PowerStatus.Standard]: _td("verji|power_levels|standard"),
};

export type PresenceState = "offline" | "online" | "unavailable" | "io.element.unreachable";
Expand Down
16 changes: 14 additions & 2 deletions src/components/views/rooms/LegacyRoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ import RoomCallBanner from "../beacon/RoomCallBanner";
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
import { UIComponent } from "../../../settings/UIFeature";
import { ModuleRunner } from "../../../modules/ModuleRunner";
import DMRoomMap from "../../../utils/DMRoomMap";
import MiscHeaderButtons from "../misc_header/MiscHeaderButtons";

class DisabledWithReason {
public constructor(public readonly reason: string) {}
Expand Down Expand Up @@ -593,13 +595,22 @@ export default class RoomHeader extends React.Component<IProps, IState> {
private renderButtons(isVideoRoom: boolean): React.ReactNode {
const startButtons: JSX.Element[] = [];

// Verji start
const isDm = this.props.room
? DMRoomMap.shared().getUserIdForRoomId(this.props.room.roomId) &&
this.props.room.getJoinedMembers().length === 2
: null;

// const isDm = true; //for test

if (!this.props.viewingCall && this.props.inRoom && !this.context.tombstone) {
startButtons.push(<CallButtons key="calls" room={this.props.room} />);
if (isDm) startButtons.push(<CallButtons key="calls" room={this.props.room} />);
}

if (this.props.viewingCall && this.props.activeCall instanceof ElementCall) {
startButtons.push(<CallLayoutSelector key="layout" call={this.props.activeCall} />);
if (isDm) startButtons.push(<CallLayoutSelector key="layout" call={this.props.activeCall} />);
}
// Verji end

if (!this.props.viewingCall && this.props.onForgetClick) {
startButtons.push(
Expand Down Expand Up @@ -868,6 +879,7 @@ export default class RoomHeader extends React.Component<IProps, IState> {
{topicElement}
{betaPill}
{buttons}
<MiscHeaderButtons />
</div>
{!isVideoRoom && <RoomCallBanner roomId={this.props.room.roomId} />}
<RoomLiveShareWarning roomId={this.props.room.roomId} />
Expand Down
6 changes: 5 additions & 1 deletion src/components/views/rooms/MemberTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ export default class MemberTile extends React.Component<IProps, IState> {
this.memberLastModifiedTime = member.getLastModifiedTime();

const powerStatusMap = new Map([
[100, PowerStatus.Admin],
[100, PowerStatus.SystemAdmin],
[95, PowerStatus.RosbergAdmin],
[90, PowerStatus.CustomerAdmin],
[80, PowerStatus.Admin],
[50, PowerStatus.Moderator],
[0, PowerStatus.Standard],
]);

// Find the nearest power level with a badge
Expand Down
14 changes: 14 additions & 0 deletions src/components/views/settings/tabs/room/RolesRoomSettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,20 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
}

const eventPowerSelectors = Object.keys(eventsLevels)
//Verji start
.filter((eventType) => {
const rosbergHidden = [
"im.vector.modular.widgets",
"m.room.tombstone",
"m.room.third_party_invite",
"m.room.server_acl",
"m.room.history_visibility",
"m.room.canonical_alias",
"m.room.redaction",
];
return rosbergHidden.indexOf(eventType) === -1;
}) // Verji end

.map((eventType, i) => {
if (isSpaceRoom && plEventsToShow[eventType]?.hideForSpace) {
return null;
Expand Down
Loading