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

Feat/duplication #1180

Draft
wants to merge 19 commits into
base: doryphore-dev
Choose a base branch
from
Draft

Feat/duplication #1180

wants to merge 19 commits into from

Conversation

mrflos
Copy link
Contributor

@mrflos mrflos commented Jul 1, 2024

Description of pull request / Description de la demande d'ajout

90% finished feature of duplication of pages/lists in same wiki or to external wikis

After rebase from doryphore-dev i had some strange bugs, i tried to fix them, hopefully i got them all.

You can test the duplication feature on another wiki by giving url local dev url as url for duplication (it will use the api roads instead of the controller).

Sorry for the quite big codebase changes...

Edit: i can see what when wrong : there are two other beta-features included : an image optimizer, and extra-fields feature (that add comments and reactions to bazarlist if needed)
I will check if everything is working as expected, as it should also be reviewed, or do you prefer separated PRs ?

@mrflos mrflos requested a review from seballot July 1, 2024 10:29
@mrflos mrflos marked this pull request as draft July 1, 2024 10:30
javascripts/handlers/duplicate.js Dismissed Show dismissed Hide dismissed
javascripts/handlers/duplicate.js Fixed Show fixed Hide fixed
Copy link
Contributor

@seballot seballot left a comment

Choose a reason for hiding this comment

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

WIP review, j'ai l'impression que github a perdu la moitié de mes commentaires..

-> edit c'est bon il les a gardé, je continue alors

Comment on lines +77 to +79
<button name="duplicate-action" value="open" type="submit" class="btn btn-primary"><i class="fa fa-eye-open"></i>{{ _t('DUPLICATE_AND_OPEN') }}</button>
<button name="duplicate-action" value="edit" type="submit" class="btn btn-primary"><i class="fa fa-pencil-alt"></i> {{ _t('DUPLICATE_AND_EDIT') }}</button>
<button name="duplicate-action" value="return" type="submit" class="btn btn-primary"><i class="fa fa-arrow-left"></i> {{ _t('DUPLICATE_AND_RETURN') }}</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

Je trouve que ça complique l'interface d'avoir ces trois boutons, sans apporter de grand bénéfice à l'utilisateur

image

Je pense qu'on devrait toujours faire "duplicate & afficher" (pas besoin d'icone), et si ils veulent éditer ben ils cliquent éditer, si ils veulent revenir en arrière ils cliquent le bouton dédié dans le navigateur

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok je demande l'avis de @furax37 au cas ou, mais pas d'objection

]);
} elseif (!$this->getService(AclService::class)->hasAccess('read', $this->wiki->GetPageTag())) {
// if no read access to the page
if ($contenu = $this->getService(PageManager::class)->getOne("PageLogin")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

le gars fait la description de sa PR en anglais mais utilise du francais dans le code, gnahaha :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

un peu de french touch dans la codebase!

handlers/DuplicateHandler.php Show resolved Hide resolved
$duplicationManager = $this->getService(DuplicationManager::class);
try {
$duplicationManager->importDistantContent($tag, $request);
} catch (\Throwable $th) {
Copy link
Contributor

Choose a reason for hiding this comment

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

pour info comme y'a un use Throwable y'a pas besoin du \

@@ -16,14 +16,13 @@
use YesWiki\Core\Service\AclService;
use YesWiki\Core\Service\ArchiveService;
use YesWiki\Core\Service\CommentService;
use YesWiki\Core\Service\DbService;
Copy link
Contributor

Choose a reason for hiding this comment

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

c'est une erreur d'avoir retiré cet import, c'est utilisé. J'ai fait un fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

je croies que j'avais corrigé ca et le missing { mais j'ai pas du bien reprendre mon commit lors du cherry-pick

// find fields that are textareas
foreach ($form['prepared'] as $field) {
if ($field instanceof TextareaField or $field instanceof ImageField or $field instanceof FileField) {
$fields[] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

je pense qu'il vaudrait mieux retourner le $field entrier, plutot que ce tableau avec juste ID et TYPE, comme ça on sait ce que contient la variable juste avec le nom (un $field c'est un BazarField, pas un array [id, type]) et aussi plus loin dans le code ça évite des check un foireux du genre $field[type] == 'image', c'est mieux de refaire un $field instance of ImageField

Copy link
Contributor

Choose a reason for hiding this comment

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

heu cette classe est pas utilisée non? on dirait que les function sont déjà dans DuplicateManager

@@ -298,6 +297,7 @@ public function deleteOrphaned($tag)
$this->dbService->query("DELETE FROM {$this->dbService->prefixTable('links')} WHERE from_tag='{$this->dbService->escape($tag)}' ");
$this->dbService->query("DELETE FROM {$this->dbService->prefixTable('acls')} WHERE page_tag='{$this->dbService->escape($tag)}' ");
$this->dbService->query("DELETE FROM {$this->dbService->prefixTable('triples')} WHERE `resource`='{$this->dbService->escape($tag)}' and `property`='" . TripleStore::TYPE_URI . "' and `value`='" . EntryManager::TRIPLES_ENTRY_ID . "'");
$this->dbService->query("DELETE FROM {$this->dbService->prefixTable('triples')} WHERE `resource`='{$this->dbService->escape($tag)}' and `property`='" . TripleStore::TYPE_URI . "' and `value`='" . EntryManager::TRIPLES_ENTRY_ID . "'");
Copy link
Contributor

Choose a reason for hiding this comment

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

pourquoi avoir dupliqué cette ligne?? si y'a une raison spécifique mieux vaut ajouter un commentaire pour expliquer parce ça fait bizarre :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

je pense que c'est mon rebase foireux, il a du prendre les deux

}, $pages);

return $pages;
}

private function duplicate($sourceTag, $destinationTag): bool
Copy link
Contributor

Choose a reason for hiding this comment

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

?? un code de test? à supprimer non?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

non je voulais creer une methode dans le PageManager, mais work in progress

function handleLoginResponse(data) {
if (data.isAdmin === true) {
$('#login-message').html(_t('CONNECTED_AS_ADMIN', { user: data.user })).parents('.form-group')
.removeClass('has-error')
Copy link
Contributor

Choose a reason for hiding this comment

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

ah ah, old school ! on a VueJs maintenant hein :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

je veux bien tenter une conversion en vue, mais je sens qu'il va falloir charger une lib pour les requetes ajax, mettre des methodes a la con etc, mais bon pourquoi pas.

Copy link
Contributor

Choose a reason for hiding this comment

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

non non laisse ton code comme ça, maintenant qu'il est écrit ne va pas passer du temps à déjà le refactor !

Copy link
Contributor

@seballot seballot left a comment

Choose a reason for hiding this comment

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

Yo !

top tout ça !

J'ai fait des petites remarques pour la forme, mais c'est pas du tout bloquant. y'a 2/3 commentaires à fixer cependant

J'ai poussé les petit fix, plus un passage de linter (ils étaient pas en place quand tu as commencé le boulot sur cette branche)

<div class="form-group">
<label for="urlWiki" class="control-label">{{ _t('WIKI_URL') }}</label>
<div class="input-group">
<input required type="url" class="form-control" id="urlWiki" name="urlWiki" placeholder="{{ _t('WIKI_URL') }}" value="" />
Copy link
Contributor

Choose a reason for hiding this comment

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

normalement on utilise du dash case pour les id aussi url-wiki

@@ -1180,4 +1180,11 @@ function ($attributeName) {

return $entriesIds;
}

private function duplicate($sourceTag, $destinationTag): bool
Copy link
Contributor

Choose a reason for hiding this comment

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

pareil, test code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pareil methode de service non existante encore..

@@ -417,4 +417,3 @@ private function getExternalUrlsFromIds(?string $ids)

return $externalIds;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

petite boulette manque le } maintenant ! j'ai fixé :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

j'avais corrigé ailleurs ca.. mais merci pour le fix

@@ -36,6 +36,11 @@
</td>
<td>{{ key }}</td>
<td>
{% if list.canDuplicate %}
<a class="btn btn-default btn-xs" href="{{ url({ params: { vue: 'listes', action: 'duplicate', idliste: key }}) }}">
<i class="far fa-clone"></i>
Copy link
Contributor

Choose a reason for hiding this comment

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

On est d'accord c'est pas encore implémenté la duplication de liste? en tout cas chez moi ça marche pas :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oui ca vient

if (btnAction == 'open') {
location = `${shortUrl}/?${data.pageTag}`
} else if (btnAction == 'edit') {
location = `${shortUrl}/?${data.pageTag}/edit`

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
@mrflos
Copy link
Contributor Author

mrflos commented Jul 1, 2024

Ok merci pour cette revue, je vais tout prendre en compte, sauf peut etre la re--ecriture jquery vers vuejs, je ferai que si j'ai du temps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants