Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/timeofday-custom…
Browse files Browse the repository at this point in the history
…-component
  • Loading branch information
fmartingr committed Jun 4, 2024
2 parents b19af3a + 5fcd868 commit fbf7097
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 7 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Although a valid Mattermost Enterprise Edition License is required if using this

If you're running an Enterprise Edition of Mattermost and don't already have a valid license, you can obtain a trial license from **System Console > Edition and License**. If you're running the Team Edition of Mattermost, including when you run the server directly from source, you may instead configure your server to enable both testing (`ServiceSettings.EnableTesting`) and developer mode (`ServiceSettings.EnableDeveloper`). These settings are not recommended in production environments.


## How To Install

Download the latest released version and upload to your Mattermost installation on the plugins page
Expand Down Expand Up @@ -41,8 +40,8 @@ present in your Mattermost server on the first run of the job will be saved (i.e
already been purged by a data retention policy at the time of the first run will not be included
in the legal hold). Once data is held by the Legal Hold, it will not be affected by Data Retention
policy. However, newly created Legal Holds will not be able to access data that was already purged
by Data Retention policy at the time of their first run *even if the data is held in an existing
legal hold*.
by Data Retention policy at the time of their first run _even if the data is held in an existing
legal hold_.

You can edit the name, end data and users in a Legal Hold. Adding new users to a legal hold will only
include their data from the next run of the hold. Similarly, removing a user from the hold will
Expand All @@ -59,3 +58,9 @@ permanently purged from the storage area, and cannot be recovered.

See the `processor` subdirectory for how to turn the downloaded zip file into a human readable HTML
export that you can view and search in a web browser.

## A note on downlading large legal holds

For large legal holds, the download process can take more time than the HTTP request timeout. If you are experiencing timeouts, you can increase the timeout under **System Console** > **Web server** > **Write timeout** or in your `config.json` file. This is a global setting for the entire server.

Keep in mind that the same applies for reverse proxies, which may have their own timeout settings. If you are using a reverse proxy, you may need to adjust the timeout settings there as well.
5 changes: 5 additions & 0 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
"key": "LegalHoldsSettings",
"display_name": "Legal Holds:",
"type": "custom"
},
{
"key": "AmazonS3BucketSettings",
"display_name": "S3 Bucket:",
"type": "custom"
}
]
}
Expand Down
2 changes: 0 additions & 2 deletions server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,6 @@ func (p *Plugin) runJobFromAPI(w http.ResponseWriter, _ *http.Request) {
go p.legalHoldJob.RunFromAPI()
}

// we'll want to store the access secret encrypted in the database

// testAmazonS3Connection tests the plugin's custom Amazon S3 connection
func (p *Plugin) testAmazonS3Connection(w http.ResponseWriter, _ *http.Request) {
type messageResponse struct {
Expand Down
8 changes: 8 additions & 0 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ type Plugin struct {
}

func (p *Plugin) OnActivate() error {
// Check for an enterprise license or a development environment
config := p.API.GetConfig()
license := p.API.GetLicense()

if !pluginapi.IsEnterpriseLicensedOrDevelopment(config, license) {
return fmt.Errorf("this plugin requires an Enterprise license")
}

// Create plugin API client
p.Client = pluginapi.NewClient(p.API, p.Driver)
p.Client.Log.Debug("MM LH Plugin: OnActivate called")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, {useEffect, useRef, useState} from 'react';

import BaseSetting from './base_setting';

type Props = {
id: string;
name: string;
helpText: string;
onChange: (value: string) => void;
value: string;
disabled?: boolean;
};

const SecretTextSetting = (props: Props) => {
const [value, setValue] = useState('');
const mounted = useRef(false);

useEffect(() => {
if (mounted.current) {
setValue(props.value);
return;
}

if (props.value) {
setValue('*'.repeat(32));
}

mounted.current = true;
}, [props.value]);

const handleChange = (newValue: string) => {
setValue(newValue);
};

return (
<BaseSetting
{...props}
>
<input
id={props.id}
className='form-control'
type='text'
value={value}
onChange={(e) => handleChange(e.target.value)}
disabled={props.disabled}
/>
</BaseSetting>
);
};

export default SecretTextSetting;
3 changes: 2 additions & 1 deletion webapp/src/components/amazon_s3_bucket_settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TextSetting from './admin_console_settings/text_setting';
import SaveButton from './mattermost-webapp/save_button';
import BaseSetting from './admin_console_settings/base_setting';
import StatusMessage from './admin_console_settings/status_message';
import SecretTextSetting from './admin_console_settings/secret_text_setting';

type FileSettings = {
DriverName: string;
Expand Down Expand Up @@ -185,7 +186,7 @@ const AmazonS3BucketSettings = (props: Props) => {
onChange={(value) => setFormValue('AmazonS3Endpoint', value)}
disabled={!formState.Enable}
/>
<TextSetting
<SecretTextSetting
id='com.mattermost.plugin-legal-hold.AmazonS3SecretAccessKey'
name='Amazon S3 Secret Access Key'
helpText='The secret access key to access the Amazon S3 bucket.'
Expand Down
1 change: 1 addition & 0 deletions webapp/src/components/legal_holds_setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const LegalHoldsSetting = () => {
background: 'var(--sys-center-channel-bg)',
borderRadius: '4px',
boxShadow: '0 2px 3px rgba(0, 0, 0, 0.08)',
marginBottom: '24px',
}}
>
<div
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {manifest} from '@/manifest';
import {PluginRegistry} from '@/types/mattermost-webapp';
import LegalHoldsSetting from '@/components/legal_holds_setting';
import AmazonS3BucketSettings from '@/components/amazon_s3_bucket_settings';
import CommonSettings from './components/common_settings';
import CommonSettings from '@/components/common_settings';

export default class Plugin {
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
Expand Down

0 comments on commit fbf7097

Please sign in to comment.