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

removed adminApproved field #1866

Merged
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
1 change: 0 additions & 1 deletion public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@
"appLanguageCode": "Choose Language",
"delete": "Delete User",
"saveChanges": "Save Changes",
"adminApproved": "Admin approved",
"pluginCreationAllowed": "Plugin creation allowed",
"joined": "Joined",
"created": "Created",
Expand Down
1 change: 0 additions & 1 deletion public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@
"appLanguageCode": "Choisir la langue",
"delete": "Supprimer l'utilisateur",
"saveChanges": "Enregistrer les modifications",
"adminApproved": "Approuvé par l'administrateur",
"pluginCreationAllowed": "Autorisation de création de plugin",
"joined": "Rejoint",
"created": "Créé",
Expand Down
1 change: 0 additions & 1 deletion public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,6 @@
"appLanguageCode": "भाषा चुनें",
"delete": "उपयोगकर्ता को हटाएं",
"saveChanges": "परिवर्तन सहेजें",
"adminApproved": "व्यवस्थापक द्वारा स्वीकृत",
"pluginCreationAllowed": "प्लगइन निर्माण अनुमति दी गई",
"joined": "शामिल हुए",
"created": "बनाया गया",
Expand Down
1 change: 0 additions & 1 deletion public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,6 @@
"appLanguageCode": "Elegir Idioma",
"delete": "Eliminar Usuario",
"saveChanges": "Guardar Cambios",
"adminApproved": "Aprobado por el administrador",
"pluginCreationAllowed": "Permitir creación de complementos",
"joined": "Unido",
"created": "Creado",
Expand Down
1 change: 0 additions & 1 deletion public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,6 @@
"appLanguageCode": "选择语言",
"delete": "删除用户",
"saveChanges": "保存更改",
"adminApproved": "管理员已批准",
"pluginCreationAllowed": "允许创建插件",
"joined": "加入",
"created": "创建",
Expand Down
6 changes: 0 additions & 6 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ input EditVenueInput {
}

type Mutation {
acceptAdmin(id: ID!): Boolean!
acceptMembershipRequest(membershipRequestId: ID!): MembershipRequest!
addEventAttendee(data: EventAttendeeInput!): User!
addFeedback(data: FeedbackInput!): Feedback!
Expand Down Expand Up @@ -673,10 +672,8 @@ type Mutation {
createSampleOrganization: Boolean!
createUserFamily(data: createUserFamilyInput!): UserFamily!
createUserTag(input: CreateUserTagInput!): UserTag
<<<<<<< HEAD
createVenue(data: VenueInput!): Venue
deleteAdvertisement(id: ID!): DeletePayload!
=======
deleteAdvertisementById(id: ID!): DeletePayload!
deleteAgendaCategory(id: ID!): ID!
deleteDonationById(id: ID!): DeletePayload!
Expand All @@ -693,7 +690,6 @@ type Mutation {
recaptcha(data: RecaptchaVerification!): Boolean!
refreshToken(refreshToken: String!): ExtendSession!
registerForEvent(id: ID!): Event!
rejectAdmin(id: ID!): Boolean!
rejectMembershipRequest(membershipRequestId: ID!): MembershipRequest!
removeActionItem(id: ID!): ActionItem!
removeAdmin(data: UserAndOrganizationInput!): AppUserProfile!
Expand Down Expand Up @@ -1105,7 +1101,6 @@ type Query {
user(id: ID!): UserData!
userLanguage(userId: ID!): String
users(
adminApproved: Boolean
first: Int
orderBy: UserOrderByInput
skip: Int
Expand Down Expand Up @@ -1329,7 +1324,6 @@ scalar Upload
type User {
_id: ID!
address: Address
adminApproved: Boolean
appUserProfileId: AppUserProfile
birthDate: Date
createdAt: DateTime!
Expand Down
13 changes: 0 additions & 13 deletions src/GraphQl/Mutations/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ export const LOGIN_MUTATION = gql`
email
}
appUserProfile {
adminApproved
adminFor {
_id
}
Expand Down Expand Up @@ -459,18 +458,6 @@ export const UPDATE_USERTYPE_MUTATION = gql`
}
`;

export const ACCEPT_ADMIN_MUTATION = gql`
mutation AcceptAdmin($id: ID!) {
acceptAdmin(id: $id)
}
`;

export const REJECT_ADMIN_MUTATION = gql`
mutation RejectAdmin($id: ID!) {
rejectAdmin(id: $id)
}
`;

/**
* {@label UPDATE_INSTALL_STATUS_PLUGIN_MUTATION}
* @remarks
Expand Down
6 changes: 0 additions & 6 deletions src/GraphQl/Queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ export const USER_LIST = gql`
}
}
appUserProfile {
adminApproved
_id
adminFor {
_id
Expand Down Expand Up @@ -223,7 +222,6 @@ export const USER_LIST_REQUEST = gql`
$lastName_contains: String
$first: Int
$skip: Int
$adminApproved: Boolean
) {
users(
where: {
Expand All @@ -232,7 +230,6 @@ export const USER_LIST_REQUEST = gql`
}
skip: $skip
first: $first
adminApproved: $adminApproved
) {
user {
firstName
Expand All @@ -244,7 +241,6 @@ export const USER_LIST_REQUEST = gql`
}
appUserProfile {
_id
adminApproved
adminFor {
_id
}
Expand Down Expand Up @@ -520,7 +516,6 @@ export const USER_DETAILS = gql`
}
appUserProfile {
_id
adminApproved
adminFor {
_id
}
Expand Down Expand Up @@ -730,7 +725,6 @@ export const USERS_CONNECTION_LIST = gql`
}
appUserProfile {
_id
adminApproved
adminFor {
_id
}
Expand Down
1 change: 0 additions & 1 deletion src/components/UserPortal/Login/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const MOCKS = [
accessToken: 'accessToken',
refreshToken: 'refreshToken',
appUserProfile: {
adminApproved: true,
adminFor: [
{
_id: 'id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const renderStartPostModal = (
email: '[email protected]',
appLanguageCode: 'en',
pluginCreationAllowed: true,
adminApproved: true,
createdAt: '2023-02-18T09:22:27.969Z',
adminFor: [],
createdOrganizations: [],
Expand All @@ -87,7 +86,6 @@ const renderStartPostModal = (
appUserProfile: {
__typename: 'AppUserProfile',
_id: '123',
adminApproved: true,
isSuperAdmin: true,
adminFor: [],
createdOrganizations: [],
Expand Down
3 changes: 0 additions & 3 deletions src/components/UserPortal/UserSidebar/UserSidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const MOCKS = [
},
appUserProfile: {
_id: 'properId',
adminApproved: true,
adminFor: [],
createdOrganizations: [],
createdEvents: [],
Expand Down Expand Up @@ -138,7 +137,6 @@ const MOCKS = [
createdEvents: [],
eventAdmin: [],
isSuperAdmin: true,
adminApproved: true,
pluginCreationAllowed: true,
appLanguageCode: 'en',
},
Expand Down Expand Up @@ -210,7 +208,6 @@ const MOCKS = [
},
appUserProfile: {
_id: 'orgEmpty',
adminApproved: true,
adminFor: [],
createdOrganizations: [],
createdEvents: [],
Expand Down
6 changes: 0 additions & 6 deletions src/components/UsersTableItem/UserTableItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ describe('Testing User Table Item', () => {
},
appUserProfile: {
_id: '123',
adminApproved: true,
isSuperAdmin: true,
createdOrganizations: [],
createdEvents: [],
Expand Down Expand Up @@ -238,7 +237,6 @@ describe('Testing User Table Item', () => {
},
appUserProfile: {
_id: '123',
adminApproved: true,
isSuperAdmin: true,
createdOrganizations: [],
createdEvents: [],
Expand Down Expand Up @@ -405,7 +403,6 @@ describe('Testing User Table Item', () => {
},
appUserProfile: {
_id: '123',
adminApproved: true,
isSuperAdmin: true,
createdOrganizations: [],
createdEvents: [],
Expand Down Expand Up @@ -620,7 +617,6 @@ describe('Testing User Table Item', () => {
},
appUserProfile: {
_id: '123',
adminApproved: true,
isSuperAdmin: true,
createdOrganizations: [],
createdEvents: [],
Expand Down Expand Up @@ -838,7 +834,6 @@ describe('Testing User Table Item', () => {
},
appUserProfile: {
_id: '123',
adminApproved: true,
isSuperAdmin: true,
createdOrganizations: [],
createdEvents: [],
Expand Down Expand Up @@ -1021,7 +1016,6 @@ describe('Testing User Table Item', () => {
},
appUserProfile: {
_id: '123',
adminApproved: true,
isSuperAdmin: true,
createdOrganizations: [],
createdEvents: [],
Expand Down
1 change: 0 additions & 1 deletion src/screens/LoginPage/LoginPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const MOCKS = [
login: {
user: {
_id: '1',
adminApproved: true,
},
appUserProfile: {
isSuperAdmin: false,
Expand Down
4 changes: 1 addition & 3 deletions src/screens/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ const loginPage = (): JSX.Element => {
const { login } = loginData;
const { user, appUserProfile } = login;
const isAdmin: boolean =
appUserProfile.isSuperAdmin ||
(appUserProfile.adminFor.length !== 0 &&
appUserProfile.adminApproved === true);
appUserProfile.isSuperAdmin || appUserProfile.adminFor.length !== 0;

if (role === 'admin' && !isAdmin) {
toast.warn(t('notAuthorised'));
Expand Down
45 changes: 0 additions & 45 deletions src/screens/MemberDetail/MemberDetail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const MOCKS1 = [
},
],
pluginCreationAllowed: true,
adminApproved: true,
},
user: {
_id: '1',
Expand Down Expand Up @@ -158,7 +157,6 @@ const MOCKS2 = [
},
],
pluginCreationAllowed: true,
adminApproved: true,
},
user: {
_id: '1',
Expand Down Expand Up @@ -247,7 +245,6 @@ const MOCKS3 = [
},
],
pluginCreationAllowed: true,
adminApproved: true,
},
user: {
_id: '1',
Expand Down Expand Up @@ -340,7 +337,6 @@ describe('MemberDetail', () => {
expect(screen.getAllByText(/First name/i)).toBeTruthy();
expect(screen.getAllByText(/Last name/i)).toBeTruthy();
expect(screen.getAllByText(/Language/i)).toBeTruthy();
expect(screen.getByText(/Admin approved/i)).toBeInTheDocument();
expect(screen.getByText(/Plugin creation allowed/i)).toBeInTheDocument();
expect(screen.getAllByText(/Joined on/i)).toBeTruthy();
expect(screen.getAllByText(/Joined On/i)).toHaveLength(1);
Expand Down Expand Up @@ -422,7 +418,6 @@ describe('MemberDetail', () => {
userEvent.type(screen.getByPlaceholderText(/City/i), formData.city);
userEvent.type(screen.getByPlaceholderText(/Email/i), formData.email);
userEvent.type(screen.getByPlaceholderText(/Phone/i), formData.phoneNumber);
userEvent.click(screen.getByPlaceholderText(/adminApproved/i));
userEvent.click(screen.getByPlaceholderText(/pluginCreationAllowed/i));
userEvent.selectOptions(screen.getByTestId('applangcode'), 'Français');
userEvent.upload(screen.getByLabelText(/Display Image:/i), formData.image);
Expand Down Expand Up @@ -588,46 +583,6 @@ describe('MemberDetail', () => {
waitFor(() => userEvent.click(screen.getByText(/Edit Profile/i)));
});

test('should show Yes if plugin creation is allowed and admin approved', async () => {
const props = {
id: 'rishav-jha-mech',
};
render(
<MockedProvider addTypename={false} link={link2}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<MemberDetail {...props} />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>,
);
waitFor(() =>
expect(screen.getByTestId('adminApproved')).toHaveTextContent('Yes'),
);
});

test('should show No if plugin creation is not allowed and not admin approved', async () => {
const props = {
id: 'rishav-jha-mech',
};
render(
<MockedProvider addTypename={false} link={link2}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<MemberDetail {...props} />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>,
);

waitFor(() => {
expect(screen.getByTestId('adminApproved')).toHaveTextContent('No');
});
});
test('should be redirected to / if member id is undefined', async () => {
render(
<MockedProvider addTypename={false} link={link2}>
Expand Down
16 changes: 0 additions & 16 deletions src/screens/MemberDetail/MemberDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
city: '',
country: '',
pluginCreationAllowed: false,
adminApproved: false,
});
// Handle date change
const handleDateChange = (date: Dayjs | null): void => {
Expand Down Expand Up @@ -98,7 +97,6 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
city: userData?.user?.address?.city,
country: userData?.user?.address?.countryCode,
pluginCreationAllowed: userData?.appUserProfile?.pluginCreationAllowed,
adminApproved: userData?.appUserProfile?.adminApproved,
image: userData?.user?.image || '',
});
}
Expand Down Expand Up @@ -471,20 +469,6 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
</div>
<div className="p-3">
<div className="toggles">
<div className="d-flex flex-row">
<input
type="checkbox"
name="adminApproved"
className={`mx-2 ${styles.noOutline}`}
checked={formState.adminApproved}
onChange={handleToggleChange} // API not supporting this feature
data-testid="adminApproved"
placeholder="adminApproved"
/>
<p className="p-0 m-0">
{`${t('adminApproved')} (API not supported yet)`}
</p>
</div>
<div className="d-flex flex-row">
<input
type="checkbox"
Expand Down
Loading
Loading