Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature set custom env type #1928

Merged
merged 3 commits into from
Jan 7, 2025
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
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
Loading