mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) updates from grist-core
This commit is contained in:
@@ -237,8 +237,8 @@ Please log in as an administrator.`)),
|
||||
|
||||
private _buildAuthenticationNotice(owner: IDisposableOwner) {
|
||||
return t('Grist allows different types of authentication to be configured, including SAML and OIDC. \
|
||||
We recommend enabling one of these if Grist is accessible over the network or being made available \
|
||||
to multiple people.');
|
||||
We recommend enabling one of these if Grist is accessible over the network or being made available \
|
||||
to multiple people.');
|
||||
}
|
||||
|
||||
private _buildUpdates(owner: MultiHolder) {
|
||||
|
||||
@@ -118,7 +118,7 @@ export class AppHeader extends Disposable {
|
||||
// Show 'Organization Settings' when on a home page of a valid org.
|
||||
(!this._docPageModel && this._currentOrg && !this._currentOrg.owner ?
|
||||
menuItem(() => manageTeamUsersApp({app: this._appModel}),
|
||||
'Manage Team', testId('orgmenu-manage-team'),
|
||||
t('Manage Team'), testId('orgmenu-manage-team'),
|
||||
dom.cls('disabled', !roles.canEditAccess(this._currentOrg.access))) :
|
||||
// Don't show on doc pages, or for personal orgs.
|
||||
null),
|
||||
@@ -153,12 +153,12 @@ export class AppHeader extends Disposable {
|
||||
(isBillingManager
|
||||
? menuItemLink(
|
||||
urlState().setLinkUrl({billing: 'billing'}),
|
||||
'Billing Account',
|
||||
t('Billing Account'),
|
||||
testId('orgmenu-billing'),
|
||||
)
|
||||
: menuItem(
|
||||
() => null,
|
||||
'Billing Account',
|
||||
t('Billing Account'),
|
||||
dom.cls('disabled', true),
|
||||
testId('orgmenu-billing'),
|
||||
)
|
||||
|
||||
@@ -5,20 +5,39 @@ import {IncomingMessage} from 'http';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as minio from 'minio';
|
||||
|
||||
// The minio typings appear to be quite stale. Extend them here to avoid
|
||||
// lots of casts to any.
|
||||
type MinIOClient = minio.Client & {
|
||||
statObject(bucket: string, key: string, options: {versionId?: string}): Promise<MinIOBucketItemStat>;
|
||||
getObject(bucket: string, key: string, options: {versionId?: string}): Promise<IncomingMessage>;
|
||||
listObjects(bucket: string, key: string, recursive: boolean,
|
||||
options: {IncludeVersion?: boolean}): minio.BucketStream<minio.BucketItem>;
|
||||
removeObjects(bucket: string, versions: Array<{name: string, versionId: string}>): Promise<void>;
|
||||
};
|
||||
// The minio-js v8.0.0 typings are sometimes incorrect. Here are some workarounds.
|
||||
interface MinIOClient extends
|
||||
// Some of them are not directly extendable, must be omitted first and then redefined.
|
||||
Omit<minio.Client, "listObjects" | "getBucketVersioning" | "removeObjects">
|
||||
{
|
||||
// The official typing returns `Promise<Readable>`, dropping some useful metadata.
|
||||
getObject(bucket: string, key: string, options: {versionId?: string}): Promise<IncomingMessage>;
|
||||
// The official typing dropped "options" in their .d.ts file, but it is present in the underlying impl.
|
||||
listObjects(bucket: string, key: string, recursive: boolean,
|
||||
options: {IncludeVersion?: boolean}): minio.BucketStream<minio.BucketItem>;
|
||||
// The released v8.0.0 wrongly returns `Promise<void>`; borrowed from PR #1297
|
||||
getBucketVersioning(bucketName: string): Promise<MinIOVersioningStatus>;
|
||||
// The released v8.0.0 typing is outdated; copied over from commit 8633968.
|
||||
removeObjects(bucketName: string, objectsList: RemoveObjectsParam): Promise<RemoveObjectsResponse[]>
|
||||
}
|
||||
|
||||
type MinIOBucketItemStat = minio.BucketItemStat & {
|
||||
versionId?: string;
|
||||
metaData?: Record<string, string>;
|
||||
};
|
||||
type MinIOVersioningStatus = "" | {
|
||||
Status: "Enabled" | "Suspended",
|
||||
MFADelete?: string,
|
||||
ExcludeFolders?: boolean,
|
||||
ExcludedPrefixes?: {Prefix: string}[]
|
||||
}
|
||||
|
||||
type RemoveObjectsParam = string[] | { name: string, versionId?: string }[]
|
||||
|
||||
type RemoveObjectsResponse = null | undefined | {
|
||||
Error?: {
|
||||
Code?: string
|
||||
Message?: string
|
||||
Key?: string
|
||||
VersionId?: string
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An external store implemented using the MinIO client, which
|
||||
@@ -38,7 +57,7 @@ export class MinIOExternalStorage implements ExternalStorage {
|
||||
region: string
|
||||
},
|
||||
private _batchSize?: number,
|
||||
private _s3 = new minio.Client(options) as MinIOClient
|
||||
private _s3 = new minio.Client(options) as unknown as MinIOClient
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -70,7 +89,7 @@ export class MinIOExternalStorage implements ExternalStorage {
|
||||
public async upload(key: string, fname: string, metadata?: ObjMetadata) {
|
||||
const stream = fse.createReadStream(fname);
|
||||
const result = await this._s3.putObject(
|
||||
this.bucket, key, stream,
|
||||
this.bucket, key, stream, undefined,
|
||||
metadata ? {Metadata: toExternalMetadata(metadata)} : undefined
|
||||
);
|
||||
// Empirically VersionId is available in result for buckets with versioning enabled.
|
||||
@@ -111,7 +130,9 @@ export class MinIOExternalStorage implements ExternalStorage {
|
||||
|
||||
public async hasVersioning(): Promise<Boolean> {
|
||||
const versioning = await this._s3.getBucketVersioning(this.bucket);
|
||||
return versioning && versioning.Status === 'Enabled';
|
||||
// getBucketVersioning() may return an empty string when versioning has never been enabled.
|
||||
// This situation is not addressed in minio-js v8.0.0, but included in our workaround.
|
||||
return versioning !== '' && versioning?.Status === 'Enabled';
|
||||
}
|
||||
|
||||
public async versions(key: string, options?: { includeDeleteMarkers?: boolean }) {
|
||||
|
||||
Reference in New Issue
Block a user