mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Conpherence - fix a few bugs
Summary: fixes the "click edit and it clears title" bug. fixes a "upload the same image again and I get nothing" bug by making the create file codepath also copy dimensions if the file already exists, rather than making a copy sans dimensions. fixes the "title is so long it breaks the widget" bug by truncating the text AND adding some CSS to prevent it from happening. Test Plan: messed around with a conpherence. changed the title, changed the picture, changed the crop and all worked. uploaded some long file names and verified they were truncated nicely. Reviewers: epriestley, chad Reviewed By: chad CC: aran, Korvin Maniphest Tasks: T2399 Differential Revision: https://secure.phabricator.com/D5378
This commit is contained in:
parent
1a92976c14
commit
b8c04419f0
4 changed files with 28 additions and 4 deletions
|
@ -77,7 +77,7 @@ final class ConpherenceUpdateController extends
|
||||||
$xactions[] = id(new ConpherenceTransaction())
|
$xactions[] = id(new ConpherenceTransaction())
|
||||||
->setTransactionType(ConpherenceTransactionType::TYPE_PICTURE)
|
->setTransactionType(ConpherenceTransactionType::TYPE_PICTURE)
|
||||||
->setNewValue($orig_file->getPHID());
|
->setNewValue($orig_file->getPHID());
|
||||||
// do 2 transformations "crudely"
|
// do a transformation "crudely"
|
||||||
$xformer = new PhabricatorImageTransformer();
|
$xformer = new PhabricatorImageTransformer();
|
||||||
$header_file = $xformer->executeConpherenceTransform(
|
$header_file = $xformer->executeConpherenceTransform(
|
||||||
$orig_file,
|
$orig_file,
|
||||||
|
@ -105,7 +105,14 @@ final class ConpherenceUpdateController extends
|
||||||
$title = $conpherence->getTitle();
|
$title = $conpherence->getTitle();
|
||||||
$updated = true;
|
$updated = true;
|
||||||
$fancy_ajax_style = false;
|
$fancy_ajax_style = false;
|
||||||
} else if ($top !== null || $left !== null) {
|
}
|
||||||
|
|
||||||
|
// all other metadata updates are continue requests
|
||||||
|
if (!$request->isContinueRequest()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($top !== null || $left !== null) {
|
||||||
$file = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG);
|
$file = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG);
|
||||||
$xformer = new PhabricatorImageTransformer();
|
$xformer = new PhabricatorImageTransformer();
|
||||||
$xformed = $xformer->executeConpherenceTransform(
|
$xformed = $xformer->executeConpherenceTransform(
|
||||||
|
@ -128,7 +135,7 @@ final class ConpherenceUpdateController extends
|
||||||
->setNewValue($title);
|
->setNewValue($title);
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
if (!$updated && $request->isContinueRequest()) {
|
if (!$updated) {
|
||||||
$errors[] = pht(
|
$errors[] = pht(
|
||||||
'That was a non-update. Try cancel.');
|
'That was a non-update. Try cancel.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ final class ConpherenceFileWidgetView extends AphrontView {
|
||||||
'');
|
'');
|
||||||
$file_view = id(new PhabricatorFileLinkView())
|
$file_view = id(new PhabricatorFileLinkView())
|
||||||
->setFilePHID($file->getPHID())
|
->setFilePHID($file->getPHID())
|
||||||
->setFileName($file->getName())
|
->setFileName(phutil_utf8_shorten($file->getName(), 38))
|
||||||
->setFileViewable($file->isViewableImage())
|
->setFileViewable($file->isViewableImage())
|
||||||
->setFileViewURI($file->getBestURI())
|
->setFileViewURI($file->getBestURI())
|
||||||
->setCustomClass('file-title');
|
->setCustomClass('file-title');
|
||||||
|
|
|
@ -165,6 +165,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
||||||
$new_file->setStorageHandle($copy_of_storage_handle);
|
$new_file->setStorageHandle($copy_of_storage_handle);
|
||||||
$new_file->setStorageFormat($copy_of_storage_format);
|
$new_file->setStorageFormat($copy_of_storage_format);
|
||||||
$new_file->setMimeType($copy_of_mimeType);
|
$new_file->setMimeType($copy_of_mimeType);
|
||||||
|
$new_file->copyDimensions($file);
|
||||||
|
|
||||||
$new_file->save();
|
$new_file->save();
|
||||||
|
|
||||||
|
@ -636,6 +637,20 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function copyDimensions(PhabricatorFile $file) {
|
||||||
|
$metadata = $file->getMetadata();
|
||||||
|
$width = idx($metadata, self::METADATA_IMAGE_WIDTH);
|
||||||
|
if ($width) {
|
||||||
|
$this->metadata[self::METADATA_IMAGE_WIDTH] = $width;
|
||||||
|
}
|
||||||
|
$height = idx($metadata, self::METADATA_IMAGE_HEIGHT);
|
||||||
|
if ($height) {
|
||||||
|
$this->metadata[self::METADATA_IMAGE_HEIGHT] = $height;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getMetadataName($metadata) {
|
public static function getMetadataName($metadata) {
|
||||||
switch ($metadata) {
|
switch ($metadata) {
|
||||||
case self::METADATA_IMAGE_WIDTH:
|
case self::METADATA_IMAGE_WIDTH:
|
||||||
|
|
|
@ -87,6 +87,8 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
top: -4px;
|
top: -4px;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
|
overflow-x: hidden;
|
||||||
|
width: 270px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
.conpherence-widget-pane #widgets-files .file-uploaded-by {
|
.conpherence-widget-pane #widgets-files .file-uploaded-by {
|
||||||
|
|
Loading…
Reference in a new issue