Skip to content

Commit

Permalink
Update feature set and block enable and config fucntion
Browse files Browse the repository at this point in the history
Signed-off-by: Al Asad Nur Riyad <[email protected]>
  • Loading branch information
nurRiyad committed Oct 10, 2023
1 parent 0a357bb commit fa5d7b5
Show file tree
Hide file tree
Showing 12 changed files with 421 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ function isEqualToModelPathValue(
}

function isFeatureRequired(storeGet,featureName) {



const featureSet = getFeatureSetDetails(storeGet);
const requiredFeatures = featureSet?.spec?.requiredFeatures || [];
const isRequired = requiredFeatures.includes(featureName);

return isRequired;
}

Expand All @@ -74,20 +70,24 @@ function getEnabledFeatures({ storeGet }) {
return item?.spec?.featureSet === featureSet;
}) || [];

// if user click on featureSet configure btn
if (configureMode) {
// filter only (enabled + required) feature of a feature set
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return item?.status?.enabled || isFeatureRequired(storeGet, featureName);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// if user click feature block enable btn
if (featureBlock) {

if (featureBlock) {
//feature block level
if (configureMode) {
// configure btn
// filter only (enabled + required + feature block recommended feature)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled ||
isFeatureRequired(storeGet, featureName) ||
(item?.spec?.featureBlock === featureBlock && item?.spec?.recommended)
);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// enable btn
// filter only (enabled + required + feature block feature)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
Expand All @@ -101,15 +101,29 @@ function getEnabledFeatures({ storeGet }) {
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
}
// is user click feature set enable btn
else {
} else {
// feature set level
if (configureMode) {
// configure btn
// filter only (enabled + required) feature of a feature set
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled || isFeatureRequired(storeGet, featureName)
);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// enable btn
// filter only (enabled + required + recommended)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled ||
item?.spec?.recommended ||
isFeatureRequired(storeGet,featureName)
isFeatureRequired(storeGet, featureName)
);
});
const enabledFeatureNames =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ function isEqualToModelPathValue(
}

function isFeatureRequired(storeGet,featureName) {



const featureSet = getFeatureSetDetails(storeGet);
const requiredFeatures = featureSet?.spec?.requiredFeatures || [];
const isRequired = requiredFeatures.includes(featureName);

return isRequired;
}

Expand All @@ -74,20 +70,24 @@ function getEnabledFeatures({ storeGet }) {
return item?.spec?.featureSet === featureSet;
}) || [];

// if user click on featureSet configure btn
if (configureMode) {
// filter only (enabled + required) feature of a feature set
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return item?.status?.enabled || isFeatureRequired(storeGet, featureName);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// if user click feature block enable btn
if (featureBlock) {

if (featureBlock) {
//feature block level
if (configureMode) {
// configure btn
// filter only (enabled + required + feature block recommended feature)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled ||
isFeatureRequired(storeGet, featureName) ||
(item?.spec?.featureBlock === featureBlock && item?.spec?.recommended)
);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// enable btn
// filter only (enabled + required + feature block feature)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
Expand All @@ -101,15 +101,29 @@ function getEnabledFeatures({ storeGet }) {
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
}
// is user click feature set enable btn
else {
} else {
// feature set level
if (configureMode) {
// configure btn
// filter only (enabled + required) feature of a feature set
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled || isFeatureRequired(storeGet, featureName)
);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// enable btn
// filter only (enabled + required + recommended)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled ||
item?.spec?.recommended ||
isFeatureRequired(storeGet,featureName)
isFeatureRequired(storeGet, featureName)
);
});
const enabledFeatureNames =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ function isEqualToModelPathValue(
}

function isFeatureRequired(storeGet,featureName) {



const featureSet = getFeatureSetDetails(storeGet);
const requiredFeatures = featureSet?.spec?.requiredFeatures || [];
const isRequired = requiredFeatures.includes(featureName);

return isRequired;
}

Expand All @@ -74,20 +70,24 @@ function getEnabledFeatures({ storeGet }) {
return item?.spec?.featureSet === featureSet;
}) || [];

// if user click on featureSet configure btn
if (configureMode) {
// filter only (enabled + required) feature of a feature set
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return item?.status?.enabled || isFeatureRequired(storeGet, featureName);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// if user click feature block enable btn
if (featureBlock) {

if (featureBlock) {
//feature block level
if (configureMode) {
// configure btn
// filter only (enabled + required + feature block recommended feature)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled ||
isFeatureRequired(storeGet, featureName) ||
(item?.spec?.featureBlock === featureBlock && item?.spec?.recommended)
);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// enable btn
// filter only (enabled + required + feature block feature)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
Expand All @@ -101,15 +101,29 @@ function getEnabledFeatures({ storeGet }) {
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
}
// is user click feature set enable btn
else {
} else {
// feature set level
if (configureMode) {
// configure btn
// filter only (enabled + required) feature of a feature set
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled || isFeatureRequired(storeGet, featureName)
);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// enable btn
// filter only (enabled + required + recommended)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled ||
item?.spec?.recommended ||
isFeatureRequired(storeGet,featureName)
isFeatureRequired(storeGet, featureName)
);
});
const enabledFeatureNames =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ function isEqualToModelPathValue(
}

function isFeatureRequired(storeGet,featureName) {



const featureSet = getFeatureSetDetails(storeGet);
const requiredFeatures = featureSet?.spec?.requiredFeatures || [];
const isRequired = requiredFeatures.includes(featureName);

return isRequired;
}

Expand All @@ -74,20 +70,24 @@ function getEnabledFeatures({ storeGet }) {
return item?.spec?.featureSet === featureSet;
}) || [];

// if user click on featureSet configure btn
if (configureMode) {
// filter only (enabled + required) feature of a feature set
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return item?.status?.enabled || isFeatureRequired(storeGet, featureName);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// if user click feature block enable btn
if (featureBlock) {

if (featureBlock) {
//feature block level
if (configureMode) {
// configure btn
// filter only (enabled + required + feature block recommended feature)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled ||
isFeatureRequired(storeGet, featureName) ||
(item?.spec?.featureBlock === featureBlock && item?.spec?.recommended)
);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// enable btn
// filter only (enabled + required + feature block feature)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
Expand All @@ -101,15 +101,29 @@ function getEnabledFeatures({ storeGet }) {
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
}
// is user click feature set enable btn
else {
} else {
// feature set level
if (configureMode) {
// configure btn
// filter only (enabled + required) feature of a feature set
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled || isFeatureRequired(storeGet, featureName)
);
});
const enabledFeatureNames =
enabledFeatures.map((item) => item?.metadata?.name) || [];
return enabledFeatureNames;
} else {
// enable btn
// filter only (enabled + required + recommended)
const enabledFeatures = allFeatureSetFeature.filter((item) => {
const featureName = item?.metadata?.name;
return (
item?.status?.enabled ||
item?.spec?.recommended ||
isFeatureRequired(storeGet,featureName)
isFeatureRequired(storeGet, featureName)
);
});
const enabledFeatureNames =
Expand Down
Loading

0 comments on commit fa5d7b5

Please sign in to comment.