Skip to content

Commit

Permalink
Making a couple more minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
snake14 committed Nov 20, 2024
1 parent 23d04dc commit b9aa22a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 15 deletions.
6 changes: 6 additions & 0 deletions Dao/BaseDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ protected function incrementNameWithNumber(string $name): string
++$number;
$newName = str_replace($matches[0], '', $name);
}

// Make sure that we don't exceed the max length of 255 characters
if (strlen($newName . " ($number)") > 255) {
$newName = substr($newName, 0, 251);
}

$newName .= " ($number)";

return $newName;
Expand Down
10 changes: 10 additions & 0 deletions tests/Integration/Dao/TagsDaoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -685,10 +685,15 @@ public function testMakeCopyNameUnique(string $name, array $tags, string $expect
if ($number < 1) {
$tempName = "FooTag";
}

if ($tags == [0] && strpos($name, 'FooTag') === false) {
$tempName = $name;
}
$this->createTag($idSite, $idContainerVersion, $tempName);
}

$updatedName = $this->dao->makeCopyNameUnique($idSite, $name, $idContainerVersion);
$this->assertLessThanOrEqual(255, strlen($updatedName), 'The name should not exceed the 255 characters');
$this->assertSame($expected, $updatedName);
}

Expand All @@ -714,6 +719,11 @@ public function getMakeCopyNameUniqueTestData(): array
['FooTag(1)', [1, 2, 3], 'FooTag(1)'],
['SomeOtherName', [1, 2, 3], 'SomeOtherName'],
['SomeOtherName (1)', [1, 2, 3], 'SomeOtherName (1)'],
[
'Test tag with a really long name. Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcde',
[0],
'Test tag with a really long name. Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890Abcdefghijklmnopqrstuvwxyz1234567890A (1)'
],
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/UI/ContainerTag_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ describe("ContainerTag", function () {
await page.goto(container1Base);
await clickFirstRowTableAction('icon-content-copy', 3);
await page.evaluate(() => $('div.copyMtmObjectDialog button.btn').click());
await page.waitForTimeout(250);
await page.waitForNetworkIdle();
await capture.page(page, 'copy_tag_success');
});
});
24 changes: 13 additions & 11 deletions vue/dist/TagManager.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -10741,18 +10741,18 @@ function getCircularReplacer() {
Debuggingvue_type_script_lang_ts.render = Debuggingvue_type_template_id_1ae9acce_render

/* harmony default export */ var Debugging = (Debuggingvue_type_script_lang_ts);
// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/TagManager/vue/src/CopyDialog/CopyDialog.vue?vue&type=template&id=3dbbf457
// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-babel/node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/@vue/cli-plugin-babel/node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist/templateLoader.js??ref--6!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/TagManager/vue/src/CopyDialog/CopyDialog.vue?vue&type=template&id=46b30588

var CopyDialogvue_type_template_id_3dbbf457_hoisted_1 = {
var CopyDialogvue_type_template_id_46b30588_hoisted_1 = {
class: "copyMtmObjectDialog"
};
var CopyDialogvue_type_template_id_3dbbf457_hoisted_2 = ["innerHTML"];
function CopyDialogvue_type_template_id_3dbbf457_render(_ctx, _cache, $props, $setup, $data, $options) {
var CopyDialogvue_type_template_id_46b30588_hoisted_2 = ["innerHTML"];
function CopyDialogvue_type_template_id_46b30588_render(_ctx, _cache, $props, $setup, $data, $options) {
var _component_Field = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveComponent"])("Field");

var _directive_form = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["resolveDirective"])("form");

return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", CopyDialogvue_type_template_id_3dbbf457_hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h2", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.getCopyDialogTitle), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.getCopyDescription), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, {
return Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementBlock"])("div", CopyDialogvue_type_template_id_46b30588_hoisted_1, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("h2", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.getCopyDialogTitle), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("p", null, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.getCopyDescription), 1), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["withDirectives"])(Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("div", null, [Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])(_component_Field, {
uicontrol: "site",
name: "destinationSite",
title: _ctx.translate('TagManager_ChooseWebsite'),
Expand All @@ -10776,14 +10776,14 @@ function CopyDialogvue_type_template_id_3dbbf457_render(_ctx, _cache, $props, $s
key: 1,
class: "copyNote",
innerHTML: _ctx.$sanitize(_ctx.getCopyContainerNote)
}, null, 8, CopyDialogvue_type_template_id_3dbbf457_hoisted_2)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("button", {
}, null, 8, CopyDialogvue_type_template_id_46b30588_hoisted_2)) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createElementVNode"])("button", {
class: "btn",
onClick: _cache[2] || (_cache[2] = function () {
return _ctx.performCopy && _ctx.performCopy.apply(_ctx, arguments);
})
}, Object(external_commonjs_vue_commonjs2_vue_root_Vue_["toDisplayString"])(_ctx.translate('General_Copy')), 1)], 512), [[_directive_form]])]);
}
// CONCATENATED MODULE: ./plugins/TagManager/vue/src/CopyDialog/CopyDialog.vue?vue&type=template&id=3dbbf457
// CONCATENATED MODULE: ./plugins/TagManager/vue/src/CopyDialog/CopyDialog.vue?vue&type=template&id=46b30588

// CONCATENATED MODULE: ./node_modules/@vue/cli-plugin-typescript/node_modules/cache-loader/dist/cjs.js??ref--14-0!./node_modules/babel-loader/lib!./node_modules/@vue/cli-plugin-typescript/node_modules/ts-loader??ref--14-2!./node_modules/@vue/cli-service/node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/@vue/cli-service/node_modules/vue-loader-v16/dist??ref--0-1!./plugins/TagManager/vue/src/CopyDialog/CopyDialog.vue?vue&type=script&lang=ts

Expand Down Expand Up @@ -10950,7 +10950,7 @@ function CopyDialogvue_type_template_id_3dbbf457_render(_ctx, _cache, $props, $s

external_CoreHome_["AjaxHelper"].fetch(requestParams).then(function (response) {
// If there was an issue with the response, display a generic error
if (!response || !response.success || !response.urlToNewCopy) {
if (!response || !response.isSuccess || !response.urlToNewCopy) {
var message = Object(external_CoreHome_["translate"])('General_ErrorRequest', '', '');
var notificationInstanceId = external_CoreHome_["NotificationsStore"].show({
message: message,
Expand All @@ -10959,14 +10959,16 @@ function CopyDialogvue_type_template_id_3dbbf457_render(_ctx, _cache, $props, $s
type: 'transient'
});
external_CoreHome_["NotificationsStore"].scrollToNotification(notificationInstanceId);
window.Piwik_Popover.close();
return;
} // Close the modal, reload the store, and display notification


window.Piwik_Popover.close();

_this2.reloadEntityStore();

_this2.displaySuccessNotification(response.urlToNewCopy);

window.Piwik_Popover.close();
});
},
reloadEntityStore: function reloadEntityStore() {
Expand Down Expand Up @@ -11147,7 +11149,7 @@ function CopyDialogvue_type_template_id_3dbbf457_render(_ctx, _cache, $props, $s



CopyDialogvue_type_script_lang_ts.render = CopyDialogvue_type_template_id_3dbbf457_render
CopyDialogvue_type_script_lang_ts.render = CopyDialogvue_type_template_id_46b30588_render

/* harmony default export */ var CopyDialog = (CopyDialogvue_type_script_lang_ts);
// CONCATENATED MODULE: ./plugins/TagManager/vue/src/index.ts
Expand Down
2 changes: 1 addition & 1 deletion vue/dist/TagManager.umd.min.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions vue/src/CopyDialog/CopyDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export default defineComponent({
AjaxHelper.fetch(requestParams).then((response) => {
// If there was an issue with the response, display a generic error
if (!response || !response.success || !response.urlToNewCopy) {
if (!response || !response.isSuccess || !response.urlToNewCopy) {
const message = translate('General_ErrorRequest', '', '');
const notificationInstanceId = NotificationsStore.show({
message,
Expand All @@ -227,12 +227,15 @@ export default defineComponent({
type: 'transient',
});
NotificationsStore.scrollToNotification(notificationInstanceId);
window.Piwik_Popover.close();
return;
}
// Close the modal, reload the store, and display notification
window.Piwik_Popover.close();
this.reloadEntityStore();
this.displaySuccessNotification(response.urlToNewCopy);
window.Piwik_Popover.close();
});
},
reloadEntityStore() {
Expand Down

0 comments on commit b9aa22a

Please sign in to comment.