Move ssh out to org level

This commit is contained in:
Tuan Dang
2024-12-15 20:43:13 -08:00
214 changed files with 6277 additions and 2125 deletions
+21 -4
View File
@@ -1,14 +1,31 @@
/** Extracts the key and value from a passed in env string based on the provided delimiters. */
export const getKeyValue = (pastedContent: string, delimiters: string[]) => {
const foundDelimiter = delimiters.find((delimiter) => pastedContent.includes(delimiter));
if (!pastedContent) {
return { key: "", value: "" };
}
if (!foundDelimiter) {
let firstDelimiterIndex = -1;
let foundDelimiter = "";
delimiters.forEach((delimiter) => {
const index = pastedContent.indexOf(delimiter);
if (index !== -1 && (firstDelimiterIndex === -1 || index < firstDelimiterIndex)) {
firstDelimiterIndex = index;
foundDelimiter = delimiter;
}
});
const hasValueAfterDelimiter = pastedContent.length > firstDelimiterIndex + foundDelimiter.length;
if (firstDelimiterIndex === -1 || !hasValueAfterDelimiter) {
return { key: pastedContent.trim(), value: "" };
}
const [key, value] = pastedContent.split(foundDelimiter);
const key = pastedContent.substring(0, firstDelimiterIndex);
const value = pastedContent.substring(firstDelimiterIndex + foundDelimiter.length);
return {
key: key.trim(),
value: (value ?? "").trim()
value: value.trim()
};
};
+28 -3
View File
@@ -1,5 +1,6 @@
import { apiRequest } from "@app/config/request";
import { createWorkspace } from "@app/hooks/api/workspace/queries";
import { ProjectType, Workspace } from "@app/hooks/api/workspace/types";
const secretsToBeAdded = [
{
@@ -36,12 +37,13 @@ const secretsToBeAdded = [
* Create and initialize a new project in organization with id [organizationId]
* Note: current user should be a member of the organization
*/
const initProjectHelper = async ({ projectName }: { projectName: string }) => {
export const initProjectHelper = async ({ projectName }: { projectName: string }) => {
// create new project
const {
data: { project }
} = await createWorkspace({
projectName
projectName,
type: ProjectType.SecretManager
});
try {
@@ -59,4 +61,27 @@ const initProjectHelper = async ({ projectName }: { projectName: string }) => {
return project;
};
export { initProjectHelper };
export const getProjectHomePage = (workspace: Workspace) => {
if (workspace.type === ProjectType.SecretManager) {
return `/${workspace.type}/${workspace.id}/secrets/overview`;
}
if (workspace.type === ProjectType.CertificateManager) {
return `/${workspace.type}/${workspace.id}/certificates`;
}
if (workspace.type === ProjectType.KMS) {
return `/${workspace.type}/${workspace.id}/kms`;
}
return `/${workspace.type}/${workspace.id}/ssh`;
};
export const getProjectTitle = (type: ProjectType) => {
const titleConvert = {
[ProjectType.SecretManager]: "Secret Management",
[ProjectType.KMS]: "Key Management",
[ProjectType.CertificateManager]: "Cert Management",
[ProjectType.SSH]: "SSH"
};
return titleConvert[type];
};