WIP: build mattermost web app from source and remove spam properly #53

Draft
fsagbuya wants to merge 3 commits from fsagbuya/it-infra:mattermost-webapp into master
4 changed files with 23818 additions and 0 deletions

View File

@ -915,6 +915,7 @@ in
services.mattermost = {
enable = true;
package = pkgs.callPackage ./mattermost {};
siteUrl = "https://chat.m-labs.hk/";
mutableConfig = true;
};

View File

@ -0,0 +1,126 @@
{ lib
, buildGoModule
, fetchFromGitHub
, buildNpmPackage
, nix-update-script
, fetchurl
, nixosTests
}:
buildGoModule rec {
pname = "mattermost";
# ESR releases only.
# See https://docs.mattermost.com/upgrade/extended-support-release.html
# When a new ESR version is available (e.g. 8.1.x -> 9.5.x), update
# the version regex in passthru.updateScript as well.
version = "9.11.5";
src = fetchFromGitHub {
owner = "mattermost";
repo = "mattermost";
rev = "v${version}";
hash = "sha256-bLZFeG6kBVP0ws50wtBam/bO206sQnz6va8PATAoRAQ=";
};
# Needed because buildGoModule does not support go workspaces yet.
# We use go 1.22's workspace vendor command, which is not yet available
# in the default version of go used in nixpkgs, nor is it used by upstream:
# https://github.com/mattermost/mattermost/issues/26221#issuecomment-1945351597
overrideModAttrs = (_: {
buildPhase = ''
make setup-go-work
go work vendor -e
'';
});
webapp = buildNpmPackage {
pname = "mattermost-webapp";
inherit version src;
sourceRoot = "${src.name}/webapp";
patches = [
./fix-package-lock-json.patch
./remove-free-edition-banner.patch
];
makeCacheWritable = true;
forceGitDeps = true;
npmRebuildFlags = [ "--ignore-scripts" ];
npmDepsHash = "sha256-KtfzXvrQs9xs09TM1UicStI8ALt3JQXhzJ2qYrbxWHc=";
buildPhase = ''
runHook preBuild
npm run build --workspace=platform/types
npm run build --workspace=platform/client
npm run build --workspace=platform/components
npm run build --workspace=channels
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r channels/dist/* $out
runHook postInstall
'';
};
# # Makes nix-update-script pick up the fetchurl for the webapp.
# # https://github.com/Mic92/nix-update/blob/1.3.1/nix_update/eval.py#L179
# offlineCache = webapp;
vendorHash = "sha256-Gwv6clnq7ihoFC8ox8iEM5xp/us9jWUrcmqA9/XbxBE=";
modRoot = "./server";
preBuild = ''
make setup-go-work
'';
subPackages = [ "cmd/mattermost" ];
tags = [ "production" ];
ldflags = [
"-s"
"-w"
"-X github.com/mattermost/mattermost/server/public/model.Version=${version}"
"-X github.com/mattermost/mattermost/server/public/model.BuildNumber=${version}-nixpkgs"
"-X github.com/mattermost/mattermost/server/public/model.BuildDate=1970-01-01"
"-X github.com/mattermost/mattermost/server/public/model.BuildHash=v${version}"
"-X github.com/mattermost/mattermost/server/public/model.BuildHashEnterprise=none"
"-X github.com/mattermost/mattermost/server/public/model.BuildEnterpriseReady=false"
];
postInstall = ''
mkdir -p $out/{client,i18n,fonts,templates}
cp -r ${webapp}/* $out/client/
cp -r ${src}/server/fonts/* $out/fonts/
cp -r ${src}/server/templates/* $out/templates/
cp -r ${src}/server/i18n/* $out/i18n/
# For some reason a bunch of these files are executable
find $out/{client,i18n,fonts,templates} -type f -exec chmod -x {} \;
sed -i.bak "s/FREE EDITION//g" $out/client/*.js $out/client/*.js.map
'';
passthru = {
updateScript = nix-update-script {
extraArgs = [ "--version-regex" "^v(9\.11\.[0-9]+)$" ];
};
tests.mattermost = nixosTests.mattermost;
};
meta = with lib; {
description = "Mattermost is an open source platform for secure collaboration across the entire software development lifecycle";
homepage = "https://www.mattermost.org";
license = with licenses; [ agpl3Only asl20 ];
maintainers = with maintainers; [ ryantm numinit kranzes mgdelacroix ];
mainProgram = "mattermost";
};
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,163 @@
diff --git webapp/channels/src/components/global_header/left_controls/product_menu/product_branding_team_edition/product_branding_team_edition.tsx webapp/channels/src/components/global_header/left_controls/product_menu/product_branding_team_edition/product_branding_team_edition.tsx
index 9af4fc7354..60ae3160e8 100644
--- webapp/channels/src/components/global_header/left_controls/product_menu/product_branding_team_edition/product_branding_team_edition.tsx
+++ webapp/channels/src/components/global_header/left_controls/product_menu/product_branding_team_edition/product_branding_team_edition.tsx
@@ -9,10 +9,6 @@ import Logo from 'components/common/svg_images_components/logo_dark_blue_svg';
const ProductBrandingTeamEditionContainer = styled.div`
display: flex;
align-items: center;
-
- > * + * {
- margin-left: 8px;
- }
`;
const StyledLogo = styled(Logo)`
@@ -21,23 +17,6 @@ const StyledLogo = styled(Logo)`
}
`;
-const Badge = styled.div`
- display: flex;
- align-self: center;
- padding: 2px 6px;
- position: relative;
- top: 1px;
- border-radius: var(--radius-s);
- margin-left: 12px;
- background: rgba(var(--sidebar-text-rgb), 0.08);
- color: rgba(var(--sidebar-text-rgb), 0.75);
- font-family: 'Open Sans', sans-serif;
- font-size: 10px;
- font-weight: 600;
- letter-spacing: 0.025em;
- line-height: 16px;
-`;
-
const ProductBrandingTeamEdition = (): JSX.Element => {
return (
<ProductBrandingTeamEditionContainer tabIndex={0}>
@@ -45,7 +24,6 @@ const ProductBrandingTeamEdition = (): JSX.Element => {
width={116}
height={20}
/>
- <Badge>{'FREE EDITION'}</Badge>
</ProductBrandingTeamEditionContainer>
);
};
diff --git webapp/channels/src/components/header_footer_route/header.scss webapp/channels/src/components/header_footer_route/header.scss
index e7c76f9861..2841858f44 100644
--- webapp/channels/src/components/header_footer_route/header.scss
+++ webapp/channels/src/components/header_footer_route/header.scss
@@ -39,23 +39,6 @@
width: 170px;
fill: var(--center-channel-color);
}
-
- .freeBadge {
- position: relative;
- top: 1px;
- display: flex;
- align-self: center;
- padding: 2px 6px;
- border-radius: var(--radius-s);
- margin-left: 12px;
- background: rgba(var(--center-channel-color-rgb), 0.08);
- color: rgba(var(--center-channel-color-rgb), 0.75);
- font-family: 'Open Sans', sans-serif;
- font-size: 10px;
- font-weight: 600;
- letter-spacing: 0.025em;
- line-height: 16px;
- }
}
}
@@ -77,12 +60,6 @@
margin-top: 12px;
}
}
-
- &.has-free-banner.has-custom-site-name {
- .header-back-button {
- bottom: -20px;
- }
- }
}
@media screen and (max-width: 699px) {
diff --git webapp/channels/src/components/header_footer_route/header.tsx webapp/channels/src/components/header_footer_route/header.tsx
index 8cd1d8a624..55554fb0ad 100644
--- webapp/channels/src/components/header_footer_route/header.tsx
+++ webapp/channels/src/components/header_footer_route/header.tsx
@@ -25,33 +25,15 @@ const Header = ({alternateLink, backButtonURL, onBackButtonClick}: HeaderProps)
const ariaLabel = SiteName || 'Mattermost';
- let freeBanner = null;
- if (license.IsLicensed === 'false') {
- freeBanner = <><Logo/><span className='freeBadge'>{'FREE EDITION'}</span></>;
- }
-
let title: React.ReactNode = SiteName;
if (title === 'Mattermost') {
- if (freeBanner) {
- title = '';
- } else {
- title = <Logo/>;
- }
+ title = <Logo/>;
}
return (
- <div className={classNames('hfroute-header', {'has-free-banner': freeBanner, 'has-custom-site-name': title})}>
+ <div className={classNames('hfroute-header', {'has-custom-site-name': title})}>
<div className='header-main'>
<div>
- {freeBanner &&
- <Link
- className='header-logo-link'
- to='/'
- aria-label={ariaLabel}
- >
- {freeBanner}
- </Link>
- }
{title &&
<Link
className='header-logo-link'
diff --git webapp/channels/src/components/widgets/menu/menu_items/menu_start_trial.tsx webapp/channels/src/components/widgets/menu/menu_items/menu_start_trial.tsx
index 35646539c4..c1d1713948 100644
--- webapp/channels/src/components/widgets/menu/menu_items/menu_start_trial.tsx
+++ webapp/channels/src/components/widgets/menu/menu_items/menu_start_trial.tsx
@@ -14,22 +14,6 @@ import {LicenseLinks} from 'utils/constants';
import './menu_item.scss';
-const FreeVersionBadge = styled.div`
- position: relative;
- top: 1px;
- display: flex;
- padding: 2px 6px;
- border-radius: var(--radius-s);
- margin-bottom: 6px;
- background: rgba(var(--center-channel-color-rgb), 0.08);
- color: rgba(var(--center-channel-color-rgb), 0.75);
- font-family: 'Open Sans', sans-serif;
- font-size: 10px;
- font-weight: 600;
- letter-spacing: 0.025em;
- line-height: 16px;
-`;
-
type Props = {
id: string;
}
@@ -50,7 +34,6 @@ const MenuStartTrial = (props: Props): JSX.Element | null => {
role='menuitem'
id={props.id}
>
- <FreeVersionBadge>{'FREE EDITION'}</FreeVersionBadge>
<div className='editionText'>
{formatMessage(
{