Skip to content

Commit

Permalink
Merge pull request #1928 from akto-api-security/feature_set_custom_en…
Browse files Browse the repository at this point in the history
…v_type

Feature set custom env type
  • Loading branch information
ayushaga14 authored Jan 7, 2025
2 parents 204f400 + 5592c44 commit 15c0915
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ public String fetchCustomerEndpoints(){

List<Integer> apiCollectionIds;

private ENV_TYPE envType;
private String envType;

public String updateEnvType(){
try {
Expand Down Expand Up @@ -942,7 +942,7 @@ public void setRedacted(boolean redacted) {
this.redacted = redacted;
}

public void setEnvType(ENV_TYPE envType) {
public void setEnvType(String envType) {
this.envType = envType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function PrettifyChildren({ data, headers }) {
let ids = c.hasOwnProperty('apiCollectionIds') ? c['apiCollectionIds'] : [c.id];
let collectionObj = transform.convertToPrettifyData(c);
collectionObj.urlsCount = c.urlsCount;
collectionObj.envTypeComp = c.envType ? <Badge size="small" status="info">{func.toSentenceCase(c.envType)}</Badge> : null;
collectionObj.envTypeComp = c.envType ? <Badge size="small" status="info">{c.envType}</Badge> : null;

let isChildOpen = isLevelVisible(c.level);
collectionObj.displayNameComp =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PageWithMultipleCards from "../../../components/layouts/PageWithMultipleCards"
import { Text, Button, IndexFiltersMode, Box, Badge, Popover, ActionList, Link, Tooltip, Modal, Checkbox, LegacyCard, ResourceList, ResourceItem, Avatar, Filters, Card, HorizontalStack, Icon} from "@shopify/polaris"
import { HideMinor, ViewMinor,FileMinor } from '@shopify/polaris-icons';
import { Text, Button, IndexFiltersMode, Box, Badge, Popover, ActionList, ResourceItem, Avatar, HorizontalStack, Icon, TextField, Tooltip} from "@shopify/polaris"
import { HideMinor, ViewMinor,FileMinor, FileFilledMinor } from '@shopify/polaris-icons';
import api from "../api"
import dashboardApi from "../../dashboard/api"
import settingRequests from "../../settings/api"
Expand Down Expand Up @@ -216,6 +216,8 @@ function ApiCollections() {
const [normalData, setNormalData] = useState([])
const [treeView, setTreeView] = useState(false);
const [moreActions, setMoreActions] = useState(false);
const [textFieldActive, setTextFieldActive] = useState(false);
const [customEnv,setCustomEnv] = useState('')

// const dummyData = dummyJson;

Expand Down Expand Up @@ -627,14 +629,28 @@ function ApiCollections() {
autofocusTarget="first-node"
>
<Popover.Pane>
<ActionList
{textFieldActive ?
<Box padding={"1"}>
<TextField onChange={setCustomEnv} value={customEnv} connectedRight={(
<Tooltip content="Save your Custom env type" dismissOnMouseOut>
<Button onClick={() => {
resetResourcesSelected();
updateEnvType(selectedResources, customEnv);
setTextFieldActive(false);
}} plain icon={FileFilledMinor}/>
</Tooltip>
)}/>
</Box>
:<ActionList
actionRole="menuitem"
items={[
{content: 'Staging', onAction: () => updateEnvType(selectedResources, "STAGING")},
{content: 'Production', onAction: () => updateEnvType(selectedResources, "PRODUCTION")},
{content: 'Reset', onAction: () => updateEnvType(selectedResources, null)},
{content: 'Add Custom', onAction: () => setTextFieldActive(!textFieldActive)}
]}
/>

/>}
</Popover.Pane>
</Popover>
)
Expand All @@ -654,7 +670,7 @@ function ApiCollections() {
Object.keys(copyObj).forEach((key) => {
data[key].length > 0 && data[key].forEach((c) => {
c['envType'] = dataMap[c.id]
c['envTypeComp'] = dataMap[c.id] ? <Badge size="small" status="info">{func.toSentenceCase(dataMap[c.id])}</Badge> : null
c['envTypeComp'] = dataMap[c.id] ? <Badge size="small" status="info">{dataMap[c.id]}</Badge> : null
})
})
setData(copyObj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ const transform = {
riskScore: c.riskScore,
deactivatedRiskScore: c.deactivated ? (c.riskScore - 10 ) : c.riskScore,
activatedRiskScore: -1 * (c.deactivated ? c.riskScore : (c.riskScore - 10 )),
envTypeComp: isLoading ? loadingComp : c.envType ? <Badge size="small" status="info">{func.toSentenceCase(c.envType)}</Badge> : null,
envTypeComp: isLoading ? loadingComp : c.envType ? <Badge size="small" status="info">{c.envType}</Badge> : null,
sensitiveSubTypesVal: c?.sensitiveInRespTypes.join(" ") || "-"
}
})
Expand Down

0 comments on commit 15c0915

Please sign in to comment.