Skip to content

Add ability to clone personal vault items#734

Merged
vincentsalucci merged 6 commits intomasterfrom
feature-clone-item-android
Feb 18, 2020
Merged

Add ability to clone personal vault items#734
vincentsalucci merged 6 commits intomasterfrom
feature-clone-item-android

Conversation

@vincentsalucci
Copy link
Member

Objective

  • Add ability to clone personal vault items on both iOS and Android
  • Place 'Clone' option in the respective action sheet/dropdown
  • Do not allow cloning of items owned by the organization
  • Attachments, Delete, and Share are not allowable actions during the clone flow
  • Allow ownership and collection assignment

Code Changes

  • AddEditPage.xaml: Adjusted conditional for when to show ownership options.
  • AddEditPage.xaml.cs: Added a clone mode boolean along with an instance of ViewPage into the constructor. Assigned above fields to the view model instance and adjusted visibility of toolbar items.
  • AddEditPageViewModel.cs: Added CloneMode property. Added AllowOwnershipChanges property that includes clone mode and preservers original conditional of not being in edit mode. Adjusted ShowCollections property to include clone mode. Added ViewPage property that is used to update existing instance of the ViewPage with the newly clone cipher ID. Adjusted load/submit procedures to handle Clone mode existence.
  • ViewPage.xaml: Added 'Clone' toolbar item
  • ViewPage.xaml.cs: Added Clone_Clicked function which is triggered via toolbar item click. Adjusted toolbar items when More_Clicked is fired and when AdjustToolbar is called.
  • AppResources.resx: Added 'Clone' string

Android Images

android-0-view-overflow-clone
android-1-clone-top
android-2-clone-bottom-self-owned
android-3-clone-bottom-org-owned
android-4-clone-success
android-5-org-item-no-clone

iOS Images

ios-0-view-overflow-clone
ios-1-clone-top
ios-2-clone-bottom-self-owned
ios-3-clone-bottom-org-owned
ios-4-clone-success-to-org
ios-5-org-item-no-clone

@vincentsalucci
Copy link
Member Author

@kspearrin The majority of the changes within this PR are format changes. I ran the basic formatting command within Rider and the shown output is the result: we may need to link up our formatting settings (I know @mportune-bw has been slowly crafting his setup in response to your feedback).

AppResources.Designer - I did not manually touch this file. Is this something that needs to be ignored or is this expected when adjusting a string?

AppOptions appOptions = null)
AppOptions appOptions = null,
bool cloneMode = false,
ViewPage viewPage = null)
Copy link
Member Author

@vincentsalucci vincentsalucci Feb 16, 2020

Choose a reason for hiding this comment

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

@kspearrin Is this how you envisioned the instance of ViewPage being passed into the constructor?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, looks good

Copy link
Member

@kspearrin kspearrin left a comment

Choose a reason for hiding this comment

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

A lot of formatting issues. I stopped commenting on them after I realized there were so many. We need to figure this out. Hard to see where the real changes are.

var options = new List<string> { AppResources.Attachments };
if(_vm.EditMode)

var options = new List<string> {AppResources.Attachments};
Copy link
Member

Choose a reason for hiding this comment

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

This formatting change isn't correct. Did your IDE do this?

else if(Device.RuntimePlatform == Device.Android &&
!_deviceActionService.AutofillAccessibilityServiceRunning() &&
!_deviceActionService.AutofillServiceEnabled())
!_deviceActionService.AutofillAccessibilityServiceRunning() &&
Copy link
Member

Choose a reason for hiding this comment

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

same, shouldn't format like this

{
return;
}

Copy link
Member

Choose a reason for hiding this comment

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

are you adding all of these new lines?

{
nameof(ShowPasswordIcon)
});
additionalPropertyNames: new string[] {nameof(ShowPasswordIcon)});
Copy link
Member

Choose a reason for hiding this comment

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

we need to fix all of this formatting. this isn't right


public bool ShowCollections => (!EditMode || CloneMode) && Cipher.OrganizationId != null;
public bool EditMode => !string.IsNullOrWhiteSpace(CipherId);
public bool ShowOwnershipOptions => (!EditMode || CloneMode);
Copy link
Member

Choose a reason for hiding this comment

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

Don't need parens here

@kspearrin
Copy link
Member

AppResources.Designer - I did not manually touch this file. Is this something that needs to be ignored or is this expected when adjusting a string?

Yes, that is expected.

{
if(CloneMode && ViewPage != null)
{
ViewPage.ViewModel.CipherId = this.Cipher.Id;
Copy link
Member

Choose a reason for hiding this comment

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

Let's make a public method on the ViewPage that lets you pass in the new id. Then you can set the ViewModel and the private _cipherId member as well.

-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this formatting all changed. I guess something Rider did? Does Rider have a resx editor or did you have to modify this file manually?

Copy link
Member Author

Choose a reason for hiding this comment

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

Rider did do this, but I believe its because it exceeded the line length.


public ViewPageViewModel ViewModel => _vm;

public void updateCipherId(string cipherId)
Copy link
Member

Choose a reason for hiding this comment

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

Method names in c# are PascalCased.

{
if(CloneMode)
{
ViewPage?.updateCipherId(this.Cipher.Id);
Copy link
Member

Choose a reason for hiding this comment

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

need to update it here too. this wont compile anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants