mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix project deploy settings shape
This commit is contained in:
2 files changed
+63
-28
No files matched your search
@@ -1,17 +1,32 @@
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useFS } from './useFS';
|
||||
|
||||
export interface ProjectDeploySettings {
|
||||
providerId?: string;
|
||||
netlify?: {
|
||||
export interface ShakespeareProjectConfig {
|
||||
type: 'shakespeare';
|
||||
data: {
|
||||
subdomain?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export interface NetlifyProjectConfig {
|
||||
type: 'netlify';
|
||||
data: {
|
||||
siteId?: string;
|
||||
};
|
||||
vercel?: {
|
||||
}
|
||||
|
||||
export interface VercelProjectConfig {
|
||||
type: 'vercel';
|
||||
data: {
|
||||
teamId?: string;
|
||||
projectId?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type ProjectProviderConfig = ShakespeareProjectConfig | NetlifyProjectConfig | VercelProjectConfig;
|
||||
|
||||
export type ProjectDeploySettings = Record<string, ProjectProviderConfig>;
|
||||
|
||||
/**
|
||||
* Hook to manage project-specific deployment settings
|
||||
* Stores settings in .git/shakespeare/deploy.json
|
||||
@@ -59,15 +74,20 @@ export function useProjectDeploySettings(projectId: string) {
|
||||
}
|
||||
};
|
||||
|
||||
const updateSettings = async (updates: Partial<ProjectDeploySettings>) => {
|
||||
const newSettings = { ...settings, ...updates };
|
||||
const updateSettings = async (providerId: string, config: ProjectProviderConfig) => {
|
||||
const newSettings = { ...settings, [providerId]: config };
|
||||
await saveSettings(newSettings);
|
||||
};
|
||||
|
||||
const getProviderConfig = (providerId: string): ProjectProviderConfig | undefined => {
|
||||
return settings[providerId];
|
||||
};
|
||||
|
||||
return {
|
||||
settings,
|
||||
isLoading,
|
||||
updateSettings,
|
||||
saveSettings,
|
||||
getProviderConfig,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user