Skip to content

Commit

Permalink
Add script to find dead code in FE and remove it (minio#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
reivaj05 authored Sep 27, 2023
1 parent b7f6870 commit cf4d30f
Show file tree
Hide file tree
Showing 50 changed files with 97 additions and 5,149 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ jobs:
continue-on-error: false
run: |
./check-prettier.sh
- name: Check for dead code
working-directory: ./web-app
continue-on-error: false
run: |
./check-deadcode.sh
reuse-golang-dependencies:
timeout-minutes: 30
name: reuse golang dependencies
Expand Down
3 changes: 3 additions & 0 deletions web-app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ prettify:
yarn prettier --write . --loglevel warn

pretty: prettify

find-deadcode:
./check-deadcode.sh
8 changes: 8 additions & 0 deletions web-app/check-deadcode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

if [ -f "$NVM_DIR/nvm.sh" ]
then
\. "$NVM_DIR/nvm.sh";
nvm use;
fi
yarn find-deadcode
6 changes: 4 additions & 2 deletions web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"start": "PORT=5050 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"find-deadcode": "ts-prune -s operatorApi.ts | (! grep -v 'used in module')"
},
"eslintConfig": {
"extends": "react-app",
Expand Down Expand Up @@ -77,7 +78,8 @@
"prettier": "3.0.0",
"react-scripts": "5.0.1",
"testcafe": "2.6.2",
"typescript": "^4.4.3"
"typescript": "^4.4.3",
"ts-prune": "^0.10.3"
},
"resolutions": {
"nth-check": "^2.0.1",
Expand Down
35 changes: 0 additions & 35 deletions web-app/src/api/errors.ts

This file was deleted.

32 changes: 0 additions & 32 deletions web-app/src/common/Copyright.tsx

This file was deleted.

56 changes: 0 additions & 56 deletions web-app/src/common/SecureComponent/SecureComponent.tsx

This file was deleted.

1 change: 0 additions & 1 deletion web-app/src/common/SecureComponent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

export { default as hasPermission } from "./accessControl";
export { default as SecureComponent } from "./SecureComponent";
120 changes: 0 additions & 120 deletions web-app/src/common/SecureComponent/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,124 +520,4 @@ export const IAM_PAGES_PERMISSIONS = {
],
};

export const S3_ALL_RESOURCES = "arn:aws:s3:::*";
export const CONSOLE_UI_RESOURCE = "console-ui";

export const permissionTooltipHelper = (scopes: string[], name: string) => {
let niceScopes = scopes.join(", ").toString();

return (
"You require additional permissions in order to " +
name +
". Please ask your MinIO administrator to grant you " +
niceScopes +
" permission" +
(scopes.length > 1 ? "s" : "") +
" in order to " +
name +
"."
);
};

export const listUsersPermissions = [IAM_SCOPES.ADMIN_LIST_USERS];

export const addUserToGroupPermissions = [IAM_SCOPES.ADMIN_ADD_USER_TO_GROUP];

export const deleteUserPermissions = [IAM_SCOPES.ADMIN_DELETE_USER];

export const enableUserPermissions = [IAM_SCOPES.ADMIN_ENABLE_USER];

export const disableUserPermissions = [IAM_SCOPES.ADMIN_DISABLE_USER];

//note that adminUserPermissions does NOT include ADMIN_CREATE_USER to allow hiding the Users tab for users wtih only this permission as it is being applied by default
export const adminUserPermissions = [
IAM_SCOPES.ADMIN_LIST_USER_POLICIES,
IAM_SCOPES.ADMIN_LIST_USERS,
IAM_SCOPES.ADMIN_ADD_USER_TO_GROUP,
IAM_SCOPES.ADMIN_REMOVE_USER_FROM_GROUP,
IAM_SCOPES.ADMIN_ATTACH_USER_OR_GROUP_POLICY,
IAM_SCOPES.ADMIN_LIST_USERS,
IAM_SCOPES.ADMIN_DELETE_USER,
IAM_SCOPES.ADMIN_ENABLE_USER,
IAM_SCOPES.ADMIN_DISABLE_USER,
IAM_SCOPES.ADMIN_GET_USER,
IAM_SCOPES.ADMIN_LIST_USER_POLICIES,
];

export const assignIAMPolicyPermissions = [
IAM_SCOPES.ADMIN_ATTACH_USER_OR_GROUP_POLICY,
IAM_SCOPES.ADMIN_LIST_USER_POLICIES,
IAM_SCOPES.ADMIN_GET_POLICY,
];

export const assignGroupPermissions = [
IAM_SCOPES.ADMIN_ADD_USER_TO_GROUP,
IAM_SCOPES.ADMIN_REMOVE_USER_FROM_GROUP,
IAM_SCOPES.ADMIN_LIST_GROUPS,
IAM_SCOPES.ADMIN_ENABLE_USER,
];

export const getGroupPermissions = [IAM_SCOPES.ADMIN_GET_GROUP];

export const enableDisableUserPermissions = [
IAM_SCOPES.ADMIN_ENABLE_USER,
IAM_SCOPES.ADMIN_DISABLE_USER,
];

export const editServiceAccountPermissions = [
IAM_SCOPES.ADMIN_LIST_SERVICEACCOUNTS,
IAM_SCOPES.ADMIN_UPDATE_SERVICEACCOUNT,
IAM_SCOPES.ADMIN_REMOVE_SERVICEACCOUNT,
];

export const applyPolicyPermissions = [
IAM_SCOPES.ADMIN_ATTACH_USER_OR_GROUP_POLICY,
IAM_SCOPES.ADMIN_LIST_USER_POLICIES,
];

export const deleteGroupPermissions = [IAM_SCOPES.ADMIN_REMOVE_USER_FROM_GROUP];

export const displayGroupsPermissions = [IAM_SCOPES.ADMIN_LIST_GROUPS];

export const createGroupPermissions = [
IAM_SCOPES.ADMIN_ADD_USER_TO_GROUP,
IAM_SCOPES.ADMIN_LIST_USERS,
];

export const viewUserPermissions = [
IAM_SCOPES.ADMIN_GET_USER,
IAM_SCOPES.ADMIN_LIST_USERS,
];
export const editGroupMembersPermissions = [
IAM_SCOPES.ADMIN_ADD_USER_TO_GROUP,
IAM_SCOPES.ADMIN_LIST_USERS,
];
export const setGroupPoliciesPermissions = [
IAM_SCOPES.ADMIN_ATTACH_USER_OR_GROUP_POLICY,
IAM_SCOPES.ADMIN_LIST_USER_POLICIES,
];
export const viewPolicyPermissions = [IAM_SCOPES.ADMIN_GET_POLICY];
export const enableDisableGroupPermissions = [
IAM_SCOPES.ADMIN_ENABLE_GROUP,
IAM_SCOPES.ADMIN_DISABLE_GROUP,
];
export const createPolicyPermissions = [IAM_SCOPES.ADMIN_CREATE_POLICY];

export const deletePolicyPermissions = [IAM_SCOPES.ADMIN_DELETE_POLICY];

export const listPolicyPermissions = [IAM_SCOPES.ADMIN_LIST_USER_POLICIES];

export const listGroupPermissions = [
IAM_SCOPES.ADMIN_LIST_GROUPS,
IAM_SCOPES.ADMIN_GET_GROUP,
];

export const deleteBucketPermissions = [
IAM_SCOPES.S3_DELETE_BUCKET,
IAM_SCOPES.S3_FORCE_DELETE_BUCKET,
];

export const browseBucketPermissions = [
IAM_SCOPES.S3_LIST_BUCKET,
IAM_SCOPES.S3_ALL_LIST_BUCKET,
];
6 changes: 0 additions & 6 deletions web-app/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,6 @@ export interface ErrorResponseHandler {
statusCode?: number;
message?: string; // if any type error thrown
}

export interface IBytesCalc {
total: number;
unit: string;
}

export interface IEmbeddedCustomButton {
backgroundColor?: string;
textColor?: string;
Expand Down
Loading

0 comments on commit cf4d30f

Please sign in to comment.