Files
WPS3Media/ui/pro/LicencePage.svelte
Malin 3248cbb029 feat: add S3-compatible storage provider (MinIO, Ceph, R2, etc.)
Adds a new 'S3-Compatible Storage' provider that works with any
S3-API-compatible object storage service, including MinIO, Ceph,
Cloudflare R2, Backblaze B2, and others.

Changes:
- New provider class: classes/providers/storage/s3-compatible-provider.php
  - Provider key: s3compatible
  - Reads user-configured endpoint URL from settings
  - Uses path-style URL access (required by most S3-compatible services)
  - Supports credentials via AS3CF_S3COMPAT_ACCESS_KEY_ID /
    AS3CF_S3COMPAT_SECRET_ACCESS_KEY wp-config.php constants
  - Disables AWS-specific features (Block Public Access, Object Ownership)
- New provider SVG icons (s3compatible.svg, -link.svg, -round.svg)
- Registered provider in main plugin class with endpoint setting support
- Updated StorageProviderSubPage to show endpoint URL input for S3-compatible
- Built pro settings bundle with rollup (Svelte 4.2.19)
- Added package.json and updated rollup.config.mjs for pro-only builds
2026-03-03 12:30:18 +01:00

104 lines
2.6 KiB
Svelte

<script>
import {createEventDispatcher} from "svelte";
import {api, config, settings, strings} from "../js/stores";
import {autofocus} from "../js/autofocus";
import {licence} from "./stores";
import Page from "../components/Page.svelte";
import Notifications from "../components/Notifications.svelte";
import Button from "../components/Button.svelte";
import DefinedInWPConfig from "../components/DefinedInWPConfig.svelte";
const dispatch = createEventDispatcher();
export let name = "licence";
let value = "";
/**
* Handles an "Activate License" button click.
*
* @param {Object} event
*
* @return {Promise<void>}
*/
async function handleActivateLicence( event ) {
const result = await api.post( "licences", { licence: value } );
await updateLicenceInfo( result )
}
/**
* Handles a "Remove License" button click.
*
* @param {Object} event
*
* @return {Promise<void>}
*/
async function handleRemoveLicence( event ) {
value = "";
const result = await api.delete( "licences" );
await updateLicenceInfo( result )
}
/**
* Update licence store with results of API call.
*
* @param {Object} response
*
* @return {Promise<void>}
*/
async function updateLicenceInfo( response ) {
if ( response.hasOwnProperty( "licences" ) ) {
config.update( currentConfig => {
return {
...currentConfig,
licences: response.licences
};
} );
}
// Regardless of what just happened, make sure our settings are in sync (includes reference to license).
await settings.fetch();
}
</script>
<Page {name} on:routeEvent>
<Notifications tab={name}/>
<h2 class="page-title">{$strings.licence_title}</h2>
<div class="licence-page wrapper" class:defined={$licence.is_set && $licence.is_defined}>
{#if $licence.is_set}
<label for="licence-key" class="screen-reader-text">{$strings.licence_title}</label>
<input
id="licence-key"
type="text"
class="licence-field disabled"
name="licence"
value={$licence.masked_licence}
disabled
>
{#if $licence.is_defined}
<DefinedInWPConfig defined/>
{:else}
<Button large outline on:click={handleRemoveLicence}>{$strings.remove_licence}</Button>
{/if}
{:else}
<label for="enter-licence-key" class="screen-reader-text">{$strings.enter_licence_key}</label>
<input
id="enter-licence-key"
type="text"
class="licence-field"
name="licence"
minlength="4"
placeholder={$strings.enter_licence_key}
bind:value
use:autofocus
>
<Button large primary on:click={handleActivateLicence} disabled={value.length === 0}>
{$strings.activate_licence}
</Button>
{/if}
</div>
</Page>