Skip to content

Commit

Permalink
Adjust expiration logic for shares to account for share attributes re…
Browse files Browse the repository at this point in the history
…gistered with apps
  • Loading branch information
mrow4a committed Jan 18, 2020
1 parent e5666c8 commit 1c1dc1b
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 276 deletions.
151 changes: 52 additions & 99 deletions apps/files_sharing/css/sharetabview.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,58 @@
margin-right: 0;
}

#shareWithList {
list-style-type: none;
padding : 0 0 16px;
}

#shareWithList li {
padding-top : 5px;
padding-bottom: 5px;
font-weight : bold;
white-space : normal;
}

#shareWithList .unshare img {
vertical-align: text-bottom;
/* properly align icons */
}

#shareWithList label input[type=checkbox] {
margin-left: 0;
position : relative;
}

#shareWithList .username {
padding-right : 8px;
white-space : nowrap;
text-overflow : ellipsis;
max-width : 254px;
display : inline-block;
overflow : hidden;
vertical-align: middle;
}

#shareWithList li label {
margin-right: 8px;
}

#shareWithList .expiration {
max-width: 190px;
text-align: left;
margin: 0 0 0 5px;
}

#shareWithList .removeExpiration {
text-indent: -9999px;
border: 0 none;
transform: translate(calc(-100% - 5px), -1px);
background-color: #F8F8F8;
background-position: center;
background-repeat: no-repeat;
background-image: url('../../../core/img/actions/close.svg');
}

#shareDialogLinkList .link-shares + #shareTreeUserGroupList {
margin-top: -20px;
}
Expand Down Expand Up @@ -99,15 +151,6 @@
background-size: 16px 16px;
}

.shareTabView .action-item {
display: inherit;
opacity: .5;
}

.shareTabView .action-item + .action-item {
margin-left: 5px;
}

.shareTabView .privacyWarningMessage {
margin-top: 20px;
}
Expand Down Expand Up @@ -316,94 +359,4 @@
color: red;
padding: 4px;
display: block;
}

/* ---------------------------------------------------- ShareWithList --- */

.shareWithList {
list-style-type : none;
padding : 0 0 16px;
}

[class^='shareWithList__item'] {
display : flex;
justify-content : space-between;
flex-wrap : wrap;
padding-top : 10px;
padding-bottom : 10px;
font-weight : bold;
}

.shareWithList__item--detailed {
background-color: #f8f8f8;
margin-left: -15px;
margin-right: -15px;
padding: 10px 15px;
}

.shareWithList__item--detailed + .shareWithList__item--detailed {
border-top: 1px solid #eee
}

[class^='shareWithList__container'] {
display : flex;
align-items : center;
}

.shareWithList__container--left {
justify-content: flex-start;
}

.shareWithList__container--right {
justify-content: flex-end;
}

.shareWithList__item label input[type=checkbox] {
margin-left: 0;
position : relative;
}

.shareWithList__item .username {
padding-right : 8px;
white-space : nowrap;
text-overflow : ellipsis;
max-width : 254px;
display : inline-block;
overflow : hidden;
vertical-align: middle;
}

.shareWithList__item label {
margin-right: 8px;
}

.shareWithList__item .expiration {
max-width: 190px;
text-align: left;
margin: 0 0 0 5px;
}

.shareWithList__item .removeExpiration {
text-indent: -9999px;
border: 0 none;
transform: translate(calc(-100% - 5px), -1px);
background-color: #F8F8F8;
background-position: center;
background-repeat: no-repeat;
background-image: url('../../../core/img/actions/close.svg');
}

.shareWithList__item .toggleShareDetails {
display: inherit;
opacity: 0.5;
}

.shareWithList__details {
width: 100%;
background-color: #f8f8f8;
}

.shareWithList__details-group:first-of-type,
.shareWithList__details-group + .shareWithList__details-group {
margin-top: 10px;
}
35 changes: 19 additions & 16 deletions apps/files_sharing/lib/Controller/Share20OcsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ public function createShare() {
$share->setShareType($shareType);
$share->setSharedBy($this->userSession->getUser()->getUID());

$share = $this->setShareAttributes($share, $this->request->getParam('attributes', null));
// set attributes array from request, or if not provided set empty array
$share = $this->setShareAttributes($share, $this->request->getParam('attributes', []));

try {
$share = $this->shareManager->createShare($share);
Expand Down Expand Up @@ -846,7 +847,11 @@ public function updateShare($id) {
$share->setExpirationDate($expireDate);
}

$share = $this->setShareAttributes($share, $this->request->getParam('attributes', null));
// update attributes if provided
$newAttributes = $this->request->getParam('attributes', null);
if ($newAttributes !== null) {
$share = $this->setShareAttributes($share, $newAttributes);
}

try {
$share = $this->shareManager->updateShare($share);
Expand Down Expand Up @@ -1113,24 +1118,22 @@ private function getShareById($id, $recipient = null) {

/**
* @param IShare $share
* @param string[][]|null $formattedShareAttributes
* @param string[][] $formattedShareAttributes
* @return IShare modified share
*/
private function setShareAttributes(IShare $share, $formattedShareAttributes) {
$newShareAttributes = $this->shareManager->newShare()->newAttributes();
if ($formattedShareAttributes !== null) {
foreach ($formattedShareAttributes as $formattedAttr) {
$value = isset($formattedAttr['value']) ? $formattedAttr['value'] : null;
if (isset($formattedAttr['enabled'])) {
$value = (bool) \json_decode($formattedAttr['enabled']);
}
if ($value !== null) {
$newShareAttributes->setAttribute(
$formattedAttr['scope'],
$formattedAttr['key'],
$value
);
}
foreach ($formattedShareAttributes as $formattedAttr) {
$value = isset($formattedAttr['value']) ? $formattedAttr['value'] : null;
if (isset($formattedAttr['enabled'])) {
$value = (bool) \json_decode($formattedAttr['enabled']);
}
if ($value !== null) {
$newShareAttributes->setAttribute(
$formattedAttr['scope'],
$formattedAttr['key'],
$value
);
}
}
$share->setAttributes($newShareAttributes);
Expand Down
44 changes: 42 additions & 2 deletions core/css/share.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
left: 20px;
}
}

.shareTabView .unshare.icon-loading-small {
margin-top: 1px;
}
Expand Down Expand Up @@ -95,6 +94,13 @@
padding: 8px;
}

#shareWithList li {
padding-top: 10px;
padding-bottom: 10px;
font-weight: bold;
line-height: 21px;
white-space: normal;
}
#shareWithList .shareOption {
white-space: nowrap;
display: inline-block;
Expand Down Expand Up @@ -134,6 +140,37 @@
margin: 0 3px 0 8px;
vertical-align: middle;
}
a.showCruds {
display: inline;
opacity: 0.5;
}

a.unshare {
display: inline;
float: right;
opacity: 0.5;
padding: 10px;
margin-top: -5px;
margin-right: -10px;
}

a.time {
display: inline;
float: right;
opacity: 0.5;
padding: 10px;
margin-top: -5px;
margin-right: -10px;
}

a.toggleShareDetails {
display: inline;
float: right;
opacity: 0.5;
padding: 10px;
margin-top: -5px;
margin-right: -10px;
}

#link {
border-top: 1px solid #ddd;
Expand Down Expand Up @@ -178,6 +215,9 @@ a.showCruds:hover,
a.unshare:hover {
opacity: 1;
}
a.toggleShareDetails:hover {
opacity: 1;
}
#defaultExpireMessage,
/* fix expire message going out of box */
.reshare {
Expand Down Expand Up @@ -264,4 +304,4 @@ a.unshare:hover {

.select2-container-multi .select2-choices .select2-search-choice {
padding: 3px 18px 3px 5px;
}
}
Loading

0 comments on commit 1c1dc1b

Please sign in to comment.