Skip to content

Conversation

@dhananjay0601
Copy link
Contributor

@dhananjay0601 dhananjay0601 commented Jul 24, 2023

Description

As of now only super admins can do save selection as filter or modify or delete and existing filter group.
This feature request is raised to extend this capability to admins.

Fixes devtron-labs/devtron#3402

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • By creating a new filter from the app which are not allowed for admin to and editing the existing filters

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@dhananjay0601 dhananjay0601 self-assigned this Jul 25, 2023
@@ -1,4 +1,4 @@
import React, { Suspense, useCallback, useRef, useEffect, useState, useMemo } from 'react'
import React, { Suspense, useCallback, useRef, useEffect, useState, useMemo, Children } from 'react'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unused import

@dhananjay0601 dhananjay0601 requested a review from milindk8 July 26, 2023 07:12
import { CONTEXT_NOT_AVAILABLE_ERROR } from '../../config/constantMessaging'
import { toast } from 'react-toastify'
import CreateAppGroup from './CreateAppGroup'
import { create } from 'domain'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unused imports

const [clickedGroup, setClickedGroup] = useState<GroupOptionType>(null)
const [allAppsList, setAllAppsList] = useState<CreateGroupAppListType[]>([])
const [isVirtualEnv, setIsVirtualEnv] = useState<boolean>(false)
const [unauthorizedApps, setUnauthorizedApps] = useState<String[]>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be unAuthorizedApps

}

const openCreateGroup = (e, groupId?: string) => {
const handleToast = (field: string) => {
Copy link
Contributor

@vivek-devtron vivek-devtron Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename field to action

if(err['code'] === 403) {
let arrUnauthorized = []
err['errors'].map((errors) => {
arrUnauthorized.push([...errors['userMessage']['unauthorizedApps']])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to update this in the state to show on create page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated state stored in hashmap

setLoading(true)
try {
const {result} = await appGroupPermission(envId, payload)
if(result === true) {
Copy link
Contributor

@vivek-devtron vivek-devtron Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can write it as if(result) {

}
}

async function getAllPermissionCheck(payload: CheckPermissionType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems replica of above function, can't we merge both?

import Tippy from '@tippyjs/react'

export default function CreateAppGroup({ appList, selectedAppGroup, closePopup }: CreateGroupType) {
export default function CreateAppGroup({ appList, selectedAppGroup, closePopup, unauthorizedApps }: CreateGroupType) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename unauthorizedApps to unAuthorizedApps

setSelectedAppsCount(_selectedAppsCount)
}

const unauthorizedAppCheck = (appName: String) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing all this we should pass a map of unauthorized apps from parent

@dhananjay0601 dhananjay0601 removed the request for review from milindk8 July 27, 2023 05:54
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dhananjay0601 dhananjay0601 merged commit 12c907c into main Jul 31, 2023
@dhananjay0601 dhananjay0601 deleted the admin-app-groups branch July 31, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Admins should be able to save, edit and delete filters in application groups

3 participants