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

Remove editing of Matrix credentials from Edit Profile modal #1112

Merged
merged 1 commit into from
Oct 19, 2023
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
2 changes: 0 additions & 2 deletions src/components/edit-profile/container.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ describe('Container', () => {
editProfileState: 0, // Set the initial editProfileState to State.NONE
currentDisplayName: 'John Doe',
currentProfileImage: 'profile.jpg',
currentMatrixId: '',
currentMatrixAccessToken: '',
editProfile: () => null,
startProfileEdit: () => null,
...props,
Expand Down
8 changes: 1 addition & 7 deletions src/components/edit-profile/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export interface Properties extends PublicProperties {
editProfileState: State;
currentDisplayName: string;
currentProfileImage: string;
currentMatrixId: string;
currentMatrixAccessToken: string;
editProfile: (data: { name: string; image: File; matrixId: string; matrixAccessToken: string }) => void;
editProfile: (data: { name: string; image: File }) => void;
startProfileEdit: () => void;
}

Expand All @@ -33,8 +31,6 @@ export class Container extends React.Component<Properties> {
errors: RegistrationContainer.mapErrors(editProfile.errors),
currentDisplayName: user?.data?.profileSummary.firstName,
currentProfileImage: user?.data?.profileSummary.profileImage,
currentMatrixId: user?.data?.matrixId,
currentMatrixAccessToken: user?.data?.matrixAccessToken,
editProfileState: editProfile.state,
};
}
Expand All @@ -56,8 +52,6 @@ export class Container extends React.Component<Properties> {
editProfileState={this.props.editProfileState}
currentDisplayName={this.props.currentDisplayName}
currentProfileImage={this.props.currentProfileImage}
currentMatrixId={this.props.currentMatrixId}
currentMatrixAccessToken={this.props.currentMatrixAccessToken}
/>
);
}
Expand Down
6 changes: 0 additions & 6 deletions src/components/edit-profile/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ describe('EditProfile', () => {
errors: {},
currentDisplayName: 'John Doe',
currentProfileImage: 'profile.jpg',
currentMatrixId: '',
currentMatrixAccessToken: '',
onEdit: () => null,
onClose: () => null,
...props,
Expand Down Expand Up @@ -53,8 +51,6 @@ describe('EditProfile', () => {
expect(onEditMock).toHaveBeenCalledWith({
name: 'John Doe',
image: null,
matrixId: '',
matrixAccessToken: '',
});
});

Expand Down Expand Up @@ -90,8 +86,6 @@ describe('EditProfile', () => {
const formData = {
name: 'Jane Smith',
image: 'new-image.jpg', // note: this is actually supposed to be a nodejs FILE object
matrixId: '',
matrixAccessToken: '',
};

wrapper.find('Input[name="name"]').simulate('change', formData.name);
Expand Down
34 changes: 1 addition & 33 deletions src/components/edit-profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { bem } from '../../lib/bem';
import { ImageUpload } from '../../components/image-upload';
import { IconUpload2, IconXClose } from '@zero-tech/zui/icons';
import { State as EditProfileState } from '../../store/edit-profile';
import { FeatureFlag } from '../feature-flag';

const c = bem('edit-profile');

Expand All @@ -20,40 +19,30 @@ export interface Properties {
};
currentDisplayName: string;
currentProfileImage: string;
currentMatrixId: string;
currentMatrixAccessToken: string;
onEdit: (data: { name: string; image: File; matrixId: string; matrixAccessToken: string }) => void;
onEdit: (data: { name: string; image: File }) => void;
onClose?: () => void;
}

interface State {
name: string;
image: File | null;
matrixId: string;
matrixAccessToken: string;
}

export class EditProfile extends React.Component<Properties, State> {
state = {
name: this.props.currentDisplayName,
image: null,
matrixId: this.props.currentMatrixId,
matrixAccessToken: this.props.currentMatrixAccessToken,
};

handleEdit = () => {
this.props.onEdit({
name: this.state.name,
image: this.state.image,
matrixId: this.state.matrixId,
matrixAccessToken: this.state.matrixAccessToken,
});
};

trackName = (value) => this.setState({ name: value });
trackImage = (image) => this.setState({ image });
trackMatrixId = (matrixId) => this.setState({ matrixId });
trackMatrixAccessToken = (matrixAccessToken) => this.setState({ matrixAccessToken });

get isValid() {
return this.state.name.trim().length > 0;
Expand Down Expand Up @@ -83,10 +72,6 @@ export class EditProfile extends React.Component<Properties, State> {
}

get isDisabled() {
if (this.state.matrixId !== '' && this.state.matrixAccessToken !== '') {
return false;
}

return (
!!this.nameError ||
this.isLoading ||
Expand Down Expand Up @@ -123,23 +108,6 @@ export class EditProfile extends React.Component<Properties, State> {
alert={this.nameError}
className={c('body-input')}
/>

<FeatureFlag featureFlag='enableMatrix'>
<Input
label='Matrix ID'
name='matrix_id'
value={this.state.matrixId}
onChange={this.trackMatrixId}
className={c('body-input')}
/>
<Input
label='Matrix Access Token'
name='access_token'
value={this.state.matrixAccessToken}
onChange={this.trackMatrixAccessToken}
className={c('body-input')}
/>
</FeatureFlag>
</div>
{this.imageError && (
<Alert className={c('alert-large')} variant='error'>
Expand Down
2 changes: 0 additions & 2 deletions src/store/edit-profile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const initialState: EditProfileState = {
export const editProfile = createAction<{
name: string;
image: File | null;
matrixId: string;
matrixAccessToken: string;
}>(SagaActionTypes.EditProfile);

const slice = createSlice({
Expand Down
6 changes: 1 addition & 5 deletions src/store/edit-profile/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { currentUserSelector } from '../authentication/saga';
import { setUser } from '../authentication';

export function* editProfile(action) {
const { name, image, matrixId, matrixAccessToken } = action.payload;
const { name, image } = action.payload;

yield put(setState(State.INPROGRESS));
try {
Expand All @@ -26,10 +26,6 @@ export function* editProfile(action) {
}
}

if (matrixId) {
yield call(saveUserMatrixCredentials, matrixId, matrixAccessToken);
}

const { profileId } = yield select((state) => state.authentication.user.data);
const response = yield call(apiEditUserProfile, {
profileId,
Expand Down