Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ const conf: Config = {
{
name: "olvm",
types: ["destination"],
requiredFields: ["cluster"]
requiredFields: ["cluster"],
},
{
name: "rhev",
types: ["destination"],
requiredFields: ["cluster"]
}
requiredFields: ["cluster"],
},
],

/*
Expand Down Expand Up @@ -202,7 +202,13 @@ const conf: Config = {
hiddenUsers: ["barbican", "coriolis"],

// The list of user roles to hide in the UI
hiddenUserRoles: ["audit", "creator", "observer", "service", "key-manager:service-admin"],
hiddenUserRoles: [
"audit",
"creator",
"observer",
"service",
"key-manager:service-admin",
],

// By default, if a field name contains `password` in it (ex.: `user_password`),
// it will be rendered as a password input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,10 @@ class TransferItemModal extends React.Component<Props, State> {
try {
await providerStore.loadOptionsSchema({
providerName: endpoint.type,
requiresWindowsImage: this.requiresWindowsImage,
optionsType,
useCache,
forceRefresh: !useCache,
requiresWindowsImage: this.requiresWindowsImage,
});
} catch (err) {
if (optionsType === "destination") {
Expand All @@ -500,6 +501,7 @@ class TransferItemModal extends React.Component<Props, State> {
endpointId: endpoint.id,
providerName: endpoint.type,
useCache,
forceRefresh: !useCache,
requiresWindowsImage: this.requiresWindowsImage,
});
}
Expand Down
7 changes: 7 additions & 0 deletions src/components/smart/WizardPage/WizardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,18 +491,25 @@ class WizardPage extends React.Component<Props, State> {
await providerStore.loadOptionsSchema({
providerName: endpoint.type,
optionsType,
forceRefresh: true,
requiresWindowsImage: this.requiresWindowsImage,
});
const getSchema = () =>
optionsType === "source"
? providerStore.sourceSchema
: providerStore.destinationSchema;
wizardStore.updateData(
optionsType === "source"
? { sourceOptions: undefined }
: { destOptions: undefined },
);
wizardStore.fillWithDefaultValues(optionsType, getSchema());

await providerStore.getOptionsValues({
optionsType,
endpointId: endpoint.id,
providerName: endpoint.type,
forceRefresh: true,
requiresWindowsImage: this.requiresWindowsImage,
});
wizardStore.fillWithDefaultValues(optionsType, getSchema());
Expand Down
28 changes: 25 additions & 3 deletions src/sources/ProviderSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ class ProviderSource {
providerName: ProviderTypes;
optionsType: "source" | "destination";
useCache?: boolean | null;
forceRefresh?: boolean;
quietError?: boolean | null;
requiresWindowsImage?: boolean;
}): Promise<Field[]> {
const {
providerName,
optionsType,
useCache,
forceRefresh,
quietError,
requiresWindowsImage,
} = opts;
Expand All @@ -57,9 +59,15 @@ class ProviderSource {
? providerTypes.SOURCE_TRANSFER
: providerTypes.TARGET_TRANSFER;

const url = `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/providers/${providerName}/schemas/${schemaTypeInt}`;

if (forceRefresh) {
Api.removeFromCache(url);
}

try {
const response = await Api.send({
url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/providers/${providerName}/schemas/${schemaTypeInt}`,
url,
cache: useCache,
quietError,
});
Expand Down Expand Up @@ -88,9 +96,17 @@ class ProviderSource {
endpointId: string;
envData: { [prop: string]: any } | null | undefined;
cache?: boolean | null;
forceRefresh?: boolean;
quietError?: boolean;
}): Promise<OptionValues[]> {
const { optionsType, endpointId, envData, cache, quietError } = opts;
const {
optionsType,
endpointId,
envData,
cache,
forceRefresh,
quietError,
} = opts;
let envString = "";
if (envData) {
envString = `?env=${DomUtils.encodeToBase64Url(envData)}`;
Expand All @@ -100,8 +116,14 @@ class ProviderSource {
const fieldName =
optionsType === "source" ? "source_options" : "destination_options";

const url = `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/endpoints/${endpointId}/${callName}${envString}`;

if (forceRefresh) {
Api.removeFromCache(url);
}

const response = await Api.send({
url: `${configLoader.config.servicesUrls.coriolis}/${Api.projectId}/endpoints/${endpointId}/${callName}${envString}`,
url,
cache,
cancelId: endpointId,
quietError,
Expand Down
6 changes: 6 additions & 0 deletions src/stores/ProviderStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,15 @@ class ProviderStore {
providerName: ProviderTypes;
optionsType: "source" | "destination";
useCache?: boolean;
forceRefresh?: boolean;
quietError?: boolean;
requiresWindowsImage?: boolean;
}): Promise<Field[]> {
const {
providerName,
optionsType,
useCache,
forceRefresh,
quietError,
requiresWindowsImage,
} = options;
Expand Down Expand Up @@ -272,6 +274,7 @@ class ProviderStore {
providerName,
optionsType,
useCache,
forceRefresh,
quietError,
requiresWindowsImage,
});
Expand Down Expand Up @@ -330,6 +333,7 @@ class ProviderStore {
requiresWindowsImage?: boolean;
envData?: { [prop: string]: any } | null;
useCache?: boolean;
forceRefresh?: boolean;
quietError?: boolean;
allowMultiple?: boolean;
}): Promise<OptionValues[]> {
Expand All @@ -339,6 +343,7 @@ class ProviderStore {
endpointId,
envData,
useCache,
forceRefresh,
quietError,
allowMultiple,
requiresWindowsImage,
Expand Down Expand Up @@ -386,6 +391,7 @@ class ProviderStore {
endpointId,
envData,
cache: useCache,
forceRefresh,
quietError,
});
this.getOptionsValuesSuccess({
Expand Down
26 changes: 16 additions & 10 deletions src/utils/LabelDictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,16 +178,22 @@ class LabelDictionary {
}

static pushToCache(field: Field, dictionaryKey: string) {
if (
(field.title || field.description) &&
!cache.find(i => i.key === dictionaryKey && i.name === field.name)
) {
cache.push({
label: field.title,
description: field.description,
name: field.name,
key: dictionaryKey,
});
if (!(field.title || field.description)) {
return;
}
const existingIndex = cache.findIndex(
i => i.key === dictionaryKey && i.name === field.name,
);
const entry = {
label: field.title,
description: field.description,
name: field.name,
key: dictionaryKey,
};
if (existingIndex >= 0) {
cache[existingIndex] = entry;
} else {
cache.push(entry);
}
}
}
Expand Down
Loading