mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Simple implementation of feature flags
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { env } from '$env/dynamic/public';
|
||||
|
||||
export const PUBLIC_CONSOLE_FEATURE_FLAGS = env.PUBLIC_CONSOLE_FEATURE_FLAGS ?? '';
|
||||
|
||||
function setupFlag(name: string, _description: string) {
|
||||
// TODO: Use flags library that provides visual component
|
||||
return PUBLIC_CONSOLE_FEATURE_FLAGS.includes(name);
|
||||
}
|
||||
|
||||
export const flags = {
|
||||
showSites: setupFlag('sites', 'When disabled, sites view will show high demand'),
|
||||
showCsvImport: setupFlag('csv-import', 'When disabled, documents view will hide import button')
|
||||
};
|
||||
+2
-11
@@ -24,8 +24,7 @@
|
||||
import { base } from '$app/paths';
|
||||
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { APPWRITE_OFFICIALS_ORG, isCloud } from '$lib/system';
|
||||
import { flags } from '$lib/flags';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -88,14 +87,6 @@
|
||||
$isCsvImportInProgress = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls visibility of CSV Imports feature:
|
||||
* - Shown if running on self-hosted
|
||||
* - Shown on cloud only if the organization is Appwrite's.
|
||||
* - Hidden on cloud for any non-Appwrite organization.
|
||||
*/
|
||||
$: showCsvImports = !isCloud || $organization.$id === APPWRITE_OFFICIALS_ORG;
|
||||
</script>
|
||||
|
||||
{#key page.params.collection}
|
||||
@@ -109,7 +100,7 @@
|
||||
analyticsSource="database_documents" />
|
||||
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
|
||||
<ViewSelector view={data.view} {columns} hideView />
|
||||
{#if showCsvImports}
|
||||
{#if flags.showCsvImport}
|
||||
<Button
|
||||
secondary
|
||||
event={Click.DatabaseImportCsv}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Query, type Models } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getSearch, getView, pageToOffset, View } from '$lib/helpers/load';
|
||||
import { CARD_LIMIT, Dependencies } from '$lib/constants';
|
||||
import { flags } from '$lib/flags';
|
||||
|
||||
export const load = async ({ url, depends, route, params }) => {
|
||||
depends(Dependencies.SITES);
|
||||
@@ -11,11 +12,9 @@ export const load = async ({ url, depends, route, params }) => {
|
||||
const offset = pageToOffset(page, limit);
|
||||
const view = getView(url, route, View.Grid, View.Grid);
|
||||
|
||||
const sitesLive = false;
|
||||
|
||||
if (!sitesLive)
|
||||
if (!flags.showSites) {
|
||||
return {
|
||||
sitesLive,
|
||||
sitesLive: false,
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
@@ -25,6 +24,7 @@ export const load = async ({ url, depends, route, params }) => {
|
||||
sites: []
|
||||
} as Models.SiteList
|
||||
};
|
||||
}
|
||||
|
||||
const siteList = await sdk
|
||||
.forProject(params.region, params.project)
|
||||
@@ -34,7 +34,7 @@ export const load = async ({ url, depends, route, params }) => {
|
||||
);
|
||||
|
||||
return {
|
||||
sitesLive,
|
||||
sitesLive: true,
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
|
||||
Reference in New Issue
Block a user