feat: introduce hashids permalink keys (#19324)

* feat: introduce hashids permalink keys

* implement dashboard permalinks

* remove shorturl notice from UPDATING.md

* lint

* fix test

* introduce KeyValueResource

* make filterState optional

* fix test

* fix resource names

(cherry picked from commit f4b71abb22)
This commit is contained in:
Ville Brofeldt
2022-03-24 21:53:09 +02:00
committed by Ville Brofeldt
parent 18f82411c9
commit a6a2def6d3
39 changed files with 344 additions and 367 deletions

View File

@@ -24,23 +24,18 @@ from superset.dashboards.permalink.commands.base import BaseDashboardPermalinkCo
from superset.dashboards.permalink.exceptions import DashboardPermalinkCreateFailedError
from superset.dashboards.permalink.types import DashboardPermalinkState
from superset.key_value.commands.create import CreateKeyValueCommand
from superset.key_value.types import KeyType
from superset.key_value.utils import encode_permalink_key
logger = logging.getLogger(__name__)
class CreateDashboardPermalinkCommand(BaseDashboardPermalinkCommand):
def __init__(
self,
actor: User,
dashboard_id: str,
state: DashboardPermalinkState,
key_type: KeyType,
self, actor: User, dashboard_id: str, state: DashboardPermalinkState,
):
self.actor = actor
self.dashboard_id = dashboard_id
self.state = state
self.key_type = key_type
def run(self) -> str:
self.validate()
@@ -50,12 +45,10 @@ class CreateDashboardPermalinkCommand(BaseDashboardPermalinkCommand):
"dashboardId": self.dashboard_id,
"state": self.state,
}
return CreateKeyValueCommand(
actor=self.actor,
resource=self.resource,
value=value,
key_type=self.key_type,
key = CreateKeyValueCommand(
actor=self.actor, resource=self.resource, value=value,
).run()
return encode_permalink_key(key=key.id, salt=self.salt)
except SQLAlchemyError as ex:
logger.exception("Error running create command")
raise DashboardPermalinkCreateFailedError() from ex