Skip to content

Commit

Permalink
feat: update default content
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud committed Feb 11, 2025
1 parent 8260296 commit 853b636
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/deckDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ describe('Deck dashboard', function() {
.should($el => expect($el.text().trim()).to.equal('Upcoming cards'))
})

it('Can see the default "Personal Board" created for user by default', function() {
it('Can see the default "Welcome Board" created for user by default', function() {
cy.visit('/apps/deck')

const defaultBoard = 'Personal'
const defaultBoard = 'Welcome to Nextcloud Deck!'

cy.get('.app-navigation-entry-wrapper[icon=icon-deck]')
.find('ul.app-navigation-entry__children .app-navigation-entry:contains(' + defaultBoard + ')')
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/Middleware/DefaultBoardMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
public function beforeController($controller, $methodName) {
try {
if ($this->userId !== null && $this->defaultBoardService->checkFirstRun($this->userId) && $this->permissionService->canCreate()) {
$this->defaultBoardService->createDefaultBoard($this->l10n->t('Personal'), $this->userId, '0087C5');
$this->defaultBoardService->createDefaultBoard($this->l10n->t('Welcome to Nextcloud Deck!'), $this->userId, 'bf678b');
}
} catch (\Throwable $e) {
$this->logger->error('Could not create default board', ['exception' => $e]);
Expand Down
63 changes: 57 additions & 6 deletions lib/Service/DefaultBoardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

use OCA\Deck\AppInfo\Application;
use OCA\Deck\BadRequestException;
use OCA\Deck\Db\Board;
use OCA\Deck\Db\BoardMapper;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\PreConditionNotMetException;

class DefaultBoardService {
Expand All @@ -21,6 +23,8 @@ class DefaultBoardService {
private $cardService;
private $config;
private $l10n;
private LabelService $labelService;
private AttachmentService $attachmentService;

public function __construct(
IL10N $l10n,
Expand All @@ -29,13 +33,17 @@ public function __construct(
StackService $stackService,
CardService $cardService,
IConfig $config,
LabelService $labelService,
AttachmentService $attachmentService,
) {
$this->boardService = $boardService;
$this->stackService = $stackService;
$this->cardService = $cardService;
$this->config = $config;
$this->boardMapper = $boardMapper;
$this->l10n = $l10n;
$this->labelService = $labelService;
$this->attachmentService = $attachmentService;
}

/**
Expand Down Expand Up @@ -71,19 +79,62 @@ public function checkFirstRun($userId): bool {
* @throws BadRequestException
*/
public function createDefaultBoard(string $title, string $userId, string $color) {
/** @var Board $defaultBoard */
$defaultBoard = $this->boardService->create($title, $userId, $color);
$defaultStacks = [];
$defaultCards = [];

$boardId = $defaultBoard->getId();

$defaultStacks[] = $this->stackService->create($this->l10n->t('To do'), $boardId, 1);
$defaultStacks[] = $this->stackService->create($this->l10n->t('Doing'), $boardId, 1);
$defaultStacks[] = $this->stackService->create($this->l10n->t('Done'), $boardId, 1);
$defaultStacks[] = $this->stackService->create(
$this->l10n->t('Custom lists - click to rename!'),
$boardId,
0
);
$defaultStacks[] = $this->stackService->create($this->l10n->t('Todo'), $boardId, 1);
$defaultStacks[] = $this->stackService->create($this->l10n->t('In Progress'), $boardId, 2);
$defaultStacks[] = $this->stackService->create($this->l10n->t('Done'), $boardId, 3);

$defaultCards[] = $this->cardService->create($this->l10n->t('Example Task 3'), $defaultStacks[0]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create($this->l10n->t('Example Task 2'), $defaultStacks[1]->getId(), 'text', 0, $userId);
$defaultCards[] = $this->cardService->create($this->l10n->t('Example Task 1'), $defaultStacks[2]->getId(), 'text', 0, $userId);
$readMoreLabel = $this->labelService->create('Read more inside', 'CC317C', $boardId);
$defaultLabels = $defaultBoard->getLabels();

$actionLabel = null;
foreach ($defaultLabels as $label) {
if ($label->getTitle() === 'Action needed') {
$actionLabel = $label;
break;
}
}

$cardsDataJson = file_get_contents(__DIR__ . '/fixtures/default-cards.json');
$cardsData = json_decode($cardsDataJson, true);

foreach ($cardsData as $cardData) {
$stackIndex = $cardData['stackIndex'];
$defaultCards[] = $this->cardService->create(
$this->l10n->t($cardData['title']),
$defaultStacks[$stackIndex]->getId(),
'text',
0,
$userId,
$cardData['description'],
);
}

foreach ($defaultCards as $card) {
$this->cardService->assignLabel($card->getId(), $readMoreLabel->getId());
}

$firstCard = $this->cardService->create(
$this->l10n->t('Create your first card!'),
$defaultStacks[1]->getId(),
'text',
1,
$userId
);
$this->cardService->assignLabel($firstCard->getId(), $actionLabel->getId());

$this->attachmentService->create($defaultCards[2]->getId(), 'file', 'DEFAULT_SAMPLE_FILE');

return $defaultBoard;
}
Expand Down
10 changes: 9 additions & 1 deletion lib/Service/FilesAppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,15 @@ public function display(Attachment $attachment) {
}

public function create(Attachment $attachment) {
$file = $this->getUploadedFile();
if ($attachment->getData() === 'DEFAULT_SAMPLE_FILE' && !$this->request->getUploadedFile('file')) {
$file = [
'name' => 'Nextcloud sample image - add your image here!.jpg',
'tmp_name' => __DIR__ . '/../../img/Nextcloud sample image - add your image here!.jpg',
];
} else {
$file = $this->getUploadedFile();
}

$fileName = $file['name'];

// get shares for current card
Expand Down
22 changes: 22 additions & 0 deletions lib/Service/fixtures/default-cards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"stackIndex": 0,
"title": "1. Open to learn more about boards and cards",
"description": "## Welcome to Nextcloud Deck!\n\nNextcloud Deck is a kanban style project management app that integrates seamlessly with the Nextcloud ecosystem. Here, you can create and manage boards to streamline your projects and organize project tasks visually using cards. A versatile tool, Nextcloud Deck will help you stay efficient in both personal and collaborative settings!\n\n### \ud83d\udccc How to set up a new board?\n\nAdd a new board via the \u201c+\u201d button or \u201cAdd board\u201d. Name your board and add a description to clarify its purpose if you wish.\n\nAdd task lists to your board via \u201cAdd List\u201d (e.g., \"To Do\"). Add cards to these lists to represent individual tasks or items. Organize your cards visually by assigning labels or colors.\n\nManage your board list: In the board menu next to the board name, you can edit, clone, archive and export your boards.\n\n### \ud83d\uddc2\ufe0f How to create and edit task cards?\n\nAdd cards via the \u201c+\u201d button on top of the list of your choice. Name your card and add a description using the available rich text formatting instruments.\n\nSet a due date to track deadlines and add responsible team members. Label your cards with tags for better navigation. You can create and manage tags in the sidebar, which is accessible via the toolbar button.\n\n### \ud83d\udca1Useful tips for Nextcloud Deck\n\n- Integrate Nextcloud Deck with Nextcloud Calendar and track the upcoming card deadlines.\n- Use comments to keep discussions around a task within its dedicated card.\n- Enable Nextcloud Deck notifications to always stay updated on changes to your boards."
},
{
"stackIndex": 1,
"title": "2. Drag cards left and right, up and down",
"description": "## \ud83d\udea6 Manage your boards and cards\n\nDrag your cards around the board to change position in the list or move them to other lists.\n\nArchive cards to remove them from the board without losing your content. You can always access archived cards and put them back by going to \"Show archived cards\" in the board menu.\n\nUse tags to assign types, statuses and other special attributes to your cards to aid visual navigation. Open the \"Tags\" tab in the sidebar of Nextcloud Deck to manage tags you can add to your cards.\n\n## \ud83d\udc53 Change how you view your boards\n\nTo navigate large boards easily, you can filter your cards by tags, team members, statuses and due dates. Open filter menu via Nextcloud Deck toolbar.\n\nEnable compact display mode in the Deck Board menu via the three dots menu in the toolbar. In the same menu, you can disable and enable cover images."
},
{
"stackIndex": 2,
"title": "3. Apply rich formatting and link content",
"description": "## \ud83c\udfa8 Make use of rich formatting in card descriptions\n\nYou can use various instruments to make your content more structured and informative. Try all the instruments yourself - use this checklist!\n\n- [ ] Apply headings of different hierarchy (H1-H6).\n- [ ] Use **bold** *italic* __underline__ and ~~strikethrough~~ text formatting.\n- [ ] Create unordered, ordered and to-do lists.\n- [ ] Highlight code and blockquotes, add various illustrated callouts.\n- [ ] Create and format tables\n- [ ] Add details\n- [ ] Add links, for example to [the Nextcloud website](https:\/\/nextcloud.com\/)\n- [ ] Insert attachments\n- [ ] Add emojis \ud83d\udd76\ufe0f \n\n## \ud83d\udd17 Attach files to cards\n\nYou can upload any files from your machine or pick from your Nextcloud Files, such as documents, presentations, images, video clips and anything else. Add files via \"Attachments\" tab.\n\n## \ud83c\udf04 Illustrate cards with images\n\nAttach images to your cards - they will automatically work as card covers."
},
{
"stackIndex": 3,
"title": "4. Share, comment and collaborate!",
"description": "## \ud83e\udd1d How to collaborate in your board?\n\nShare your cards and boards with others. In many Nextcloud apps, linked Nextcloud Deck items will appear as rich, interactive widgets. Once you assign someone to a card, they will receive a notification.\n\nEdit cards together, leave notes for your teammates, share task-related files by adding attachments and discuss your tasks using card comments.\n\n### "
}
]

0 comments on commit 853b636

Please sign in to comment.