stable

Clone or download

Read-only

Do not display [new document] if user cannot write

Part of story #12447: Modal new document for empty/wiki/link Go to a folder where you don't have permission to create documents (remove write capability). => the [new document] in the header is not displayed. Go to a folder where you have permission to create documents (add write capability). => the [new document] in the header is displayed. Go to an empty folder where you don't have permission to create documents (remove write capability). => the [new document] in the empty state is not displayed. Go to an empty folder where you have permission to create documents (add write capability). => the [new document] in the empty state is displayed. This is a first step, to introduce the current_folder as object in the store, and move actions.js in smaller parts for better understability. A next patch will propose two different empty states: one for writers, one for readers. Implementation note ------------------- Since the display of the empty state depends on both the content of the folder (is it empty?) and the current folder property (has user write capability?), and to limit the number of rest calls (get parents for breadcrumbs, get item for breadcrumbs and title and write capability, get folder content) we need to pass "get item" promise as argument, and wait for its resoution or else ยซPaf! ร‡a fait des Chocapics!ยป. Here is a diagram of the flow before this changeset: (router magic) | | ___ / \ Y / \ N +----------------- root? ---------------------------------------------+ | \ / | | \___/ | | | --------------+------------------- ----------------+----------------------------- -------+-----------------------+-- ------+--------------------------------+------ | | | | +----------+--------------+ +------+---------+ +--------------+---------+ +----------+-----------+ | resetAscendantHierarchy | | loadRootFolder | | loadAscendantHierarchy | | loadFolderContent * | +----------+--------------+ +------+---------+ +---------+--------------+ +----------+-----------+ | | | | | ############### # _______ | | # getProject # < - - - -` / \ +--------+---------+ | ############### | N / \ Y | getFolderContent | | | +------ in cache? -----------+ +--------+---------+ | | | | \ / | | | +--------+-------------+ | \_______/ | | | | loadFolderContent * | | | | | | +--------+-------------+ -----+------------ | | | | | --+------------+-- | | | | v | | | | | | | | | | | | ############# +----+---------+ | | -------+-----------------------+-- # getItem # | getParents | | | --------------+------------------- ############# +----+---------+ | | | | | | | | --+------------+-- | | | --------+--------- | | | | | | | ---+-------------------------+--------------------+--- | --------------------------+--------------------------- | | +-------------------+-------------------------------------------------+ | Notes: *: loadFolderContent is called both for root folder and child folder #: getProject and getItem are retrieving the current folder properties Since getFolderContent must be resolved at the same time than the retrieval of current folder properties, we need to start the retrieval of those properties earlier in the stack. This gives the following diagram: (router magic) | | ___ / \ Y / \ N +----------------- root? ---------------------------------------------+ | \ / | | \___/ +------+-----+ | | loadFolder | --------------+------------------- +------+-----+ -------+-----------------------+-- | | | | +----------+--------------+ +------+---------+ _______ | resetAscendantHierarchy | | loadRootFolder | / \ +----------+--------------+ +------+---------+ N / \ Y | | +------ in cache? --------------------+ | ############### | \ / | | # getProject # | \_______/ | | ############### | | | | \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \#\#\#\#\#\#\#\#\#\#\#\#\# | | | create promise with cached folder | | create getItem promise | | \\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ #\#\#\#\#\#\#\#\#\#\#\#\#\ | | create promise with root | | | | \\\\\\\\\\\\\\\\\\\\\\\\\\\\ +-----------+-------------------------+ | | | | +------------+--------------+ -----------------+--------------------------------------- | | getFolderContent(promise) | ----+-----------------------------------------------+---- | +------------+--------------+ | | | | +-----------+--------------------+ +------------+---------------+ -------+-----------------------+-- | loadAscendantHirarchy(promise) | | loadFolderContent(promise) | --------------+------------------- +-----------+--------------------+ +------------+---------------+ | | | | -----+------------ -----+------------ | --+------------+-- --+------------+-- | | | | | | | | | | | ////////////// +---+----------+ ////////////// +---+---------------+ | / promise ! / | getParents | / promise ! / | getFolderContent | | ////////////// +---+----------+ ////////////// +---+---------------+ | | | | | | --+------------+-- --+------------+-- | --------+--------- --------+--------- | | | | ---+-----------------------------------------------+--- | --------------------------+---------------------------- | | +--------------------+--------------------------------------------------------------+ | Change-Id: Id3f06f7c64eb115f16243229a6c071716b31b4c7

Modified Files

Name
M plugins/document/scripts/document/app.spec.js +2 โˆ’0 Go to diff View file
M plugins/document/scripts/document/components/Folder/ChildFolder.vue +6 โˆ’12 Go to diff View file
M plugins/document/scripts/document/components/Folder/EmptyState/EmptyFolder.vue +6 โˆ’2 Go to diff View file
M plugins/document/scripts/document/components/Folder/FolderContentRow.vue +1 โˆ’0 Go to diff View file
M plugins/document/scripts/document/components/Folder/FolderHeader.vue +8 โˆ’9 Go to diff View file
M plugins/document/scripts/document/components/Folder/FolderView.vue +1 โˆ’4 Go to diff View file
M plugins/document/scripts/document/components/Folder/RootFolder.vue +3 โˆ’4 Go to diff View file
M plugins/document/scripts/document/components/Folder/SearchBox.vue +3 โˆ’6 Go to diff View file
A plugins/document/scripts/document/store/actions-helpers/handle-errors.js +41 โˆ’0 Go to diff View file
A plugins/document/scripts/document/store/actions-helpers/load-ascendant-hierarchy.js +43 โˆ’0 Go to diff View file
A plugins/document/scripts/document/store/actions-helpers/load-ascendant-hierarchy.spec.js +174 โˆ’0 Go to diff View file
A plugins/document/scripts/document/store/actions-helpers/load-folder-content.js +39 โˆ’0 Go to diff View file
A plugins/document/scripts/document/store/actions-helpers/load-folder-content.spec.js +108 โˆ’0 Go to diff View file
M plugins/document/scripts/document/store/actions.js +54 โˆ’56 Go to diff View file
M plugins/document/scripts/document/store/actions.spec.js +174 โˆ’227 Go to diff View file
M plugins/document/scripts/document/store/getters.js +1 โˆ’1 Go to diff View file
M plugins/document/scripts/document/store/mutations.js +3 โˆ’3 Go to diff View file
M plugins/document/scripts/document/store/state.js +2 โˆ’3 Go to diff View file